[Live-devel] doubt trying to implement a rtsp client
Ross Finlayson
finlayson at live555.com
Wed Jun 9 14:26:41 PDT 2010
>I'm trying to implement a small receiver with live555. What I basically
>do is contacting a RTSP server, browse the subsessions, receive the
>packets of the desired subsession and pass them to a routine that
>process them. I tried following playCommon.cpp , but I'm stuck at a
>point and I don't understand how to finish the program.
>
>What I do is:
>
>* call RTSPClient::createNew to create a client
>* call RTSPClient::describeURL url get a description
>* create a MediaSsesion with MediaSession::createNew and iterate through
>its subsessions looking for the one that I want
At this point, you should call "initiate()" on the subsession object.
This will create "RTPSource" and "RTCPInstance" objects for the
stream. (The "RTPSource" object is the one that actually receives
data from the network.)
>* if I want to setup a session I call RTSPClient::setupMediaSubsession
Yes.
>but at this point I'm stuck. I think that before calling
>RTSPClient::playMediaSession I need to do something so that each time
>data is received my processing function is executed.
Yes, after calling "setupMediaSubsession()", and before calling
"playMediaSubsession()" (note that those two functions only send RTSP
commands; they don't actually do anything with the incoming data),
you should do the following:
1/ Create a 'sink' object which will actually receive the incoming
network data (from the "RTPSource" object). This must be a subclass
of "MediaSink", and could - for example - be a "FileSink", if you
want to write the incoming data into a file.
2/ Call "startPlaying()" on your 'sink' object, asking it to receive
data from the "subsession->readSource()". See line 712 of
"playCommon.cpp". (Note that you should call
"subsession->readSource()" rather than "subsession->rtpSource()",
because for some types of stream, they are different.)
Then, after doing 1/ and 2/, you will call "playMediaSubsession()",
to tell the server to start streaming data.
I'm sorry that the "openRTSP" code is so complicated (because the
"openRTSP" application has so many 'bells and whistles'). At some
point, I plan to also release a much simpler "testRTSPClient"
application that will make it easier for developers to figure out how
to write their own RTSP client application. (This will also use the
new asynchronous "RTSPClient" interface, which is what all developers
should eventually be using.)
--
Ross Finlayson
Live Networks, Inc.
http://www.live555.com/
More information about the live-devel
mailing list