How to run/start a thread at a given time using Me

2019-04-16 20:50发布

问题:

I am looking for to start a thread at a specified time with Media Foundation.

I know that in DirectShow there is a function called by IMediaFilter where tStart is the time value of the reference clock.:

Interface::HRESULT Run(REFERENCE_TIME tStart);

But in Media Foundation there is no such function that will run or start a thread with a time as a parameter.

Is there a solution to do this in Media Foundation?

回答1:

Neither DirectShow or Media Foundation have functionality that matches the question description.

Both APIs have methods to start activity immediately following the request.

DirectShow's IMediaFilter.Run does not start thread in first place. Then the method is a trick rather than intended use:

... When an application calls the IMediaControl::Run method, the Filter Graph Manager calls IMediaFilter::Run on each filter. It sets the value of tStart slightly in the future, to account for graph latency.

Note that there is no word on you calling IMediaFilter::Run, the method is supposed to be called internally.

Media Foundation's internal design is different. You cannot schedule startup and you have no effect on internal working threads either. It is suppose that you start media session activity and it gets started as soon as possible.