[pjsip] need help with pj_register_thread

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi
New to PJSIP!

Ok, I intend to create a SIPUA and SIP-Registrar using PJSIP. I havent gone far as I am facing issues in creating pool factory and pools? Following is my code so far. I am using Visual Studio. My application hasnt got any threads but I still had to call register_thread fn to create pool factory. However, even that isnt working for me!


#include "stdafx.h"
#include "stdio.h"
#include "PjDemo_End_to_End_call_Signaling.h" // this is my own header file. 
#include "conio.h" //for _getch()
#include "pjlib.h"
#include <windows.h>

//using namespace System;

pj_caching_pool cp;
pj_thread_desc thread_desc;
pj_thread_t *thread_handle;

int main(int argc, char** argv)
{
    pj_pool_t *pool = NULL;

    /*if(TOTAL_ARGS != argc)
    {
        printf("\nUsage: pjsip.exe Role IP Port\nRole: UA R");
        _getch();
    }
    */

    pj_thread_register("main_thread",thread_desc,&thread_handle); // this is not successful.

    pj_caching_pool_init(&cp,&pj_pool_factory_default_policy, 0); //later this fails

    /* how many pools to create?*/
    pool = pj_pool_create (&cp.factory,"mypool",4000,4000,NULL);
    
    if(NULL == pool)
    {
        printf("\nError in creating pool %s:%lu",__FILE__,__LINE__);
        return 1;
    }
    return 0;
}



Following code returns failure. It is called while I am registering thread.

PJ_DEF(pj_status_t) pj_thread_local_set(long index, void *value)
{
    BOOL rc;

    //Can't check stack because this function is called in the
    //beginning before main thread is initialized.
    //PJ_CHECK_STACK();
    rc = TlsSetValue(index, value);
    return rc!=0 ? PJ_SUCCESS : PJ_RETURN_OS_ERROR(GetLastError());
}


Later in pj_caching_pool_init, PJ_CHECK_STACK fails.

pls pls pls pls...pls help.

One more thing, I am a little confused between pool factory and pool thread. From the name, I felt that pool factory contains pools of various sizes but we create those individual pools using pool_create. However, when I read the code, it looked as if pool_create is used to get an already created buffer. The buffers are actually created while creating factory. Is it so?


Thanks
--Manu



__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.pjsip.org/pipermail/pjsip_lists.pjsip.org/attachments/20071025/8ac57c6e/attachment-0001.html 


[Index of Archives]     [Asterisk Users]     [Asterisk App Development]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [Linux API]
  Powered by Linux