[Live-devel] unicast onDemand from live source NAL Units

Ross Finlayson finlayson at live555.com
Wed Jan 23 05:55:28 PST 2013


> FramedSource* H264LiveServerMediaSubsession::createNewStreamSource(unsigned /*clientSessionId*/, unsigned& estBitrate) {
>  estBitrate = 10000; // kbps, estimate
>  // Create the video source:
>    H264LiveStreamFramedSource* liveFramer = H264LiveStreamFramedSource::createNew(envir(),liveBuffer);
> 	H264VideoStreamDiscreteFramer* discFramer = H264VideoStreamDiscreteFramer::createNew(envir(),liveFramer);
>  // Create a framer for the Video Elementary Stream:
>  return H264VideoStreamFramer::createNew(envir(), discFramer);

No, this is wrong!  You should not be creating/using a "H264VideoStreamFramer" at all.  That class should be used *only* when the input is a byte stream (e.g., from a file).  If - as in your case - the input is a discrete sequence of NAL units (i.e., one NAL unit at a time), then you should use a "H264VideoStreamDiscreteFramer" only.  So, you should replace the line
	return H264VideoStreamFramer::createNew(envir(), discFramer);
with
	return discFramer;

That should also fix the problem that you're seeing with "fMaxSize" not being large enough in your "H264VideoStreamLiveFramedSource" implementation.


> This is the doGetNextFrame in the H264LiveStreamFramedSource I'm using:
> 
> void H264LiveStreamFramedSource::doGetNextFrame() {
> 
> 	// Try to read as many bytes as will fit in the buffer provided (or "fPreferredFrameSize" if less)
> 	fFrameSize=fBuffer->read(fTo,fMaxSize,&fNumTruncatedBytes);

This should work, provided that your "read()" function always delivers (to "*fTo") a single NAL unit, and nothing else - and blocks until one becomes available.  In other words, after "read()" is called, the first bytes of *fTo must be the start of a single NAL unit, with *no* 'start code'.

This is not ideal, though, because, ideally, 'read' functions called from a LIVE555-based application should not block (because LIVE555-based applications run in a single-threaded event loop).  Instead, if "doGetNextFrame()" gets called when no new NAL unit is currently available, it should return immediately.

I suggest that you review the sample code that we have provided in "liveMedia/DeviceSource.cpp".  You can use this class as a model for how to write your "H264LiveStreamFramedSource" class.


Ross Finlayson
Live Networks, Inc.
http://www.live555.com/

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


More information about the live-devel mailing list