[Live-devel] Multiple clients on a single FramedSource substream

David J Myers david.myers at panogenics.com
Sat Jan 28 09:38:22 PST 2012


Hi, I don't think I'm handling multiple client connections properly in my
camera's live rtsp server.

My camera has multiple streams and I derive a class from FramedSource for
each of my substreams, the constructor looks like this:-

StreamSource::StreamSource(UsageEnvironment &env,streamSubStream_t
*substream) : 

     FramedSource(env), m_substream(substream)

{

     FUNCTION_TRACE;

     substream->source = this;

     m_listsources.push_back(this);

     ++referenceCount;

     if (eventTriggerId == 0)

     {

         eventTriggerId =
envir().taskScheduler().createEventTrigger(deliverFrame0);

     }

     m_BufferOffset = 0;

     m_NalIndex = 0;

     INFO("StreamSource constructor, this=0x%p, ref count =%d, StreamIndex =
%d\r\n",

                this, referenceCount, substream->iStreamNo);

}

So I'm saving a pointer to the source in a parameter I pass in. The trouble
is, I think, when a second client connects to the same stream, another
instance of the class is created, and this pointer gets overwritten with the
latest instance. Then, when I need to trigger the event when I have a NAL
unit to send, I call this function:-

void signalNewFrameData(StreamSource* source) {

  TaskScheduler* ourScheduler = &(source->envir().taskScheduler()); 

  StreamSource* ourDevice  = source; 

 

  if (ourScheduler != NULL)

  { // sanity check

       TRACE("About to trigger Deliver event\r\n");

       ourScheduler->triggerEvent(StreamSource::eventTriggerId, ourDevice);

  }

}

I only seem to call this function for the last source on this substream.
I've inherited a lot of this code but do I need to trigger the event for all
sources connected or am I totally misunderstanding this mechanism?

Thanks - David

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


More information about the live-devel mailing list