win32 programmer directx video How to reset start time in renderer?

来源:百度文库 编辑:神马文学网 时间:2024/04/27 14:18:47
Previous Thread:   How renderfile works
2/7/2006 11:03:39 PM    How to reset start time in renderer?Dear all, I am writing my source filter now. In this filter,the functions of splitter are also included. The graph is like belowsource filter -> video decoder -> video rendererI expose a simpler interface like IMediaSeeking::SetPosition, thecaller need not to know the actual file pos. they want to jump. Thefile pos. is converted inside my filter.The problem is I need to call IMediaSeeking::SetPosition of GraphManger inside my source filter. But when i call it, the video rendererwill not render any frame except the first one. After several seconds,the renderer will play smoothly. Another phenomenon is the sliderwill stop when renderer hang. It will increse progressively afterrendererplay normaly.I guess the problem is the WaitForRenderTime() function in renderer.The m_tStart in renderer will be updated when Run() is called. If them_tStart is not updated properly, the m_RenderEvent will not beset signal in render time. The Graph Manager should propagatePause() and Run() upstream when I call IMediaSeeking::SetPositon.But the result is not what I predicted.Any suggestions?ThanksChris C.
7250599242
2/8/2006 10:48:38 AM    Re: How to reset start time in renderer?On 7 Feb 2006 23:03:39 -0800, Chris C. wrote:I don't think you want to call the graph's IMediaSeeking from within yourfilter's IMediaSeeking interface -- especially as the graph will normallypass the call to your filter's method.If the original SetPositions call is routed from the app to the graph andthen to your source filter, the stream time will be reset. So your firsttimestamp of 0 after the seek will be rendered immediately.If you need to perform some seeking within your source filter without goingthrough the graph, then the stream time will not be reset, so you will needto adjust your timestamps. When you start to push data after the seek, youwill need to either set the timestamps to be the current stream time plussome latency or you can make them contiguous with the previous times.Note that if you are using the current stream time, remember that the baseclass implementation of StreamTime is not correct when paused. The correctimplementation is to store a "paused-at" time on the transition fromrunning to paused, which is reset to 0 when stopped.G
2/8/2006 7:05:56 PM    Re: How to reset start time in renderer?I know the graph will pass the call to my filter if the app callgraph's IMediaSeeking normaly. My requirement is call the graph'sIMediaSeeking directly inside my filter. I will get a reference to thegraph first inside my filter. And then, I will call the graph'sIMediaSeeking through the graph. After the graph propagate the callproperly, my filter will receive the call. I just want to move theburden of calling IMediaSeeking from the app to my filter.After SetPositon call is sent by graph, all filters in the graph willchange its state (Run -> Pause -> Run). So the stream time will bereset to 0 since the m_tStart in every filter is updated to the newestreference time, right? I guess the NewSegment just inform thedownstream filter the stream time is reset to 0 now, but the actualeffect is achieved by state change.I have try another method when I seeking my data not throughtIMediaSeeking. After seeking is complete, I call the IMediaFilter ofvideo and audio renderer to change the state manually. And the resultis normal. I think such method is not like the normal procedure that weseek data through IMediaSeeking. There would be some side effect ornot. I will try your suggestion first.Thanks for your reply.Chris C.
2/9/2006 3:34:40 PM    Re: How to reset start time in renderer?On 8 Feb 2006 19:05:56 -0800, Chris C. wrote:This is not how it works. The state transition is not sufficient to resetthe base time. If you have a sample queued at the renderer, and you havebeen running for 10 seconds, the sample's timestamp might be 10.1 seconds.If you pause and then run again, the sample will render immediately, notafter 10 seconds. The base time reset is needed because of the flush, butit is not triggered by the flush or the state transition. The base timereset only happens because the graph manager "knows" that SetPositions willrequire a flush. You can't trigger it from any other interface -- it's aprivate communication between the graph handler for IMediaControl and thehandler for IMediaSeeking.As you say, you can bypass IMediaControl and IMediaSeeking entirely, andset your own base time using IMediaFilter::Run on the graph, and this willwork fine. However, I would very strongly recommend that you do not do thisfrom within a filter. If you want to add a simpler interface for the app tocall, why not look at implementing a plug-in distributor? This allows youto build a control interface that will be loaded by the graph manager.G
2/12/2006 11:15:56 PM    Re: How to reset start time in renderer?Dear GeraintI have try your suggestion to adjust the stream time after seeking. Butthere still has a problem I need to overcome. Since I use theCOutputQueue in my filter. If my source filter has parsed data of 10sec. The renderer may show the data of 5 sec now. There exist a delaybetween source and renderer filter. After seeking, the correct streamtime should be 5 sec + latency time, not 10 sec + latency time. How doI determine the correct stream time in my source filter?I have read the doc about the plug-in distributor. So the app need toquery interface through the graph manager to get the PID. The PID dothe reamaining thing as custom. But such PID must be registered inregistry in advance, right? If the user's PC not contain such a PID,the app can't invoke such function call. When the app want to seekdata, it must through the PID, not throught my filter directly. But inmy plan, my filter should provide a interface to allow the app to seek.Thanks for your replayChris C.
2/19/2006 10:42:58 PM    Re: How to reset start time in renderer?Finally, I call the graph's GetCurrentPosition to get the actual timethat renderer return. But such kind of method is not perfectly since Ishould not call the graph's interface inside my custom filter. I willpost the better solution if I discover it.Thanks for helpChris C.