[Live-devel] LiveMedia in a Directshow Filter - Encapsulating

Eyal Shveky eyals at aeronautics-sys.com
Thu Dec 2 18:40:08 PST 2010


 
Hi, 

 I almost started to give up with live555, then I decided to go over to F&Q, and start from streaming Mpeg1-2 instead of MPeg4 and ondemand, Following testMPEG1or2VideoStreamer and the advice of encapsulating my DS source with FramedSource then I see some gray static picture on my VLCplayer from. Didn't gave up continue trying to make it works. I think my main problem  is synchronizing both threads. Actually with DirectShow filter is more then one, Anyway I took the tread that receives the MediaSample (i.e frame) type of CRTSPInputPin. Subclass it from FramedSource, then I realize the when I'm creating it I need to pass the BasicUsageEnvironment as a parameter so the usage environment have to be global for use of both threads. then only after I'm creating my CRTSPInputPin type of FramedSource in my filter creation I'm assigning the pointer to a global CRTSPInputPin type of FramedSource. That used in the Live555 thread at the point of creating the framer MPEG1or2VideoStreamFramer later used by videoSink->startPlaying as the video source. 
The flow:  On the CRTSPInputPin  when a new MediaSample(Frame) is received I'm running the live555 thread only for the first time . . That create the server,socket,port etc -> startPlaying at the end doEventLoopwith the fWatchVariable - Live555 is running. Continue in DS thread getting the buffer and length of the frame from the MediaSample call to doGetNextFrame() to process that frame.
>From that point both threads asynchronously running, And I need to sync them somehow. Sometimes I'm receiving frames from my source before Live555 get to the point of startplaying, Sometimes Live555 process the same frame on a loop, (The gray VLC effect). Most of the time I'm getting "ignoring non video sequence header" between one receive to another.
Questions:
1) How do I sync the LiveMedia Sequence, It's running on 1 thread moving the nextFrame from source to sink on endless loop.
     It seams that while breaking that loop I have to dill with the consciences , My source is FramedSource and I'm calling doGetNextFrame in order to set fTo, fFrameSize from a global buffer, do I need the fWatchVariable? Do I need to used the DeliverFrame method and do the frame set over there?
2) Should I add another task to the scheduler or subclass it and used it from the DS thread in order to sync to Live555 flow.

Source Code attached,
I'm more then accepting to see it works.
Thanks a lot 
 Eyal

	>  >while(true)
	>  >{
	>  >       fWatchVariable = 0;
	>  >       dummyTask(NULL); // 100ms
	>  >       env->taskScheduler().doEventLoop(&fWatchVariable);
	>  >       if (fWatchVariable = 1)
	>  >       {
	>  >             printf("\nIn While fWatchVariable=%d,",fWatchVariable);
	>  >             if (!mP4LiveSms->mpeg4LiveSource != NULL)
	>  >                               mP4LiveSms->mpeg4LiveSource->deliverFrame();
	>  >       }
	>  >}
	
	[...]
	
	>  1)  How should I call deliverFrame() from the Main thread(DS Graph
	>in a Filter) in order to signal my FramedSource that a new frame is
	>arrived.
	
	You don't!  "deliverFrame()" - being a LIVE555 library operation -
	should be called only from the LIVE555 event loop thread - not from
	some other thread.
	
	However, what you *can* do in the non-LIVE555 thread (i.e., your
	'DirectShow' thread) is set "fWatchVariable" to 1.  If you do this,
	then the LIVE555 event loop (your code above) will notice this, and
	do the right thing, calling "deliverFrame()".
	
	
	>3) Question about the parameters : fPresentationTime,
	>fDurationInMicroseconds what exactly they mean.
	>   fPresentationTime Is the different between sample(frame) start and
	>Stop - in my received filter -> pSample->GetTime(&tStart, &tStop);?
	
	In most situations, you can just set "fPresentationTime" by calling
	"gettimeofday()".  You should do this inside your "deliverFrame()"
	function (which is called from the LIVE555 event loop thread, of
	course).
	
	
	>   fDurationInMicroseconds - How do I set this parameter?
	
	In principle, it should be set to the duration between successive
	frames (that you deliver using "deliverFrame()").
	
	However, because you are streaming from a live source, rather than
	from a file, it's probably OK to leave this variable unset (in which
	case, it'll get a default value of 0).
	--
	
	Ross Finlayson
	Live Networks, Inc.
	http://www.live555.com/
	
	
	


**********************************************************************************************
LEGAL NOTICE - Unless expressly stated otherwise, this message, its annexes, attachments, appendixes, 
any subsequent correspondence, and any document, data, sketches, plans and/or other material that is 
hereby attached, are proprietary. confidential and may be legally privileged. 
Nothing in this e-mail is intended to conclude a contract on behalf of Aeronautics or 
make it subject to any other legally binding commitments, unless the e-mail 
contains an express statement to the contrary or incorporates a formal Purchase Order.
This transmission is intended for the named addressee only. Unless you are the named addressee (or 
authorised to receive it for the addressee) you may not copy or use it, or disclose it to anyone else, any 
disclosure or copying of the contents of this e-mail or any action taken (or not taken) in reliance on it is 
unauthorised and may be unlawful. If you are not an addressee, please inform the sender immediately.

IMPORTANT: The contents of this email and any attachments are confidential. They are intended for the 
named recipient(s) only.
If you have received this email in error, please notify the system manager or the sender immediately and do 
not disclose the contents to anyone or make copies thereof.
*** eSafe scanned this email for viruses, vandals, and malicious content. ***
**********************************************************************************************
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.live555.com/pipermail/live-devel/attachments/20101203/d152fe35/attachment-0003.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: MyRTSPFilter_send.zip
Type: application/zip
Size: 11934 bytes
Desc: MyRTSPFilter_send.zip
URL: <http://lists.live555.com/pipermail/live-devel/attachments/20101203/d152fe35/attachment-0003.zip>


More information about the live-devel mailing list