Hi, You don't need to create thread, just register your thread into pjlib because the thread already created by external. I wrote a DLL library using pjmedia. This dll will export c functions. Becaue high level GUI programmer which call my DLL don't handle thread carefully, they event don't know when they will create thread. So I put code which like Manjeet provided into every exported function calls. typedef struct external_thread { pj_thread_desc desc; pj_thread_t *thread; } external_thread; std::list<external_thread *> e_threads; void exported_func() { // register external thread into pjlib first, like Manjeet provided. } regards, Gang On Sat, Apr 4, 2009 at 4:43 AM, Micha? <s-michael at o2.pl> wrote: > Hi. > > Manjeet, thanks for your reply. > > Unfortunately I still have problems with that. Maybe I'll write what I have > and what I want to have: > My driver ( DLL) is based on external library. In one method of its class, > let say: Line::MakeCall() I want to call pjsip function to handle SIP > communication. This function is simply PJSUA example with little changes > from: > http://www.pjsip.org/pjsip/docs/html/page_pjsip_sample_simple_pjsuaua_c.htm > > Currently I have this PJSUA example as method of my another class, let say > SipComm::initial(). As I see this code has some threads because without my > changes I was receiving: "Calling pjlib from unknown/external thread. You > must register external threads with pj_thread_register() before calling any > pjlib functions." > Thus I wanted to register and create thread ( e.g. pj_thread_create with > SipComm::initial() as parameter) and different combinations with calling it > in SipComm::initial() or in Line::MakeCall() before invoking > SipComm::initial() but I receive only "Calling pjlib from unknown/external > thread.." or hang out of driver. > I know that this description may be not satisfactory and so I would have > bigger thanks for any advices, because currently I'm out of ideas. > Best Regards > Michael > > manjeet pisze: > > Hi Michael, > > > > You have to call "pj_thread_register()" from the thread which is trying > to use PJlib. > > > > Something like below should work for you :- > > > > pj_thread_desc rtpdesc; > > pj_thread_t *thread = 0; > > > > // Register the thread with PJLIB, this is must for any external > threads > > // which need to use the PJLIB framework > > if (!pj_thread_is_registered()) > > { > > status = pj_thread_register("Threadname", rtpdesc, &thread ); > > if (status != PJ_SUCCESS) > > { > > app_perror("Threadname Failed to register with PJLIB,exit", > status); > > exit(1); > > } > > } > > > > if (pj_thread_is_registered()) > > { > > REPORTERROR("Threadname is succesfully registered with PJMedia"); > > } > > > > > > Regards, > > Manjeet > > > > > > --- On Thu, 4/2/09, Michael <s-michael at o2.pl> wrote: > > > > From: Michael <s-michael@xxxxx> > > Subject: Threads question > > To: pjsip at lists.pjsip.org > > Date: Thursday, April 2, 2009, 1:31 AM > > > > Hi All, > > > > I'm trying to use threads in my SIP driver under windows but without > > experience with threads I'm only receiving: "Calling pjlib from > > unknown/external thread. You must register external > > threads with > > pj_thread_register() before calling any pjlib functions." or it > crashes as > > soon as it reaches pj_pool_create and I can't do anything. > > > > I'm trying use simple PJSUA in my method responsible for starting SIP > > communication and from what I've read I have to register pjsip > thread. I would > > be very thankful for any advice when and where can I (have to) > register a > > thread, call pj_pool_create, pj_thread_create etc, or do I have to > consider > > other issues? . Maybe someone have sample code with threads, besides > those from > > pjsip site?. > > > > > > Thanks in advance > > Michael > > > > > > _______________________________________________ > > Visit our blog: http://blog.pjsip.org > > > > pjsip mailing list > > pjsip at lists.pjsip.org > > http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org > > > > > > > > > > _______________________________________________ > > Visit our blog: http://blog.pjsip.org > > > > pjsip mailing list > > pjsip at lists.pjsip.org > > http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org > > > > _______________________________________________ > Visit our blog: http://blog.pjsip.org > > pjsip mailing list > pjsip at lists.pjsip.org > http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org > -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.pjsip.org/pipermail/pjsip_lists.pjsip.org/attachments/20090405/65a604dd/attachment-0001.html>