[Live-devel] RTSP MediaSession.cpp patch for RTP/RTCP for multicast

Robert Krakora rob.krakora at gmail.com
Thu Jan 14 10:10:14 PST 2010


Hello,

I am using VLC 0.9.10 with live555 snapshot live.2010.01.13.tar.gz to
receive and decode multicast content from an Axis 213 PTZ camera (version
4.35.1 firmware).  However, I kept getting the following error about 60% of
the time when trying to invoke it from the command line:

[root at mediaport102 ~]# export DISPLAY=:0.0; vlc -vvvvv --noosd --fullscreen
--m4v-fps 30 --rtsp-mcast -I rc --no-audio rtsp://
dcampbell:msdvideo at 172.19.3.223:554/mpeg4/media.amp
VLC media player 0.9.10 Grishenko
[00000001] main libvlc debug: VLC media player - version 0.9.10 Grishenko -
(c) 1996-2009 the VideoLAN team
[00000001] main libvlc debug: libvlc was configured with ../configure
'--prefix=/usr' '--libdir=/usr/lib64' '--with-live555-tree=/usr/lib64/live'
'--enable-run-as-root' '--enable-debug' 'LDFLAGS=-L/usr/lib64'
LibVLC has detected an unusable buggy GNU/libc version.
Please update to version 2.8 or newer.
[00000001] main libvlc debug: translation test: code is "C"
[00000001] main libvlc debug: checking builtin modules
[00000001] main libvlc debug: checking plugin modules
[00000001] main libvlc debug: loading plugins cache file
/root/.cache/vlc/plugins-04081e.dat
[00000001] main libvlc debug: recursively browsing `/usr/lib64/vlc'
[00000001] main libvlc debug: module bank initialized, found 259 modules
[00000001] main libvlc warning: Unable to get HAL device properties
[00000001] main libvlc debug: opening config file (/root/.config/vlc/vlcrc)
[00000001] main libvlc debug: CPU has capabilities 486 586 MMX 3DNow! MMXEXT
SSE SSE2 FPU
[00000001] main libvlc debug: looking for memcpy module: 4 candidates
[00000001] main libvlc debug: using memcpy module "memcpymmxext"
[00000686] main interaction debug: thread 1098783040 (Interaction control)
created at priority 0 (../../src/interface/interaction.c:382)
[00000686] main interaction debug: thread started
[00000688] main input debug: Creating an input for 'Media Library'
[00000688] main input debug: Input is a meta file: disabling unneeded
options
[00000688] main input debug:
`file/xspf-open:///root/.local/share/vlc/ml.xspf' gives access `file' demux
`xspf-open' path `/root/.local/share/vlc/ml.xspf'
[00000688] main input debug: creating access 'file'
path='/root/.local/share/vlc/ml.xspf'
[00000689] main access debug: looking for access module: 3 candidates
[00000689] access_file access debug: opening file
`/root/.local/share/vlc/ml.xspf'
[00000689] main access debug: using access module "access_file"
[00000689] main access debug: TIMER module_Need() : 0.467 ms - Total 0.467
ms / 1 intvls (Avg 0.467 ms)
[00000690] main stream debug: Using AStream*Stream
[00000690] main stream debug: pre-buffering...
[00000690] main stream debug: received first data for our buffer
[00000688] main input debug: creating demux: access='file' demux='xspf-open'
path='/root/.local/share/vlc/ml.xspf'
[00000691] main demux debug: looking for demux module: 1 candidate
[00000691] playlist demux debug: using XSPF playlist reader
[00000691] main demux debug: using demux module "playlist"
[00000691] main demux debug: TIMER module_Need() : 1.042 ms - Total 1.042 ms
/ 1 intvls (Avg 1.042 ms)
[00000688] main input debug:
`file/xspf-open:///root/.local/share/vlc/ml.xspf' successfully opened
[00000692] main xml debug: looking for xml module: 2 candidates
[00000692] main xml debug: using xml module "xml"
[00000692] main xml debug: TIMER module_Need() : 0.855 ms - Total 0.855 ms /
1 intvls (Avg 0.855 ms)
[00000691] playlist demux debug: parsed 0 tracks successfully
[00000692] main xml debug: removing module "xml"
[00000688] main input debug: EOF reached
[00000688] main input debug: control type=1
[00000691] main demux debug: removing module "playlist"
[00000689] main access debug: removing module "access_file"
[00000688] main input debug: Destroying the input for 'Media Library'
[00000688] main input debug: TIMER input launching for 'Media Library' :
11.250 ms - Total 11.250 ms / 1 intvls (Avg 11.250 ms)
[00000693] main preparser debug: waiting for thread initialization
[00000693] main preparser debug: thread started
[00000693] main preparser debug: thread 1085921600 (preparser) created at
priority 0 (../../src/playlist/thread.c:79)
[00000694] main fetcher debug: waiting for thread initialization
[00000694] main fetcher debug: thread started
[00000694] main fetcher debug: thread 1109272896 (fetcher) created at
priority 0 (../../src/playlist/thread.c:108)
[00000687] main playlist debug: waiting for thread initialization
[00000687] main playlist debug: thread started
[00000687] main playlist debug: thread 1119762752 (playlist) created at
priority 0 (../../src/playlist/thread.c:117)
[00000695] main interface debug: looking for interface module: 1 candidate
[00000687] main playlist debug: rebuilding array of current - root Playlist
[00000687] main playlist debug: rebuild done - 0 items, index -1
[00000695] main interface debug: using interface module "hotkeys"
[00000695] main interface debug: TIMER module_Need() : 0.772 ms - Total
0.772 ms / 1 intvls (Avg 0.772 ms)
[00000695] main interface debug: thread 1130252608 (interface) created at
priority 0 (../../src/interface/interface.c:168)
[00000696] main interface debug: looking for interface module: 1 candidate
[00000695] main interface debug: thread started
[00000696] main interface debug: using interface module "inhibit"
[00000696] main interface debug: TIMER module_Need() : 112.259 ms - Total
112.259 ms / 1 intvls (Avg 112.259 ms)
[00000696] main interface debug: thread 1140742464 (interface) created at
priority 0 (../../src/interface/interface.c:168)
[00000697] main interface debug: looking for interface module: 1 candidate
[00000697] main interface debug: using interface module "screensaver"
[00000697] main interface debug: TIMER module_Need() : 0.116 ms - Total
0.116 ms / 1 intvls (Avg 0.116 ms)
[00000697] main interface debug: thread 1151232320 (interface) created at
priority 0 (../../src/interface/interface.c:168)
[00000687] main playlist debug: adding item `rtsp://
dcampbell:msdvideo at 172.19.3.223:554/mpeg4/media.amp' ( rtsp://
dcampbell:msdvideo at 172.19.3.223:554/mpeg4/media.amp )
[00000698] main interface debug: looking for interface module: 18 candidates
[00000698] main interface debug: using interface module "signals"
[00000698] main interface debug: TIMER module_Need() : 0.095 ms - Total
0.095 ms / 1 intvls (Avg 0.095 ms)
[00000698] main interface debug: thread 1172212032 (interface) created at
priority 0 (../../src/interface/interface.c:168)
[00000699] main interface debug: looking for interface module: 18 candidates
Remote control interface initialized. Type `help' for help.
[00000699] main interface debug: using interface module "rc"
[00000699] main interface debug: TIMER module_Need() : 0.296 ms - Total
0.296 ms / 1 intvls (Avg 0.296 ms)
[00000696] main interface debug: thread started
[00000687] main playlist debug: rebuilding array of current - root Playlist
[00000687] main playlist debug: rebuild done - 1 items, index -1
[00000697] main interface debug: thread started
[00000698] main interface debug: thread started
[00000699] main interface debug: thread 1182701888 (interface) created at
priority 0 (../../src/interface/interface.c:168)
[00000687] main playlist debug: starting new item
[00000687] main playlist debug: processing request item null node Playlist
skip 0
[00000687] main playlist debug: creating new input thread
[00000700] main input debug: Creating an input for 'rtsp://
dcampbell:msdvideo at 172.19.3.223:554/mpeg4/media.amp'
[00000699] main interface debug: thread started
[00000700] main input debug: thread started
[00000700] main input debug: waiting for thread initialization
[00000700] main input debug: `rtsp://
dcampbell:msdvideo at 172.19.3.223:554/mpeg4/media.amp' gives access `rtsp'
demux `' path `dcampbell:msdvideo at 172.19.3.223:554/mpeg4/media.amp'
[00000700] main input debug: creating demux: access='rtsp' demux='' path='
dcampbell:msdvideo at 172.19.3.223:554/mpeg4/media.amp'
[00000701] main demux debug: looking for access_demux module: 1 candidate
[00000700] main input debug: thread 1193191744 (input) created at priority
10 (../../src/input/input.c:370)
Sending request: OPTIONS rtsp://172.19.3.223:554/mpeg4/media.amp RTSP/1.0
CSeq: 1
User-Agent: VLC media player (LIVE555 Streaming Media v2009.07.27)


Received OPTIONS response: RTSP/1.0 200 OK
CSeq: 1
Public: DESCRIBE, GET_PARAMETER, PAUSE, PLAY, SETUP, SET_PARAMETER, TEARDOWN


Sending request: DESCRIBE rtsp://172.19.3.223:554/mpeg4/media.amp RTSP/1.0
CSeq: 2
Accept: application/sdp
User-Agent: VLC media player (LIVE555 Streaming Media v2009.07.27)


Received DESCRIBE response: RTSP/1.0 401 Unauthorized
CSeq: 2
WWW-Authenticate: Basic realm="/"


Sending request: DESCRIBE rtsp://172.19.3.223:554/mpeg4/media.amp RTSP/1.0
CSeq: 3
Accept: application/sdp
Authorization: Basic ZGNhbXBiZWxsOm1zZHZpZGVv
User-Agent: VLC media player (LIVE555 Streaming Media v2009.07.27)


Received DESCRIBE response: RTSP/1.0 200 OK
CSeq: 3
Content-Base: rtsp://172.19.3.223:554/mpeg4/media.amp/
Content-Type: application/sdp
Content-Length: 696


Need to read 696 extra bytes
Read 696 extra bytes: v=0
o=- 18951009734492 18951009734498 IN IP4 172.19.3.223
s=Media Presentation
e=NONE
c=IN IP4 0.0.0.0
b=AS:8000
t=0 0
a=control:*
a=range:npt=now-
a=mpeg4-iod:
"data:application/mpeg4-iod;base64,AoDUAE8BAf/1AQOAbwABQFBkYXRhOmFwcGxpY2F0aW9uL21wZWc0LW9kLWF1O2Jhc2U2NCxBUjBCR3dVZkF4Y0F5U1FBWlFRTklCRUVrK0FBZWhJQUFIb1NBQVlCQkE9PQQNAQUABAAAAAAAAAAAAAYJAQAAAAAAAAAAAzoAAkA2ZGF0YTphcHBsaWNhdGlvbi9tcGVnNC1iaWZzLWF1O2Jhc2U2NCx3QkFTWVFTSVVFVUZQd0E9BBICDQAAAgAAAAAAAAAABQMAAEAGCQEAAAAAAAAAAA=="
m=video 0 RTP/AVP 96
b=AS:8000
a=framerate:30
a=control:trackID=1
a=rtpmap:96 MP4V-ES/90000
a=fmtp:96 profile-level-id=245;
config=000001B0F5000001B509000001000000012008D49D88032516043C14440F;
a=mpeg4-esid:201

[00000701] live555 demux debug: RTP subsession 'video/MP4V-ES'
Sending request: SETUP rtsp://172.19.3.223:554/mpeg4/media.amp/trackID=1RTSP/1.0
CSeq: 4
Transport: RTP/AVP;multicast;client_port=36916-36917
Authorization: Basic ZGNhbXBiZWxsOm1zZHZpZGVv
User-Agent: VLC media player (LIVE555 Streaming Media v2009.07.27)


Received SETUP response: RTSP/1.0 200 OK
CSeq: 4
Session: 1886570945;timeout=60
Transport:
RTP/AVP;multicast;destination=239.209.84.157;ttl=5;port=50000-50001;mode="PLAY"


[00000700] main input debug: selecting program id=0
[00000701] live555 demux debug: setup start: 0 stop:0
Sending request: PLAY rtsp://172.19.3.223:554/mpeg4/media.amp/ RTSP/1.0
CSeq: 5
Session: 1886570945
Range: npt=0.000-
Authorization: Basic ZGNhbXBiZWxsOm1zZHZpZGVv
User-Agent: VLC media player (LIVE555 Streaming Media v2009.07.27)


Received PLAY response: RTSP/1.0 200 OK
CSeq: 5
Session: 1886570945
Range: npt=now-
RTP-Info: url=trackID=1;seq=7996;rtptime=3557386590


[00000701] live555 demux debug: We have a timeout of 60 seconds
[00000702] main generic debug: waiting for thread initialization
[00000702] main generic debug: thread started
[00000702] main generic debug: thread 1203681600 (liveMedia-timeout) created
at priority 0 (../../../modules/demux/live555.cpp:1055)
[00000701] live555 demux debug: spawned timeout thread
[00000701] live555 demux debug: play start: 0 stop:0
[00000701] main demux debug: using access_demux module "live555"
[00000701] main demux debug: TIMER module_Need() : 89.912 ms - Total 89.912
ms / 1 intvls (Avg 89.912 ms)
[00000703] main decoder debug: looking for decoder module: 26 candidates
[00000703] avcodec decoder debug: libavcodec initialized (interface 3412992
)
[00000703] avcodec decoder debug: using direct rendering
[00000703] avcodec decoder debug: ffmpeg codec (MPEG-4 Video) started
[00000703] main decoder debug: using decoder module "avcodec"
[00000703] main decoder debug: TIMER module_Need() : 14.274 ms - Total
14.274 ms / 1 intvls (Avg 14.274 ms)
[00000703] main decoder debug: thread 1214171456 (decoder) created at
priority 0 (../../src/input/decoder.c:217)
[00000700] main input debug: `rtsp://
dcampbell:msdvideo at 172.19.3.223:554/mpeg4/media.amp' successfully opened
BasicTaskScheduler::SingleStep(): select() fails: Bad file descriptor
[00000703] main decoder debug: thread started

By turning on debugging I was able to ascertain that the problem was that
the fd_set socket handle mask for the 'select()' call was not getting
updated when RTP and RTCP sockets were closed and reopened with different
file descriptor values because of a multicast address/port changed flagged
by the RTSP stack.  Below is the diff between the 'stock' file and modified
file and attached is an attempted patch.  The patch does work, but there may
or may not be some other pitfalls that are not readily apparent to me.

[root at devkrakora live-latest]# diff -uN live/liveMedia/MediaSession.cpp
live.modified/liveMedia/MediaSession.cpp
--- live/liveMedia/MediaSession.cpp     2010-01-13 02:19:35.000000000 -0500
+++ live.modified/liveMedia/MediaSession.cpp    2010-01-14
20:44:35.000000000 -0500
@@ -976,21 +976,38 @@
   netAddressBits destAddress = connectionEndpointAddress();
   if (destAddress == 0) destAddress = defaultDestAddress;
   struct in_addr destAddr; destAddr.s_addr = destAddress;
-
+
   // The destination TTL remains unchanged:
   int destTTL = ~0; // means: don't change

   if (fRTPSocket != NULL) {
+    fRTPSource->stopGettingFrames();
     Port destPort(serverPortNum);
     fRTPSocket->changeDestinationParameters(destAddr, destPort, destTTL);
   }
   if (fRTCPSocket != NULL && !isSSM()) {
     // Note: For SSM sessions, the dest address for RTCP was already set.
+    if (fRTCPInstance != NULL) {
+      Medium::close(fRTCPInstance); fRTCPInstance = NULL;
+    }
     Port destPort(serverPortNum+1);
-    fRTCPSocket->
+    fRTCPSocket->
       changeDestinationParameters(destAddr, destPort, destTTL);
-  }
-}
+    // Finally, create our RTCP instance. (It starts running automatically)
+    if (fRTPSource != NULL) {
+      unsigned totSessionBandwidth = 500; // HACK - later get from SDP#####
+      fRTCPInstance = RTCPInstance::createNew(env(), fRTCPSocket,
+                                              totSessionBandwidth,
+                                              (unsigned char const*)
+                                              fParent.CNAME(),
+                                              NULL /* we're a client */,
+                                              fRTPSource);
+      if (fRTCPInstance == NULL) {
+        env().setResultMsg("Failed to create RTCP instance");
+      }
+    }
+  }
+}

 double MediaSubsession::getNormalPlayTime(struct timeval const&
presentationTime) {
   // First, check whether our "RTPSource" object has already been
synchronized using RTCP.
[root at devkrakora live-latest]#




-- 
Rob Krakora
Senior Software Engineer
MessageNet Systems
101 East Carmel Dr. Suite 105
Carmel, IN 46032
(317)566-1677 Ext. 206
(317)663-0808 Fax
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.live555.com/pipermail/live-devel/attachments/20100114/2ed4c3d9/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: patch.MediaSession.cpp
Type: application/octet-stream
Size: 1892 bytes
Desc: not available
URL: <http://lists.live555.com/pipermail/live-devel/attachments/20100114/2ed4c3d9/attachment-0001.obj>


More information about the live-devel mailing list