Hi,
Is it possible to have two pjsip instances running simultaneously in the
same app?
I want to have two "SIP engines" running side by side (don't ask why :p)
After SIPEngine_1 is initialized and running fine, I try to launch
SIPEngine_2 but the problems start when I try to Init the transaction
layer...
This is what I try to run when start SIP Engine 2
pj_status_t status;
/* Must init PJLIB first: */
// status = pj_init();
// pj_assert(status == PJ_SUCCESS);
/* Then init PJLIB-UTIL: */
// status = pjlib_util_init();
// pj_assert(status == PJ_SUCCESS);
pj_thread_desc desc;
pj_thread_t *this_thread;
status = pj_thread_register("Thread FaxSipEngine", desc, &this_thread);
if (status != PJ_SUCCESS) {
Logger::instance->Debug("FAXSIPENGINE | Unable to register
pj_thread");
return;
}
/* Must create a pool factory before we can allocate any memory. */
pj_caching_pool_init(&cp, &pj_pool_factory_default_policy, 0);
/* Create global endpoint: */
{
const pj_str_t *hostname;
const char *endpt_name;
/* Endpoint MUST be assigned a globally unique name.
* The name will be used as the hostname in Warning header.
*/
/* For this implementation, we'll use hostname for simplicity */
hostname = pj_gethostname();
endpt_name = hostname->ptr;
/* Create the endpoint: */
status = pjsip_endpt_create(&cp.factory, endpt_name,
&g_endpt);
pj_assert(status == PJ_SUCCESS);
}
/*
* Add UDP transport, with hard-coded port
* Alternatively, application can use pjsip_udp_transport_attach() to
* start UDP transport, if it already has an UDP socket (e.g. after it
* resolves the address with STUN).
*/
{
pj_sockaddr_in addr;
status = !PJ_SUCCESS;
while(status != PJ_SUCCESS){
addr.sin_family = pj_AF_INET();
addr.sin_addr.s_addr = 0;
addr.sin_port = pj_htons((pj_uint16_t)mySipPort);
status = pjsip_udp_transport_start( g_endpt, &addr, NULL, 1,
NULL);
if(status != PJ_SUCCESS)
Fax::instance->mySipPort++;
}
if (status != PJ_SUCCESS) {
;//app_perror(THIS_FILE, "Unable to start UDP transport",
status);
return;
}
}
/*
* Init transaction layer.
* This will create/initialize transaction hash tables etc.
*/
status = pjsip_tsx_layer_init_module(g_endpt);
pj_assert(status == PJ_SUCCESS);
/*
* Initialize UA layer module.
* This will create/initialize dialog hash tables etc.
*/
status = pjsip_ua_init_module( g_endpt, NULL );
pj_assert(status == PJ_SUCCESS);
[...]
Any help will be appreciated ;)
André
On 3/19/08, André Teixeira coelho@wit-software.com wrote:
Hi,
Is it possible to have two pjsip instances running simultaneously in the
same app?
No, not possible, sorry. We have some global variables lying around,
so this is not possible.
I want to have two "SIP engines" running side by side (don't ask why :p)
I'm afraid I have to ask why. :)
Cheers,
-benny
After SIPEngine_1 is initialized and running fine, I try to launch
SIPEngine_2 but the problems start when I try to Init the transaction
layer...
This is what I try to run when start SIP Engine 2
pj_status_t status;
/* Must init PJLIB first: */
// status = pj_init();
// pj_assert(status == PJ_SUCCESS);
/* Then init PJLIB-UTIL: */
// status = pjlib_util_init();
// pj_assert(status == PJ_SUCCESS);
pj_thread_desc desc;
pj_thread_t *this_thread;
status = pj_thread_register("Thread FaxSipEngine", desc, &this_thread);
if (status != PJ_SUCCESS) {
Logger::instance->Debug("FAXSIPENGINE | Unable to register
pj_thread");
return;
}
/* Must create a pool factory before we can allocate any memory. */
pj_caching_pool_init(&cp, &pj_pool_factory_default_policy, 0);
/* Create global endpoint: */
{
const pj_str_t *hostname;
const char *endpt_name;
/* Endpoint MUST be assigned a globally unique name.
* The name will be used as the hostname in Warning header.
*/
/* For this implementation, we'll use hostname for simplicity */
hostname = pj_gethostname();
endpt_name = hostname->ptr;
/* Create the endpoint: */
status = pjsip_endpt_create(&cp.factory, endpt_name,
&g_endpt);
pj_assert(status == PJ_SUCCESS);
}
/*
* Add UDP transport, with hard-coded port
* Alternatively, application can use pjsip_udp_transport_attach() to
* start UDP transport, if it already has an UDP socket (e.g. after it
* resolves the address with STUN).
*/
{
pj_sockaddr_in addr;
status = !PJ_SUCCESS;
while(status != PJ_SUCCESS){
addr.sin_family = pj_AF_INET();
addr.sin_addr.s_addr = 0;
addr.sin_port = pj_htons((pj_uint16_t)mySipPort);
status = pjsip_udp_transport_start( g_endpt, &addr, NULL, 1,
NULL);
if(status != PJ_SUCCESS)
Fax::instance->mySipPort++;
}
if (status != PJ_SUCCESS) {
;//app_perror(THIS_FILE, "Unable to start UDP transport",
status);
return;
}
}
/*
* Init transaction layer.
* This will create/initialize transaction hash tables etc.
*/
status = pjsip_tsx_layer_init_module(g_endpt);
pj_assert(status == PJ_SUCCESS);
/*
* Initialize UA layer module.
* This will create/initialize dialog hash tables etc.
*/
status = pjsip_ua_init_module( g_endpt, NULL );
pj_assert(status == PJ_SUCCESS);
[...]
Any help will be appreciated ;)
André
Visit our blog: http://blog.pjsip.org
pjsip mailing list
pjsip@lists.pjsip.org
http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org
You CAN, of course, run two version on the same computer. (I do this
all the time, just give them different ports.) Those two processes
can talk via a pipe or shared memory (at least under Linux.)
I wonder if one could do some sort of hack by making multiple shared
libraries of PJSIP and loading it multiple times into an app? Would
the globals be segregated in their own area via the shared library?
Norman Franke
Answering Service for Directors, Inc.
www.myasd.com
On Mar 19, 2008, at 1:57 PM, Benny Prijono wrote:
On 3/19/08, André Teixeira coelho@wit-software.com wrote:
Hi,
Is it possible to have two pjsip instances running simultaneously
in the
same app?
No, not possible, sorry. We have some global variables lying around,
so this is not possible.
I want to have two "SIP engines" running side by side (don't ask
why :p)
I'm afraid I have to ask why. :)
Cheers,
-benny
After SIPEngine_1 is initialized and running fine, I try to launch
SIPEngine_2 but the problems start when I try to Init the
transaction
layer...
This is what I try to run when start SIP Engine 2
pj_status_t status;
/* Must init PJLIB first: */
// status = pj_init();
// pj_assert(status == PJ_SUCCESS);
/* Then init PJLIB-UTIL: */
// status = pjlib_util_init();
// pj_assert(status == PJ_SUCCESS);
pj_thread_desc desc;
pj_thread_t *this_thread;
status = pj_thread_register("Thread FaxSipEngine", desc,
&this_thread);
if (status != PJ_SUCCESS) {
Logger::instance->Debug("FAXSIPENGINE | Unable to register
pj_thread");
return;
}
/* Must create a pool factory before we can allocate any
memory. */
pj_caching_pool_init(&cp, &pj_pool_factory_default_policy, 0);
/* Create global endpoint: */
{
const pj_str_t *hostname;
const char *endpt_name;
/* Endpoint MUST be assigned a globally unique name.
* The name will be used as the hostname in Warning header.
*/
/* For this implementation, we'll use hostname for
simplicity */
hostname = pj_gethostname();
endpt_name = hostname->ptr;
/* Create the endpoint: */
status = pjsip_endpt_create(&cp.factory, endpt_name,
&g_endpt);
pj_assert(status == PJ_SUCCESS);
}
/*
* Add UDP transport, with hard-coded port
* Alternatively, application can use
pjsip_udp_transport_attach() to
* start UDP transport, if it already has an UDP socket (e.g.
after it
* resolves the address with STUN).
*/
{
pj_sockaddr_in addr;
status = !PJ_SUCCESS;
while(status != PJ_SUCCESS){
addr.sin_family = pj_AF_INET();
addr.sin_addr.s_addr = 0;
addr.sin_port = pj_htons((pj_uint16_t)mySipPort);
status = pjsip_udp_transport_start( g_endpt, &addr,
NULL, 1,
NULL);
if(status != PJ_SUCCESS)
Fax::instance->mySipPort++;
}
if (status != PJ_SUCCESS) {
;//app_perror(THIS_FILE, "Unable to start UDP transport",
status);
return;
}
}
PROBLEMS START HERE, I get an assertion error inside
pjsip_tsx_layer_init_module(g_endpt);
/*
* Init transaction layer.
* This will create/initialize transaction hash tables etc.
*/
status = pjsip_tsx_layer_init_module(g_endpt);
pj_assert(status == PJ_SUCCESS);
/*
* Initialize UA layer module.
* This will create/initialize dialog hash tables etc.
*/
status = pjsip_ua_init_module( g_endpt, NULL );
pj_assert(status == PJ_SUCCESS);
[...]
Any help will be appreciated ;)
André
Visit our blog: http://blog.pjsip.org
pjsip mailing list
pjsip@lists.pjsip.org
http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org
Visit our blog: http://blog.pjsip.org
pjsip mailing list
pjsip@lists.pjsip.org
http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org
Ok, I kinda expected that answer....
It would be nice because i've build a module separately from the main
application, and now I was trying to integrate everything. Once the main
app is a bit complex I didn't want to be messing around too much.....
But now I guess will happen :-P
Thanks anyway
Benny Prijono wrote:
On 3/19/08, André Teixeira coelho@wit-software.com wrote:
Hi,
Is it possible to have two pjsip instances running simultaneously in the
same app?
No, not possible, sorry. We have some global variables lying around,
so this is not possible.
I want to have two "SIP engines" running side by side (don't ask why :p)
I'm afraid I have to ask why. :)
Cheers,
-benny
After SIPEngine_1 is initialized and running fine, I try to launch
SIPEngine_2 but the problems start when I try to Init the transaction
layer...
This is what I try to run when start SIP Engine 2
pj_status_t status;
/* Must init PJLIB first: */
// status = pj_init();
// pj_assert(status == PJ_SUCCESS);
/* Then init PJLIB-UTIL: */
// status = pjlib_util_init();
// pj_assert(status == PJ_SUCCESS);
pj_thread_desc desc;
pj_thread_t *this_thread;
status = pj_thread_register("Thread FaxSipEngine", desc, &this_thread);
if (status != PJ_SUCCESS) {
Logger::instance->Debug("FAXSIPENGINE | Unable to register
pj_thread");
return;
}
/* Must create a pool factory before we can allocate any memory. */
pj_caching_pool_init(&cp, &pj_pool_factory_default_policy, 0);
/* Create global endpoint: */
{
const pj_str_t *hostname;
const char *endpt_name;
/* Endpoint MUST be assigned a globally unique name.
* The name will be used as the hostname in Warning header.
*/
/* For this implementation, we'll use hostname for simplicity */
hostname = pj_gethostname();
endpt_name = hostname->ptr;
/* Create the endpoint: */
status = pjsip_endpt_create(&cp.factory, endpt_name,
&g_endpt);
pj_assert(status == PJ_SUCCESS);
}
/*
* Add UDP transport, with hard-coded port
* Alternatively, application can use pjsip_udp_transport_attach() to
* start UDP transport, if it already has an UDP socket (e.g. after it
* resolves the address with STUN).
*/
{
pj_sockaddr_in addr;
status = !PJ_SUCCESS;
while(status != PJ_SUCCESS){
addr.sin_family = pj_AF_INET();
addr.sin_addr.s_addr = 0;
addr.sin_port = pj_htons((pj_uint16_t)mySipPort);
status = pjsip_udp_transport_start( g_endpt, &addr, NULL, 1,
NULL);
if(status != PJ_SUCCESS)
Fax::instance->mySipPort++;
}
if (status != PJ_SUCCESS) {
;//app_perror(THIS_FILE, "Unable to start UDP transport",
status);
return;
}
}
/*
* Init transaction layer.
* This will create/initialize transaction hash tables etc.
*/
status = pjsip_tsx_layer_init_module(g_endpt);
pj_assert(status == PJ_SUCCESS);
/*
* Initialize UA layer module.
* This will create/initialize dialog hash tables etc.
*/
status = pjsip_ua_init_module( g_endpt, NULL );
pj_assert(status == PJ_SUCCESS);
[...]
Any help will be appreciated ;)
André
Visit our blog: http://blog.pjsip.org
pjsip mailing list
pjsip@lists.pjsip.org
http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org
Visit our blog: http://blog.pjsip.org
pjsip mailing list
pjsip@lists.pjsip.org
http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org
André Teixeira wrote:
Ok, I kinda expected that answer....
cool, a chess player ;)
It would be nice because i've build a module separately from the main
application, and now I was trying to integrate everything. Once the main
app is a bit complex I didn't want to be messing around too much.....
But now I guess will happen :-P
can you please give more details since it sounds really cool!
Thanks anyway
Best regards,
Mike