Hey All,

I getting frustrated trying to get a working client. I am building for an embedded system which uses QT. I'd basically like to send/recv messages and send/recv calls. I'd like to use sofia-sip without glib and use Speex through gstreamer.

Here is what I have so far. This all runs in it's own thread.

void SofiaSipManager::start() {
#ifdef ENABLE_SOFIASIP
su_init();
su_home_init(sofiasip_home);
sofiasip_root = su_root_create(NULL);

sofiasip_callee = nua_create(sofiasip_root, /* event loop */
event_callback, /* Callback for processing events */
NULL, /* Additional data to pass to callback */
NUTAG_MEDIA_ENABLE(1),
NUTAG_URL(incoming),
TAG_END()); /* Last tag should always finish the sequence */

sofiasip_caller = nua_create(sofiasip_root, /* event loop */
event_callback, /* Callback for processing events */
NULL, /* Additional data to pass to callback */
NUTAG_MEDIA_ENABLE(1),
NUTAG_URL(outgoing),
TAG_END()); /* Last tag should always finish the sequence */

su_root_threading(sofiasip_root, 0);
su_root_run(sofiasip_root);

nua_destroy(sofiasip_callee);
nua_destroy(sofiasip_caller);
su_root_destroy(sofiasip_root);
su_home_deinit(sofiasip_home);
su_deinit();
#endif
}

void SofiaSipManager::handleSendMessage(QString to, QString message){
#ifdef ENABLE_SOFIASIP
nua_handle_t *handle;

handle = nua_handle(sofiasip_caller,
NULL,
SIPTAG_TO_STR(to.toLatin1()),
TAG_END());

nua_message(handle,
SIPTAG_CONTENT_TYPE_STR("text/plain"),
SIPTAG_PAYLOAD_STR(message.toLatin1()),
TAG_END());

nua_handle_destroy(handle);
#endif
}

/******************************************************************************
*
*****************************************************************************/
void SofiaSipManager::handleCall(QString to) {
#ifdef ENABLE_SOFIASIP
nua_handle_t *handle;

handle = nua_handle(sofiasip_caller,
NULL,
SIPTAG_TO_STR(to.toLatin1()),
TAG_END());

nua_invite(handle,
SIPTAG_CONTENT_TYPE_STR("application/sdp"),
SOATAG_ADDRESS("127.0.0.1"),
SOATAG_USER_SDP_STR(
"m=audio 49984 RTP/AVP 0\n"
"a=rtpmap:0 PCMU/8000\n"
"c=IN IP4 127.0.0.1\n"),
TAG_END());
#endif
}

#ifdef ENABLE_SOFIASIP
void event_callback(nua_event_t event,
int status,
char const *phrase,
nua_t *nua,
nua_magic_t *magic,
nua_handle_t *nh,
nua_hmagic_t *hmagic,
sip_t const *sip,
tagi_t tags[]) {

tl_print(stdout, "Tags:", tags);

switch (event) {
case nua_r_invite:
S_DEBUG(QS("RECV Invite event %1 status %2 %3").arg(nua_event_name(event)).arg(status).arg(phrase));
if (status == 200) nua_ack(nh, TAG_END());
break;
case nua_i_invite:
S_DEBUG(QS("INVITE Invite event %1 status %2 %3").arg(nua_event_name(event)).arg(status).arg(phrase));
nua_respond(nh,
200,
"OK",
SIPTAG_CONTENT_TYPE_STR("application/sdp"),
SOATAG_USER_SDP_STR("m=audio 8000 RTP/AVP 0\n"
"a=rtpmap:0 PCMU/8000\n"),
TAG_END());
break;
case nua_i_state:
S_DEBUG(QS("INVITE State event %1 status %2 %3").arg(nua_event_name(event)).arg(status).arg(phrase));
nua_callstate state = (nua_callstate)callstate(tags);
S_DEBUG(QS("State change: %1").arg( nua_callstate_name(state) ) );
break;
case nua_i_message:
S_DEBUG(QS("INVITE Message event %1 status %2 %3").arg(nua_event_name(event)).arg(status).arg(phrase));
if (sip->sip_payload) {
S_DEBUG(QS("%1 said %2").arg(sip->sip_from->a_display).arg(sip->sip_payload->pl_data));
sofiasipManagerInstance->emitRecvMessage(sip->sip_from->a_display,sip->sip_payload->pl_data);
}
break;
case nua_i_notify:
S_DEBUG(QS("INVITE Notify event %1 status %2 %3").arg(nua_event_name(event)).arg(status).arg(phrase));
tagi_t const *t = tl_find(tags, nutag_substate);
nua_substate substate = (nua_substate)(t ? t->t_value : 0);
S_DEBUG(QS("Substate: %1").arg(nua_substate_name(substate)));
break;
default:
if (status > 100){
S_DEBUG(QS("event %1 status %2 %3").arg(nua_event_name(event)).arg(status).arg(phrase));
}else{
S_DEBUG(QS("event %1 status %2 %3").arg(nua_event_name(event)).arg(status).arg(phrase));
}
nua_handle_destroy(nh);
break;
}
}
#endif

Using Ekiga as the other phone; I can send/recv messages fine but I cannot send/recv calls. When I go to make a call it fails within a second of being connected.

outgoing call log:
[14:02:30.122 dbg1 2ncdko-PhoneManagerThread] sofiasip_manager.cpp:247 : handleCall()
Tags: nua::callstate: 2
soa::active_audio: 3
nua::offer_sent: true
soa::local_sdp: v=0
o=- 8624069989177229576 816566757862232857 IN IP4 127.0.0.1
s=-
t=0 0
m=audio 49984 RTP/AVP 0
c=IN IP4 127.0.0.1
a=rtpmap:0 PCMU/8000
soa::local_sdp_str: "v=0
o=- 8624069989177229576 816566757862232857 IN IP4 127.0.0.1
s=-
t=0 0
m=audio 49984 RTP/AVP 0
c=IN IP4 127.0.0.1
a=rtpmap:0 PCMU/8000
"
::tag_null: 0
[14:02:30.123 dbg1 2nc5wo-SofiaSipManagerThread] sofiasip_manager.cpp:92 : INVITE State event nua_i_state status 0 INVITE sent [14:02:30.123 dbg1 2nc5wo-SofiaSipManagerThread] sofiasip_manager.cpp:94 : State change: calling
Tags: ::tag_null: 0
[14:02:30.136 dbg1 2nc5wo-SofiaSipManagerThread] sofiasip_manager.cpp:78 : RECV Invite event nua_r_invite status 180 Ringing
Tags: nua::callstate: 3
soa::active_audio: 3
::tag_null: 0
[14:02:30.136 dbg1 2nc5wo-SofiaSipManagerThread] sofiasip_manager.cpp:92 : INVITE State event nua_i_state status 180 Ringing [14:02:30.136 dbg1 2nc5wo-SofiaSipManagerThread] sofiasip_manager.cpp:94 : State change: proceeding [14:02:30.785 dbg1 Main] view_event_filter.cpp:103 : focusChanged(162124032/QPushButton, 0/NULL)
Tags: soa::active_audio: 3
::tag_null: 0
[14:02:31.880 dbg1 2nc5wo-SofiaSipManagerThread] sofiasip_manager.cpp:78 : RECV Invite event nua_r_invite status 200 OK
Tags: nua::callstate: 8
soa::active_audio: 3
nua::answer_recv: true
soa::remote_sdp: v=0
o=- 1248976951 1248976951 IN IP4 166.17.243.59
s=Opal SIP Session
c=IN IP4 166.17.243.59
t=0 0
m=audio 5068 RTP/AVP 0
a=rtpmap:0 PCMU/8000/1
soa::remote_sdp_str: "v=0
o=- 1248976951 1248976951 IN IP4 166.17.243.59
s=Opal SIP Session
c=IN IP4 166.17.243.59
t=0 0
m=audio 5068 RTP/AVP 0
a=rtpmap:0 PCMU/8000/1
"
::tag_null: 0
[14:02:31.880 dbg1 2nc5wo-SofiaSipManagerThread] sofiasip_manager.cpp:92 : INVITE State event nua_i_state status 200 OK [14:02:31.880 dbg1 2nc5wo-SofiaSipManagerThread] sofiasip_manager.cpp:94 : State change: ready
Tags: soa::active_audio: 3
::tag_null: 0
[14:02:31.880 dbg1 2nc5wo-SofiaSipManagerThread] sofiasip_manager.cpp:111 : event nua_i_active status 200 Call active


Incoming call:
[14:03:35.074 dbg1 2o5814-SofiaSipManagerThread] sofiasip_manager.cpp:82 : INVITE Invite event nua_i_invite status 100 Trying
Tags: nua::callstate: 5
soa::active_audio: 0
soa::active_video: 0
soa::active_image: 0
soa::active_chat: 0
nua::offer_recv: true
soa::remote_sdp: v=0
o=- 1248977015 1248977015 IN IP4 166.17.243.59
s=Opal SIP Session
c=IN IP4 166.17.243.59
t=0 0
m=audio 5074 RTP/AVP 3 122 123 108 103 102 124 99 8 0 101 100
a=rtpmap:3 gsm/8000/1
a=rtpmap:122 Speex/8000/1
a=fmtp:122 sr=8000,mode=any
a=rtpmap:123 Speex/16000/1
a=fmtp:123 sr=16000,mode=any
a=rtpmap:108 iLBC/8000/1
a=fmtp:108 mode=20
a=rtpmap:103 G726-16/8000/1
a=rtpmap:102 G726-24/8000/1
a=rtpmap:124 G726-32/8000/1
a=rtpmap:99 G726-40/8000/1
a=rtpmap:8 PCMA/8000/1
a=rtpmap:0 PCMU/8000/1
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-15,32-49
a=rtpmap:100 NSE/8000
a=fmtp:100 192-193
m=video 5076 RTP/AVP 107 125 31
a=rtpmap:107 h264/90000
a=fmtp:107 packetization-mode="1";profile-level-id="42C01E"
a=rtpmap:125 theora/90000
a=fmtp:125 delivery-method="in_band";height=576;sampling="YCbCr-4:2:0";width=704
a=rtpmap:31 h261/90000
a=fmtp:31 CIF=1;QCIF=1
soa::remote_sdp_str: "v=0
o=- 1248977015 1248977015 IN IP4 166.17.243.59
s=Opal SIP Session
c=IN IP4 166.17.243.59
t=0 0
m=audio 5074 RTP/AVP 3 122 123 108 103 102 124 99 8 0 101 100
a=rtpmap:3 gsm/8000/1
a=rtpmap:122 Speex/8000/1
a=fmtp:122 sr=8000,mode=any
a=rtpmap:123 Speex/16000/1
a=fmtp:123 sr=16000,mode=any
a=rtpmap:108 iLBC/8000/1
a=fmtp:108 mode=20
a=rtpmap:103 G726-16/8000/1
a=rtpmap:102 G726-24/8000/1
a=rtpmap:124 G726-32/8000/1
a=rtpmap:99 G726-40/8000/1
a=rtpmap:8 PCMA/8000/1
a=rtpmap:0 PCMU/8000/1
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-15,32-49
a=rtpmap:100 NSE/8000
a=fmtp:100 192-193
m=video 5076 RTP/AVP 107 125 31
a=rtpmap:107 h264/90000
a=fmtp:107 packetization-mode="1";profile-level-id="42C01E"
a=rtpmap:125 theora/90000
a=fmtp:125 delivery-method="in_band";height=576;sampling="YCbCr-4:2:0";width=704
a=rtpmap:31 h261/90000
a=fmtp:31 CIF=1;QCIF=1
"
::tag_null: 0
[14:03:35.074 dbg1 2o5814-SofiaSipManagerThread] sofiasip_manager.cpp:92 : INVITE State event nua_i_state status 100 Trying [14:03:35.074 dbg1 2o5814-SofiaSipManagerThread] sofiasip_manager.cpp:94 : State change: received
Tags: nua::callstate: 7
soa::active_audio: 3
nua::answer_sent: true
soa::local_sdp: v=0
o=- 6238591492794951955 4371138495210417909 IN IP4 166.17.243.201
s=-
c=IN IP4 166.17.243.201
t=0 0
m=audio 8000 RTP/AVP 0
a=rtpmap:0 PCMU/8000
m=video 0 RTP/AVP 19
soa::local_sdp_str: "v=0
o=- 6238591492794951955 4371138495210417909 IN IP4 166.17.243.201
s=-
c=IN IP4 166.17.243.201
t=0 0
m=audio 8000 RTP/AVP 0
a=rtpmap:0 PCMU/8000
m=video 0 RTP/AVP 19
"
::tag_null: 0
[14:03:35.075 dbg1 2o5814-SofiaSipManagerThread] sofiasip_manager.cpp:92 : INVITE State event nua_i_state status 200 OK [14:03:35.075 dbg1 2o5814-SofiaSipManagerThread] sofiasip_manager.cpp:94 : State change: completed
Tags: ::tag_null: 0
[14:03:35.092 dbg1 2o5814-SofiaSipManagerThread] sofiasip_manager.cpp:111 : event nua_i_ack status 200 OK
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Sofia-sip-devel mailing list
Sofia-sip-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sofia-sip-devel

Reply via email to