|
List Info
Thread: Invite Hello World
|
|
| Invite Hello World |
  Australia |
2007-05-06 06:46:00 |
Hello list,
I'm trying to get a simple "hello world" sample up
and going and I am
having trouble sending and receiving an INVITE. I've looked
at
http://wiki.opensource.nokia.com/projects/SofiaTutorial
a> and I can send and
receive a simple message. But I would like help sending and
receiving an
INVITE (the API is still very new to me).
Below is my humble attempt, can anyone see where I have
messed up big time
and help me resolve the issue.
I would like the Caller to send the invite to the Callee.
Thank you in advance!
---code---
#include <stdio.h>
#include <sofia-sip/nua.h>
// #define CALLER 1
struct application
{
su_home_t home; /* memory home */
su_root_t* root; /* root object */
nua_t* nua; /* NUA stack object */
};
void event_callback(nua_event_t event, int status, const
char* phrase,
nua_t* nua, nua_magic_t* magic, nua_handle_t* nh,
nua_hmagic_t* hmagic,
const sip_t* sip, tagi_t tags[]);
void send_invite(nua_t* nua, su_home_t*);
void event_i_invite(int status, const char* phrase, nua_t*
nua,
nua_magic_t* magic, nua_handle_t* nh, nua_hmagic_t* hmagic,
const sip_t*
sip, tagi_t tags[]);
void event_r_invite(int status, const char* phrase, nua_t*
nua,
nua_magic_t* magic, nua_handle_t* nh, nua_hmagic_t* hmagic,
const sip_t*
sip, tagi_t tags[]);
int main(int argc, char* argv[])
{
application app = ;
app.home.suh_size = sizeof(application);
su_init();
su_home_init(&app.home);
app.root = su_root_create(&app);
#ifdef CALLER
printf("I am the Callern");
#else
printf("I am the Calleen");
#endif
if (app.root != NULL)
{
app.nua = nua_create(app.root, event_callback,
&app,
#ifdef CALLER
NUTAG_URL("sip:0.0.0.0:5062"),
/* Address to bind to */
#else
NUTAG_URL("sip:0.0.0.0:5060"),
#endif
TAG_END());
if (app.nua != NULL)
{
nua_set_params(app.nua,
SIPTAG_USER_AGENT_STR("Simon/1.0"),
SIPTAG_ALLOW_STR("INVITE,CANCEL,BYE,ACK"),
SIPTAG_USER_AGENT(NULL),
NUTAG_AUTOACK(1),
TAG_END());
#ifdef CALLER
send_invite(app.nua, &app.home);
#endif
su_root_run(app.root);
nua_destroy(app.nua);
}
su_root_destroy(app.root);
}
su_home_deinit(&app.home);
su_deinit();
return 0;
}
void event_callback(nua_event_t event, int status, const
char* phrase,
nua_t* nua, nua_magic_t* magic, nua_handle_t* nh,
nua_hmagic_t* hmagic,
const sip_t* sip, tagi_t tags[])
{
switch (event)
{
case nua_i_invite:
event_i_invite(status, phrase, nua, magic, nh,
hmagic, sip, tags);
break;
case nua_r_invite:
event_r_invite(status, phrase, nua, magic, nh,
hmagic, sip, tags);
break;
case nua_r_set_params:
break;
/* and so on ... */
default:
/* unknown event -> print out error message */
if (status > 100)
{
printf("Unknown event %d: %03d %sn",
event, status, phrase);
}
else
{
printf("Unknown event %dn", event);
}
}
return;
}
void send_invite(nua_t* nua, su_home_t* h)
{
nua_handle_t* handle = nua_handle(nua, h,
SIPTAG_TO_STR("sip:test 127.0.0.1:5060"),
TAG_END());
nua_invite(handle, TAG_END());
nua_handle_destroy(handle);
return;
}
void event_i_invite(int status, const char* phrase, nua_t*
nua,
nua_magic_t* magic, nua_handle_t* nh, nua_hmagic_t* hmagic,
const sip_t*
sip, tagi_t tags[])
{
printf("Incoming call...n");
return;
}
void event_r_invite(int status, const char* phrase, nua_t*
nua,
nua_magic_t* magic, nua_handle_t* nh, nua_hmagic_t* hmagic,
const sip_t*
sip, tagi_t tags[])
{
printf("Response to INVITE: %03d %sn", status,
phrase);
return;
}
------------------------------------------------------------
-------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and
take
control of your XML. No limits. Just data. Click to get it
now.
http://sourcefor
ge.net/powerbar/db2/
_______________________________________________
Sofia-sip-devel mailing list
Sofia-sip-devel lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sofia-s
ip-devel
|
|
| Re: Invite Hello World |
  Russian Federation |
2007-05-07 02:30:20 |
В Вск, 06/05/2007 в 21:46 +1000, simon pixeltangent.com пишет:
> Hello list,
>
> I'm trying to get a simple "hello world"
sample up and going and I am
> having trouble sending and receiving an INVITE. I've
looked at
> http://wiki.opensource.nokia.com/projects/SofiaTutorial
a> and I can send and
> receive a simple message. But I would like help sending
and receiving an
> INVITE (the API is still very new to me).
>
> Below is my humble attempt, can anyone see where I have
messed up big time
> and help me resolve the issue.
>
> I would like the Caller to send the invite to the
Callee.
>
> Thank you in advance!
Hello Simon. Since invite should initialize SDP, you have to
pass sdp
string to call nua_invite, then it will work, try:
> nua_invite(handle,
> SOATAG_USER_SDP_STR("v=0rnm=audio
5000 RTP/AVP 18 8rn"
> "a=rtpmap:18
G729/8000rn"
> "a=rtpmap:8
PCMA/8000rn"),
> TAG_END());
Heh, I'd better file a bug about that, it's really easy to
fire a warning to
developer about incorrect api usage. But it's really hard to
find what's wrong
in this case moreover if you are newbie.
------------------------------------------------------------
-------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and
take
control of your XML. No limits. Just data. Click to get it
now.
http://sourcefor
ge.net/powerbar/db2/
_______________________________________________
Sofia-sip-devel mailing list
Sofia-sip-devel lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sofia-s
ip-devel
|
|
| Re: Invite Hello World |
  Australia |
2007-05-07 21:47:48 |
Thankyou so very much, I know I will have more questions in
the future.
> В Вск, 06/05/2007 в 21:46 +1000, simon pixeltangent.com пишет:
>> Hello list,
>>
>> I'm trying to get a simple "hello world"
sample up and going and I am
>> having trouble sending and receiving an INVITE.
I've looked at
>> http://wiki.opensource.nokia.com/projects/SofiaTutorial
a> and I can send
>> and
>> receive a simple message. But I would like help
sending and receiving an
>> INVITE (the API is still very new to me).
>>
>> Below is my humble attempt, can anyone see where I
have messed up big
>> time
>> and help me resolve the issue.
>>
>> I would like the Caller to send the invite to the
Callee.
>>
>> Thank you in advance!
>
> Hello Simon. Since invite should initialize SDP, you
have to pass sdp
> string to call nua_invite, then it will work, try:
>
>
>> nua_invite(handle,
>>
SOATAG_USER_SDP_STR("v=0rnm=audio 5000 RTP/AVP 18
>> 8rn"
>>
"a=rtpmap:18 G729/8000rn"
>> "a=rtpmap:8
PCMA/8000rn"),
>> TAG_END());
>
> Heh, I'd better file a bug about that, it's really easy
to fire a warning
> to
> developer about incorrect api usage. But it's really
hard to find what's
> wrong
> in this case moreover if you are newbie.
>
>
------------------------------------------------------------
-------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and
take
control of your XML. No limits. Just data. Click to get it
now.
http://sourcefor
ge.net/powerbar/db2/
_______________________________________________
Sofia-sip-devel mailing list
Sofia-sip-devel lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sofia-s
ip-devel
|
|
[1-3]
|
|