[Live-devel] SIP & RTCP

NADEAU Frederic -EXT frederic.nadeau at transport.alstom.com
Mon Oct 29 07:12:56 PDT 2012


Hi,
There is a problem in the SIP implementation. RTCP report are not send to the proper address.

Test were performed with live555-2012-10-24 with the following mod :
--- live/groupsock/Groupsock.cpp        2012-10-24 09:07:18.000000000 -0400
+++ live-20121024-mod-siprtcp/groupsock/Groupsock.cpp   2012-10-29 08:40:44.000000000 -0400
@@ -276,7 +276,11 @@ Boolean Groupsock::output(UsageEnvironme

     if (DebugLevel >= 3) {
       env << *this << ": wrote " << bufferSize << " bytes, ttl "
-         << (unsigned)ttlToSend;
+         << (unsigned)ttlToSend << " to ";
+      for (destRecord* dests = fDests; dests != NULL; dests = dests->fNext) {
+        env << AddressString(dests->fGroupEId.groupAddress()).val() << ", "
+            << dests->fPort << ", ";
+      }
       if (numMembers > 0) {
        env << "; relayed to " << numMembers << " members";
       }

This allow better debugging. Also, DebugLevel was set to 3 in NetInterface.cpp.

The issue is that the SIP client sent RTCP report to its own address. You'll find below:
 - output of unchanged(except above changes)
 - output of patched version
 - patch

Configuration setup:
 - PC with Live555: 10.32.9.41
 - PC with FreeSwich: 10.32.250.4 configure to answer any calls with music-on-hold

You will notice that in playSIP-original, when a RTCP report is written, it is read back immediately.
For better readability, some lines were redacted.

Patch keeps track of the SDP sent by remote party(previously discarded) and modification to playSIP read
back this information to properly setup RTCP report.

Also, the item Max-Forwards has been added to SIP message as required by RFC3261 section 8.1.1. See patch.

Bonus question: any better way to provide Live555 dev team with big text file?(attachment, pastbin, etc)

*****************************************************************************************
/tmp # ./playSIP-original sip:toto at 10.32.250.4
14:24:13 Groupsock(3: 10.32.9.41, 0, 255): created
Sending request: INVITE sip:toto at 10.32.250.4 SIP/2.0
From: toto <sip:toto at 10.32.9.41>;tag=83369963
Via: SIP/2.0/UDP 10.32.9.41:32818
To: sip:toto at 10.32.250.4
Contact: sip:toto at 10.32.9.41:32818
Call-ID: 1955131746 at 10.32.9.41
CSeq: 1 INVITE
Content-Type: application/sdp
User-Agent: playSIP-original (LIVE555 Streaming Media v2012.10.24)
Content-Length: 121

v=0
o=- 1955131746 0 IN IP4 10.32.9.41
s=playSIP-original session
c=IN IP4 10.32.9.41
t=0 0
m=audio 8000 RTP/AVP 0

14:24:13 Groupsock(3: 10.32.9.41, 0, 255): wrote 472 bytes, ttl 255 to 10.32.250.4, 5060,
14:24:13 Groupsock(3: 10.32.9.41, 0, 255): read 275 bytes from 10.32.250.4
Received INVITE response: SIP/2.0 100 Trying
Via: SIP/2.0/UDP 10.32.9.41:32818
From: toto <sip:toto at 10.32.9.41>;tag=83369963
To: <sip:toto at 10.32.250.4>
Call-ID: 1955131746 at 10.32.9.41
CSeq: 1 INVITE
User-Agent: FreeSWITCH-mod_sofia/1.2.0-rc2+git~20120730T235848Z~3b5b59e693
Content-Length: 0


14:24:13 Groupsock(3: 10.32.9.41, 0, 255): read 1013 bytes from 10.32.250.4
Received INVITE response: SIP/2.0 200 OK
Via: SIP/2.0/UDP 10.32.9.41:32818
From: toto <sip:toto at 10.32.9.41>;tag=83369963
To: <sip:toto at 10.32.250.4>;tag=34rSN3mvS765D
Call-ID: 1955131746 at 10.32.9.41
CSeq: 1 INVITE
Contact: <sip:toto at 10.32.250.4:5060;transport=udp>
User-Agent: FreeSWITCH-mod_sofia/1.2.0-rc2+git~20120730T235848Z~3b5b59e693
Accept: application/sdp
Allow: INVITE, ACK, BYE, CANCEL, OPTIONS, MESSAGE, UPDATE, INFO, REGISTER, REFER, NOTIFY, PUBLISH, SUBSCRIBE
Supported: timer, precondition, path, replaces
Allow-Events: talk, hold, conference, presence, dialog, line-seize, call-info, sla, include-session-description, presence.winfo, message-summary, refer
Content-Type: application/sdp
Content-Disposition: session
Content-Length: 189
Remote-Party-ID: "toto" <sip:toto at 10.32.250.4>;party=calling;privacy=off;screen=no

v=0
o=FreeSWITCH 1351487890 1351487891 IN IP4 10.32.250.4
s=FreeSWITCH
c=IN IP4 10.32.250.4
t=0 0
m=audio 29358 RTP/AVP 0
a=rtpmap:0 PCMU/8000
a=silenceSupp:off - - - -
a=ptime:20

Opened URL "sip:toto at 10.32.250.4", returning a SDP description:
v=0
o=- 1955131746 0 IN IP4 10.32.9.41
s=playSIP-original session
c=IN IP4 10.32.9.41
t=0 0
m=audio 8000 RTP/AVP 0

14:24:13 Groupsock(4: 10.32.9.41, 8000, 255): created
14:24:13 Groupsock(5: 10.32.9.41, 8001, 255): created
Created receiver for "audio/PCMU" subsession (client ports 8000-8001)
Setup "audio/PCMU" subsession (client ports 8000-8001)
Created output file: "audio-PCMU-1"
Sending request: ACK sip:toto at 10.32.250.4 SIP/2.0
From: toto <sip:toto at 10.32.9.41>;tag=83369963
Via: SIP/2.0/UDP 10.32.9.41:32818
To: sip:toto at 10.32.250.4;tag=34rSN3mvS765D
Call-ID: 1955131746 at 10.32.9.41
CSeq: 1 ACK
Content-Length: 0


14:24:13 Groupsock(3: 10.32.9.41, 0, 255): wrote 226 bytes, ttl 255 to 10.32.250.4, 5060,
Started playing session
Receiving streamed data (signal with "kill -HUP 7488" or "kill -USR1 7488" to terminate)...
14:24:13 Groupsock(4: 10.32.9.41, 8000, 255): read 172 bytes from 10.32.250.4
...
14:24:15 Groupsock(4: 10.32.9.41, 8000, 255): read 172 bytes from 10.32.250.4
14:24:15 Groupsock(5: 10.32.9.41, 8001, 255): wrote 48 bytes, ttl 255 to 10.32.9.41, 8001,
14:24:15 Groupsock(5: 10.32.9.41, 8001, 255): read 48 bytes from 10.32.9.41
14:24:15 Groupsock(4: 10.32.9.41, 8000, 255): read 172 bytes from 10.32.250.4
...
14:24:18 Groupsock(4: 10.32.9.41, 8000, 255): read 172 bytes from 10.32.250.4
14:24:18 Groupsock(5: 10.32.9.41, 8001, 255): read 78 bytes from 10.32.250.4
14:24:18 Groupsock(4: 10.32.9.41, 8000, 255): read 172 bytes from 10.32.250.4
...
14:24:21 Groupsock(4: 10.32.9.41, 8000, 255): read 172 bytes from 10.32.250.4
14:24:21 Groupsock(5: 10.32.9.41, 8001, 255): wrote 48 bytes, ttl 255 to 10.32.9.41, 8001,
14:24:21 Groupsock(5: 10.32.9.41, 8001, 255): read 48 bytes from 10.32.9.41
14:24:21 Groupsock(4: 10.32.9.41, 8000, 255): read 172 bytes from 10.32.250.4
...
14:24:23 Groupsock(4: 10.32.9.41, 8000, 255): read 172 bytes from 10.32.250.4
14:24:23 Groupsock(5: 10.32.9.41, 8001, 255): read 78 bytes from 10.32.250.4
14:24:23 Groupsock(4: 10.32.9.41, 8000, 255): read 172 bytes from 10.32.250.4
...
14:24:27 Groupsock(4: 10.32.9.41, 8000, 255): read 172 bytes from 10.32.250.4
14:24:27 Groupsock(5: 10.32.9.41, 8001, 255): wrote 48 bytes, ttl 255 to 10.32.9.41, 8001,
14:24:27 Groupsock(5: 10.32.9.41, 8001, 255): read 48 bytes from 10.32.9.41
14:24:27 Groupsock(4: 10.32.9.41, 8000, 255): read 172 bytes from 10.32.250.4
...
14:24:28 Groupsock(4: 10.32.9.41, 8000, 255): read 172 bytes from 10.32.250.4
14:24:28 Groupsock(5: 10.32.9.41, 8001, 255): read 78 bytes from 10.32.250.4
14:24:28 Groupsock(4: 10.32.9.41, 8000, 255): read 172 bytes from 10.32.250.4
...
14:24:32 Groupsock(4: 10.32.9.41, 8000, 255): read 172 bytes from 10.32.250.4
14:24:32 Groupsock(5: 10.32.9.41, 8001, 255): wrote 48 bytes, ttl 255 to 10.32.9.41, 8001,
14:24:32 Groupsock(5: 10.32.9.41, 8001, 255): read 48 bytes from 10.32.9.41
14:24:32 Groupsock(4: 10.32.9.41, 8000, 255): read 172 bytes from 10.32.250.4
...
14:24:33 Groupsock(4: 10.32.9.41, 8000, 255): read 172 bytes from 10.32.250.4
14:24:33 Groupsock(5: 10.32.9.41, 8001, 255): read 78 bytes from 10.32.250.4
14:24:33 Groupsock(4: 10.32.9.41, 8000, 255): read 172 bytes from 10.32.250.4
...
14:24:37 Groupsock(4: 10.32.9.41, 8000, 255): read 172 bytes from 10.32.250.4
14:24:37 Groupsock(5: 10.32.9.41, 8001, 255): wrote 48 bytes, ttl 255 to 10.32.9.41, 8001,
14:24:37 Groupsock(5: 10.32.9.41, 8001, 255): read 48 bytes from 10.32.9.41
14:24:37 Groupsock(4: 10.32.9.41, 8000, 255): read 172 bytes from 10.32.250.4
...
14:24:38 Groupsock(4: 10.32.9.41, 8000, 255): read 172 bytes from 10.32.250.4
14:24:38 Groupsock(5: 10.32.9.41, 8001, 255): read 78 bytes from 10.32.250.4
14:24:38 Groupsock(4: 10.32.9.41, 8000, 255): read 172 bytes from 10.32.250.4
...
14:24:43 Groupsock(4: 10.32.9.41, 8000, 255): read 172 bytes from 10.32.250.4
14:24:43 Groupsock(5: 10.32.9.41, 8001, 255): wrote 48 bytes, ttl 255 to 10.32.9.41, 8001,
14:24:43 Groupsock(5: 10.32.9.41, 8001, 255): read 48 bytes from 10.32.9.41
14:24:43 Groupsock(4: 10.32.9.41, 8000, 255): read 172 bytes from 10.32.250.4
...
14:24:43 Groupsock(4: 10.32.9.41, 8000, 255): read 172 bytes from 10.32.250.4
14:24:43 Groupsock(5: 10.32.9.41, 8001, 255): read 78 bytes from 10.32.250.4
14:24:43 Groupsock(4: 10.32.9.41, 8000, 255): read 172 bytes from 10.32.250.4
...
14:24:47 Groupsock(4: 10.32.9.41, 8000, 255): read 172 bytes from 10.32.250.4
14:24:47 Groupsock(5: 10.32.9.41, 8001, 255): wrote 48 bytes, ttl 255 to 10.32.9.41, 8001,
14:24:47 Groupsock(5: 10.32.9.41, 8001, 255): read 48 bytes from 10.32.9.41
14:24:47 Groupsock(4: 10.32.9.41, 8000, 255): read 172 bytes from 10.32.250.4
...
14:24:48 Groupsock(4: 10.32.9.41, 8000, 255): read 172 bytes from 10.32.250.4
14:24:48 Groupsock(5: 10.32.9.41, 8001, 255): read 78 bytes from 10.32.250.4
14:24:48 Groupsock(4: 10.32.9.41, 8000, 255): read 172 bytes from 10.32.250.4
...
14:24:52 Groupsock(4: 10.32.9.41, 8000, 255): read 172 bytes from 10.32.250.4
14:24:52 Groupsock(5: 10.32.9.41, 8001, 255): wrote 48 bytes, ttl 255 to 10.32.9.41, 8001,
14:24:52 Groupsock(5: 10.32.9.41, 8001, 255): read 48 bytes from 10.32.9.41
14:24:52 Groupsock(4: 10.32.9.41, 8000, 255): read 172 bytes from 10.32.250.4
...
14:24:53 Groupsock(4: 10.32.9.41, 8000, 255): read 172 bytes from 10.32.250.4
14:24:53 Groupsock(5: 10.32.9.41, 8001, 255): read 78 bytes from 10.32.250.4
14:24:53 Groupsock(4: 10.32.9.41, 8000, 255): read 172 bytes from 10.32.250.4
...
14:24:56 Groupsock(4: 10.32.9.41, 8000, 255): read 172 bytes from 10.32.250.4
Got shutdown signal
Sending request: BYE sip:toto at 10.32.250.4 SIP/2.0
From: toto <sip:toto at 10.32.9.41>;tag=83369963
Via: SIP/2.0/UDP 10.32.9.41:32818
To: sip:toto at 10.32.250.4;tag=34rSN3mvS765D
Call-ID: 1955131746 at 10.32.9.41
CSeq: 2 BYE
Content-Length: 0


14:24:56 Groupsock(3: 10.32.9.41, 0, 255): wrote 226 bytes, ttl 255 to 10.32.250.4, 5060,
14:24:56 Groupsock(5: 10.32.9.41, 8001, 255): wrote 40 bytes, ttl 255 to 10.32.9.41, 8001,
14:24:56 Groupsock(5: 10.32.9.41, 8001, 255): deleting
14:24:56 Groupsock(4: 10.32.9.41, 8000, 255): deleting
14:24:56 Groupsock(3: 10.32.9.41, 0, 255): deleting
*****************************************************************************************
/tmp # ./playSIP-mod  sip:toto at 10.32.250.4
14:27:49 Groupsock(3: 10.32.9.41, 0, 255): created
Sending request: INVITE sip:toto at 10.32.250.4 SIP/2.0
From: toto <sip:toto at 10.32.9.41>;tag=798552056
Via: SIP/2.0/UDP 10.32.9.41:32818
Max-Forwards: 70
To: sip:toto at 10.32.250.4
Contact: sip:toto at 10.32.9.41:32818
Call-ID: 212035618 at 10.32.9.41
CSeq: 1 INVITE
Content-Type: application/sdp
User-Agent: playSIP-mod (LIVE555 Streaming Media v2012.10.24)
Content-Length: 115

v=0
o=- 212035618 0 IN IP4 10.32.9.41
s=playSIP-mod session
c=IN IP4 10.32.9.41
t=0 0
m=audio 8000 RTP/AVP 0

14:27:49 Groupsock(3: 10.32.9.41, 0, 255): wrote 479 bytes, ttl 255 to 10.32.250.4, 5060,
14:27:49 Groupsock(3: 10.32.9.41, 0, 255): read 275 bytes from 10.32.250.4
Received INVITE response: SIP/2.0 100 Trying
Via: SIP/2.0/UDP 10.32.9.41:32818
From: toto <sip:toto at 10.32.9.41>;tag=798552056
To: <sip:toto at 10.32.250.4>
Call-ID: 212035618 at 10.32.9.41
CSeq: 1 INVITE
User-Agent: FreeSWITCH-mod_sofia/1.2.0-rc2+git~20120730T235848Z~3b5b59e693
Content-Length: 0


14:27:49 Groupsock(3: 10.32.9.41, 0, 255): read 1013 bytes from 10.32.250.4
Received INVITE response: SIP/2.0 200 OK
Via: SIP/2.0/UDP 10.32.9.41:32818
From: toto <sip:toto at 10.32.9.41>;tag=798552056
To: <sip:toto at 10.32.250.4>;tag=4DjjQy5ZpgXrS
Call-ID: 212035618 at 10.32.9.41
CSeq: 1 INVITE
Contact: <sip:toto at 10.32.250.4:5060;transport=udp>
User-Agent: FreeSWITCH-mod_sofia/1.2.0-rc2+git~20120730T235848Z~3b5b59e693
Accept: application/sdp
Allow: INVITE, ACK, BYE, CANCEL, OPTIONS, MESSAGE, UPDATE, INFO, REGISTER, REFER, NOTIFY, PUBLISH, SUBSCRIBE
Supported: timer, precondition, path, replaces
Allow-Events: talk, hold, conference, presence, dialog, line-seize, call-info, sla, include-session-description, presence.winfo, message-summary, refer
Content-Type: application/sdp
Content-Disposition: session
Content-Length: 189
Remote-Party-ID: "toto" <sip:toto at 10.32.250.4>;party=calling;privacy=off;screen=no

v=0
o=FreeSWITCH 1351488404 1351488405 IN IP4 10.32.250.4
s=FreeSWITCH
c=IN IP4 10.32.250.4
t=0 0
m=audio 29060 RTP/AVP 0
a=rtpmap:0 PCMU/8000
a=silenceSupp:off - - - -
a=ptime:20

Opened URL "sip:toto at 10.32.250.4", returning a SDP description:
v=0
o=- 212035618 0 IN IP4 10.32.9.41
s=playSIP-mod session
c=IN IP4 10.32.9.41
t=0 0
m=audio 8000 RTP/AVP 0

14:27:49 Groupsock(4: 10.32.9.41, 8000, 255): created
14:27:49 Groupsock(5: 10.32.9.41, 8001, 255): created
Created receiver for "audio/PCMU" subsession (client ports 8000-8001)
Setup "audio/PCMU" subsession (client ports 8000-8001)
Created output file: "audio-PCMU-1"
Sending request: ACK sip:toto at 10.32.250.4 SIP/2.0
From: toto <sip:toto at 10.32.9.41>;tag=798552056
Via: SIP/2.0/UDP 10.32.9.41:32818
Max-Forwards: 70
To: sip:toto at 10.32.250.4;tag=4DjjQy5ZpgXrS
Call-ID: 212035618 at 10.32.9.41
CSeq: 1 ACK
Content-Length: 0


14:27:49 Groupsock(3: 10.32.9.41, 0, 255): wrote 244 bytes, ttl 255 to 10.32.250.4, 5060,
Started playing session
Receiving streamed data (signal with "kill -HUP 8081" or "kill -USR1 8081" to terminate)...
14:27:49 Groupsock(4: 10.32.9.41, 8000, 255): read 172 bytes from 10.32.250.4
...
14:27:51 Groupsock(4: 10.32.9.41, 8000, 255): read 172 bytes from 10.32.250.4
14:27:51 Groupsock(5: 10.32.9.41, 8001, 255): wrote 48 bytes, ttl 255 to 10.32.250.4, 29061,
14:27:51 Groupsock(4: 10.32.9.41, 8000, 255): read 172 bytes from 10.32.250.4
...
14:27:54 Groupsock(4: 10.32.9.41, 8000, 255): read 172 bytes from 10.32.250.4
14:27:54 Groupsock(5: 10.32.9.41, 8001, 255): read 78 bytes from 10.32.250.4
14:27:54 Groupsock(4: 10.32.9.41, 8000, 255): read 172 bytes from 10.32.250.4
...
14:27:56 Groupsock(4: 10.32.9.41, 8000, 255): read 172 bytes from 10.32.250.4
14:27:56 Groupsock(5: 10.32.9.41, 8001, 255): wrote 48 bytes, ttl 255 to 10.32.250.4, 29061,
14:27:56 Groupsock(4: 10.32.9.41, 8000, 255): read 172 bytes from 10.32.250.4
...
14:27:59 Groupsock(4: 10.32.9.41, 8000, 255): read 172 bytes from 10.32.250.4
14:27:59 Groupsock(5: 10.32.9.41, 8001, 255): read 78 bytes from 10.32.250.4
14:27:59 Groupsock(4: 10.32.9.41, 8000, 255): read 172 bytes from 10.32.250.4
...
14:28:01 Groupsock(4: 10.32.9.41, 8000, 255): read 172 bytes from 10.32.250.4
14:28:02 Groupsock(5: 10.32.9.41, 8001, 255): wrote 48 bytes, ttl 255 to 10.32.250.4, 29061,
14:28:02 Groupsock(4: 10.32.9.41, 8000, 255): read 172 bytes from 10.32.250.4
...
14:28:04 Groupsock(4: 10.32.9.41, 8000, 255): read 172 bytes from 10.32.250.4
14:28:04 Groupsock(5: 10.32.9.41, 8001, 255): read 78 bytes from 10.32.250.4
14:28:04 Groupsock(4: 10.32.9.41, 8000, 255): read 172 bytes from 10.32.250.4
...
14:28:07 Groupsock(4: 10.32.9.41, 8000, 255): read 172 bytes from 10.32.250.4
Got shutdown signal
Sending request: BYE sip:toto at 10.32.250.4 SIP/2.0
From: toto <sip:toto at 10.32.9.41>;tag=798552056
Via: SIP/2.0/UDP 10.32.9.41:32818
Max-Forwards: 70
To: sip:toto at 10.32.250.4;tag=4DjjQy5ZpgXrS
Call-ID: 212035618 at 10.32.9.41
CSeq: 2 BYE
Content-Length: 0


14:28:07 Groupsock(3: 10.32.9.41, 0, 255): wrote 244 bytes, ttl 255 to 10.32.250.4, 5060,
14:28:07 Groupsock(5: 10.32.9.41, 8001, 255): wrote 40 bytes, ttl 255 to 10.32.250.4, 29061,
14:28:07 Groupsock(5: 10.32.9.41, 8001, 255): deleting
14:28:07 Groupsock(4: 10.32.9.41, 8000, 255): deleting
14:28:07 Groupsock(3: 10.32.9.41, 0, 255): deleting
*****************************************************************************************
diff -rupN live-20121024/liveMedia/include/SIPClient.hh live-20121024-mod-siprtcp/liveMedia/include/SIPClient.hh
--- live-20121024/liveMedia/include/SIPClient.hh        2012-10-24 09:07:18.000000000 -0400
+++ live-20121024-mod-siprtcp/liveMedia/include/SIPClient.hh    2012-10-29 09:51:52.000000000 -0400
@@ -67,6 +67,9 @@ public:
   static Boolean parseSIPURLUsernamePassword(char const* url,
                                             char*& username,
                                             char*& password);
+  char const* getInviteSdpReply() {
+    return fInviteSDPDescriptionReturned;
+  }

 protected:
   virtual ~SIPClient();
@@ -108,34 +111,36 @@ private:
   // Set for all calls:
   unsigned char fDesiredAudioRTPPayloadFormat;
   char* fMIMESubtype;
-      unsigned fMIMESubtypeSize;
+  unsigned fMIMESubtypeSize;
   int fVerbosityLevel;
   unsigned fCSeq; // sequence number, used in consecutive requests
   char const* fApplicationName;
-      unsigned fApplicationNameSize;
+  unsigned fApplicationNameSize;
   char const* fOurAddressStr;
-      unsigned fOurAddressStrSize;
+  unsigned fOurAddressStrSize;
   portNumBits fOurPortNum;
   Groupsock* fOurSocket;
   char* fUserAgentHeaderStr;
-      unsigned fUserAgentHeaderStrSize;
+  unsigned fUserAgentHeaderStrSize;

   // Set for each call:
   char const* fURL;
-      unsigned fURLSize;
+  unsigned fURLSize;
   struct in_addr fServerAddress;
   portNumBits fServerPortNum; // in host order
   portNumBits fClientStartPortNum; // in host order
   unsigned fCallId, fFromTag; // set by us
   char const* fToTagStr; // set by the responder
-      unsigned fToTagStrSize;
+  unsigned fToTagStrSize;
   Authenticator fValidAuthenticator;
   char const* fUserName; // 'user' name used in "From:" & "Contact:" lines
-      unsigned fUserNameSize;
+  unsigned fUserNameSize;

   char* fInviteSDPDescription;
+  char* fInviteSDPDescriptionReturned;
   char* fInviteCmd;
-      unsigned fInviteCmdSize;
+  unsigned fInviteCmdSize;
   Authenticator* fWorkingAuthenticator;
   inviteClientState fInviteClientState;
   char fEventLoopStopFlag;
diff -rupN live-20121024/liveMedia/SIPClient.cpp live-20121024-mod-siprtcp/liveMedia/SIPClient.cpp
--- live-20121024/liveMedia/SIPClient.cpp       2012-10-24 09:07:18.000000000 -0400
+++ live-20121024-mod-siprtcp/liveMedia/SIPClient.cpp   2012-10-29 09:52:05.000000000 -0400
@@ -49,7 +49,8 @@ SIPClient::SIPClient(UsageEnvironment& e
     fCSeq(0), fURL(NULL), fURLSize(0),
     fToTagStr(NULL), fToTagStrSize(0),
     fUserName(NULL), fUserNameSize(0),
-    fInviteSDPDescription(NULL), fInviteCmd(NULL), fInviteCmdSize(0){
+    fInviteSDPDescription(NULL),  fInviteSDPDescriptionReturned(NULL),
+    fInviteCmd(NULL), fInviteCmdSize(0){
   if (mimeSubtype == NULL) mimeSubtype = "";
   fMIMESubtype = strDup(mimeSubtype);
   fMIMESubtypeSize = strlen(fMIMESubtype);
@@ -229,6 +230,7 @@ char* SIPClient::invite1(Authenticator*
       + 5 /* max short len */ + 3 /* max char len */
       + rtpmapLineSize;
     delete[] fInviteSDPDescription;
+    delete[] fInviteSDPDescriptionReturned;
     fInviteSDPDescription = new char[inviteSDPFmtSize];
     sprintf(fInviteSDPDescription, inviteSDPFmt,
            fCallId, fCSeq, fOurAddressStr,
@@ -243,6 +245,7 @@ char* SIPClient::invite1(Authenticator*
       "INVITE %s SIP/2.0\r\n"
       "From: %s <sip:%s@%s>;tag=%u\r\n"
       "Via: SIP/2.0/UDP %s:%u\r\n"
+      "Max-Forwards: 70\r\n"
       "To: %s\r\n"
       "Contact: sip:%s@%s:%u\r\n"
       "Call-ID: %u@%s\r\n"
@@ -432,6 +435,7 @@ void SIPClient::doInviteStateTerminated(
   if (responseCode < 200 || responseCode > 299) {
     // We failed, so return NULL;
     delete[] fInviteSDPDescription; fInviteSDPDescription = NULL;
+    delete[] fInviteSDPDescriptionReturned; fInviteSDPDescriptionReturned = NULL;
   }

   // Unblock the event loop:
@@ -595,6 +599,7 @@ unsigned SIPClient::getResponseCode() {
       }

       bodyStart[contentLength] = '\0'; // trims any extra data
+      fInviteSDPDescriptionReturned = strDup(bodyStart);
     }
   } while (0);

@@ -636,6 +641,7 @@ Boolean SIPClient::sendACK() {
       "ACK %s SIP/2.0\r\n"
       "From: %s <sip:%s@%s>;tag=%u\r\n"
       "Via: SIP/2.0/UDP %s:%u\r\n"
+      "Max-Forwards: 70\r\n"
       "To: %s;tag=%s\r\n"
       "Call-ID: %u@%s\r\n"
       "CSeq: %d ACK\r\n"
@@ -677,6 +683,7 @@ Boolean SIPClient::sendBYE() {
       "BYE %s SIP/2.0\r\n"
       "From: %s <sip:%s@%s>;tag=%u\r\n"
       "Via: SIP/2.0/UDP %s:%u\r\n"
+      "Max-Forwards: 70\r\n"
       "To: %s;tag=%s\r\n"
       "Call-ID: %u@%s\r\n"
       "CSeq: %d BYE\r\n"
diff -rupN live-20121024/testProgs/playSIP.cpp live-20121024-mod-siprtcp/testProgs/playSIP.cpp
--- live-20121024/testProgs/playSIP.cpp 2012-10-24 09:07:18.000000000 -0400
+++ live-20121024-mod-siprtcp/testProgs/playSIP.cpp     2012-10-29 08:40:44.000000000 -0400
@@ -20,6 +20,20 @@ along with this library; if not, write t
 #include "playCommon.hh"
 #include "SIPClient.hh"

+static char* getLine(char* startOfLine) {
+  // returns the start of the next line, or NULL if none
+  for (char* ptr = startOfLine; *ptr != '\0'; ++ptr) {
+    if (*ptr == '\r' || *ptr == '\n') {
+      // We found the end of the line
+      *ptr++ = '\0';
+      if (*ptr == '\n') ++ptr;
+      return ptr;
+    }
+  }
+
+  return NULL;
+}
+
 SIPClient* ourSIPClient = NULL;
 Medium* createClient(UsageEnvironment& env, char const* /*url*/, int verbosityLevel, char const* applicationName) {
   // First, trim any directory prefixes from "applicationName":
@@ -82,6 +96,53 @@ void getSDPDescription(RTSPClient::respo
 void setupSubsession(MediaSubsession* subsession, Boolean /*streamUsingTCP*/, RTSPClient::responseHandler* afterFunc) {
   subsession->setSessionId("mumble"); // anything that's non-NULL will work

+  // Parse the "Transport:" header parameters:
+  // We do not send audio, but we need port for RTCP
+  char* serverAddressStr;
+  portNumBits serverPortNum;
+  unsigned char rtpChannelId, rtcpChannelId;
+
+  rtpChannelId = rtcpChannelId = 0xff;
+  serverPortNum = 0;
+  serverAddressStr = NULL;
+
+  char* sdp = strDup(ourSIPClient->getInviteSdpReply());
+
+  char* lineStart;
+  char* nextLineStart = sdp;
+  while (1) {
+    lineStart = nextLineStart;
+    if (lineStart == NULL) {
+      break;
+    }
+    nextLineStart = getLine(lineStart);
+
+    char* toTagStr = strDupSize(lineStart);
+
+    if (sscanf(lineStart, "m=audio %[^/\r\n]", toTagStr) == 1) {
+      sscanf(toTagStr, "%hu", &serverPortNum);
+    } else if (sscanf(lineStart, "c=IN IP4 %[^/\r\n]", toTagStr) == 1) {
+      serverAddressStr = strDup(toTagStr);
+    }
+    delete[] toTagStr;
+  }
+
+  if(sdp != NULL) {
+        delete[] sdp;
+  }
+
+  delete[] subsession->connectionEndpointName();
+  subsession->connectionEndpointName() = serverAddressStr;
+  subsession->serverPortNum = serverPortNum;
+  subsession->rtpChannelId = rtpChannelId;
+  subsession->rtcpChannelId = rtcpChannelId;
+
+  // Set the RTP and RTCP sockets' destination address and port from the information in the SETUP response (if present):
+  netAddressBits destAddress = subsession->connectionEndpointAddress();
+  if (destAddress != 0) {
+    subsession->setDestinations(destAddress);
+  }
+
   afterFunc(NULL, 0, NULL);
 }

*****************************************************************************************


________________________________
CONFIDENTIALITY : This e-mail and any attachments are confidential and may be privileged. If you are not a named recipient, please notify the sender immediately and do not disclose the contents to another person, use it for any purpose or store or copy the information in any medium.



More information about the live-devel mailing list