These are my SDP outputs:
LOCAL:
v=0
o=3686278856 0 0 IN IP4 10.0.0.27
s=Session SIP/SDP
c=IN IP4 10.0.0.27
t=0 0
a=rtpmap:8 PCMA/8000/1
a=rtpmap:18 G729/8000/1
a=fmtp:18 annexb=no
a=rtpmap:0 PCMU/8000/1
a=rtpmap:111 ILBC/8000/1
a=fmtp:111 mode=30
a=ptime:20
m=audio 3001 RTP/AVP 8 18 0 111
a=rtpmap:8 PCMA/8000/1
a=rtpmap:18 G729/8000/1
a=fmtp:18 annexb=no
a=rtpmap:0 PCMU/8000/1
a=rtpmap:111 ILBC/8000/1
a=fmtp:111 mode=30
a=ptime:20
REMOTE: SIP SERVER:
v=0
o=- 150969000 1806128112579501 IN IP4 [IP_OF_MY_SIP_SERVER]
s=Dialogic_SIP_CCLIB
c=IN IP4 217.65.176.110
t=0 0
a=rtpmap:8 PCMA/8000/1
a=ptime:20
a=sendrecv
m=audio 21104 RTP/AVP 8
c=IN IP4 217.65.176.110
a=rtpmap:8 PCMA/8000/1
a=ptime:20
a=sendrecv
new SDP:
v=0
o=- 150969000 1806128112579501 IN IP4 [IP_OF_MY_SIP_SERVER]
s=Dialogic_SIP_CCLIB
c=IN IP4 10.0.0.27
t=0 0
m=audio 3001 RTP/AVP 8
a=rtpmap:8 PCMA/8000/1
--------------------------------------------
1.FIRST PROBLEM (As far as I see solved)
1.1.Problem Definition
I try to parse SDP string below with the newest version of
org.zoolu.sdp.SDPParser (with Generic Vector).
----
v=0
o=- 151044168 1474421261158700 IN IP4 217.65.174.109
s=Dialogic_SIP_CCLIB
t=0 0
m=audio 22824 RTP/AVP 8
c=IN IP4 217.65.176.110
a=rtpmap:8 PCMA/8000/1
a=ptime:20
a=sendrecv
-----
But, in this method, it cant parse "m" field. because, it begins before "c"
in my SDP.
public SessionDescriptor(String sdp) {
SdpParser par = new SdpParser(sdp);
// parse mandatory fields
v = par.parseSdpField('v');
if (v == null)
v = new SdpField('v', "0");
o = par.parseOriginField();
if (o == null)
o = new OriginField("unknown");
s = par.parseSessionNameField();
if (s == null)
s = new SessionNameField();
c = par.parseConnectionField();
if (c == null)
c = new ConnectionField("IP4", "0.0.0.0");
t = par.parseTimeField();
if (t == null)
t = new TimeField();
while (par.hasMore()
&& (!par.startsWith("a=") && !par.startsWith("m="))) { // skip
// unknown
// lines..
par.goToNextLine();
}
// parse session attributes
av = new Vector<AttributeField>();
while (par.hasMore() && par.startsWith("a=")) {
AttributeField attribute = par.parseAttributeField();
av.addElement(attribute);
}
// parse media descriptors
media = new Vector<MediaDescriptor>();
MediaDescriptor md;
while ((md = par.parseMediaDescriptor()) != null) {
addMediaDescriptor(md);
}
}
1.2 MY CURRENT SOLUTION FOR THE FIRST PROBLEM
The order of SIP's fields can be change, so I need to use a switch to
handle it.
And also, when switch comes to 'm', I have needed to change
SdpParser.java's line 214 , and cancel this line "index = end;"...
Altered version of the method:
public SessionDescriptor(String sdp) {
SdpParser par = new SdpParser(sdp);
// parse mandatory fields
while(par.charAt(0)!='a'){
char charSwitch= par.getRemainingString().charAt(0);
switch(charSwitch){
case 'v':{
v = par.parseSdpField('v');
if (v == null)
v = new SdpField('v', "0");
break;
}
case 'o':{
o = par.parseOriginField();
if (o == null)
o = new OriginField("unknown");
break;
}
case 's':{
s = par.parseSessionNameField();
if (s == null)
s = new SessionNameField();
break;
}
case 't':{
t = par.parseTimeField();
if (t == null)
t = new TimeField();
break;
}
case 'c':{
c = par.parseConnectionField();
if (c == null)
c = new ConnectionField("IP4", "0.0.0.0");
break;
}
case 'm':{
// parse media descriptors
media = new Vector<MediaDescriptor>();
MediaDescriptor md;
while ((md = par.parseMediaDescriptor()) != null) {
addMediaDescriptor(md);
}
}
}
}
while (par.hasMore()
&& (!par.startsWith("a=") && !par.startsWith("m="))) { // skip
// unknown
// lines..
par.goToNextLine();
}
// parse session attributes
av = new Vector<AttributeField>();
while (par.hasMore() && par.startsWith("a=")) {
AttributeField attribute = par.parseAttributeField();
av.addElement(attribute);
}
}
2.SECOND PROBLEM
2.2 DEFINITION OF THE 2. PROBLEM
"I can send my voice to mobile phone, but can not receive."
After solving the first problem ; I can parse the SDP right, and my
LOCAL-REMOT SDP outputs:
LOCAL:
v=0
o=3686278856 0 0 IN IP4 10.0.0.27
s=Session SIP/SDP
c=IN IP4 10.0.0.27
t=0 0
a=rtpmap:8 PCMA/8000/1
a=rtpmap:18 G729/8000/1
a=fmtp:18 annexb=no
a=rtpmap:0 PCMU/8000/1
a=rtpmap:111 ILBC/8000/1
a=fmtp:111 mode=30
a=ptime:20
m=audio 3001 RTP/AVP 8 18 0 111
a=rtpmap:8 PCMA/8000/1
a=rtpmap:18 G729/8000/1
a=fmtp:18 annexb=no
a=rtpmap:0 PCMU/8000/1
a=rtpmap:111 ILBC/8000/1
a=fmtp:111 mode=30
a=ptime:20
SIP SERVER:
v=0
o=- 150969000 1806128112579501 IN IP4 217.65.176.110
s=Dialogic_SIP_CCLIB
c=IN IP4 217.65.176.110
t=0 0
a=rtpmap:8 PCMA/8000/1
a=ptime:20
a=sendrecv
m=audio 21104 RTP/AVP 8
c=IN IP4 217.65.176.110
a=rtpmap:8 PCMA/8000/1
a=ptime:20
a=sendrecv
new SDP:
v=0
o=- 150969000 1806128112579501 IN IP4 217.65.176.110
s=Dialogic_SIP_CCLIB
c=IN IP4 10.0.0.27
t=0 0
m=audio 3001 RTP/AVP 8
a=rtpmap:8 PCMA/8000/1
Kind Regards,
Murat Döner
from TURAN
Original issue reported on code.google.com by kuru...@gmail.com on 13 Apr 2010 at 12:08
Original issue reported on code.google.com by
kuru...@gmail.com
on 13 Apr 2010 at 12:08