[Live-devel] streaming H.264 with changing resolution

orbit orbit.huang at icatchinc.com
Mon Dec 14 02:09:41 PST 2009


> >I use Live555 to stream H.264 from the embedded borad and find a bug:
> >
> >for my borad, user could change video's resolution,  at beginning
> >user recive H.264 from the borad , it plays well, but if user
> >disconnect then reconnect with different resolution, client player
> >does not decode frames correctly because SPS and PPS are not the
> >same as previous caused by fSPLines is not NULL (see below code) and
> >media field of SDP doesn't be set again.
>
> Unfortunately, for most servers, the current behavior - setting up
> "fSDPLines" only once, when the first client connects - will be the
> desired behavior, because (for most servers) the stream's SDP
> parameters will not change from client to client.  Also, in some
> cases, it might be costly to figure out the SDP parameters (e.g., it
> might involve doing some reading/parsing of the input source), so we
> would not want to generate these more than once.  Therefore the
> current default behavior should remain.
>
> What you can do, however, is reimplement the "sdpLines()" virtual
> function in your "OnDemandServerMediaSubsession" subclass, as follows:
>
> char const* yourSubclass::sdpLines() {
>        delete[] fSDPLines; fSDPLines = NULL;
>
>        return OnDemandServerMediaSubsession::sdpLines();
> }
>

Alternatively, you could just add
>        delete[] fSDPLines; fSDPLines = NULL;
> to your implementation of the "createNewRTPSink()" virtual function.
>
>
For my need, I add a virtual const char* sdpLines(FramedSource* inputSource)
= 0 to SeverMediaSession.cpp and reimplament myServerMediaSubsession

const char*
myServerMediaSubsession::sdpLines(FramedSource* inputSource)
{
    if (fSDPLines != NULL)
    {
        delete[] fSDPLines;
        fSDPLines = NULL;
    }

    if (fSDPLines == NULL)
   {
    ......
    ......
    RTPSink* dummyRTPSink
      = createNewRTPSink(&dummyGroupsock, rtpPayloadType, inputSource);

    setSDPLinesFromRTPSink(dummyRTPSink, inputSource);
    Medium::close(dummyRTPSink);
  }
  return fSDPLines;
}





> For either of these solutions to work, the definition of "fSDPLines"
> in "liveMedia/include/OnDemandServerMediaSubsession.hh" will need to
> be changed from "private" to protected".  (I'll make this change in
> the next release of the software.)
>

I'm curious, though.  You talk about the user "reconnect(ing) with a
> different resolution".  How are you doing this in the RTSP protocol?
> Because you must be creating your "H264VideoRTPSink" with a different
> "sprop_parameter_sets_str" parameter each time (in order for its SDP
> description to change), you must be making the
> "sprop_parameter_sets_str" parameter be somehow dependent upon the
> client-desired resolution.  How are you doing this?
>

 I add a H264VideoStreamFramer member (fStreamSource) into
RTSPCilentSession, my H264VideoStreamFramer creates a thread to read stream
from the board and write to FIFO. when server accept clinet's first
request(DESCRIBE or OPTIONS), RTSPCilentSession checks if FIFO has data and
make the "sprop_parameter_sets_str"

 envir().taskScheduler().turnOnBackgroundReadHandling(fStreamSource->getClientReadPipe(),
        (TaskScheduler::BackgroundHandlerProc*)&incomingSPSAndPPSHandler,
this);

If it gets "sprop_parameter_sets_str", it will process commands continuously
otherwise RTSPCilentSession will terminate because of time out.


orbit.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.live555.com/pipermail/live-devel/attachments/20091214/bf90e7cc/attachment.html>


More information about the live-devel mailing list