locked
when capturing, what is the best way to obtain the logical time for a media sample? RRS feed

  • Question

  • I am using GMFBridge to include capture/pause functionality.   I need to be able to determine the 'logical' media sample time (i.e. not stream time).   By logical time, I am referring to time measured relative to the start of the first media sample and that includes all pause intervals.   Stream time, in contrast, excludes all pause intervals.


    My question is, when capturing/recording media data, what is the best way to determine the logical time of a media sample? 


    The approach I am considering is as follows:


    1) pause the graph and wait for it to cue
    2) call IReferenceClock::GetTime() to get the start time
    3) call IMediaControl::Run () to start capturing media
    4) in ISampleGrabberCB::BufferCB(), compute the logical time by calling IReferenceClock::GetTime()  and subtracting the start time obtained in step 2

    In using this approach, I am not certain of how accurate the computed logical time is.    There may be better ways to do this, hence my question.

    Thanks

     



    • Edited by IB00 Tuesday, November 29, 2011 5:02 AM
    Tuesday, November 29, 2011 5:01 AM

Answers

  • Thanks for putting me on the right track.  It will be a few days before I finish updating my code and unit tests.  I'll keep this post open for a few more days in case I encounter any hiccups. 

    Ian

    • Marked as answer by IB00 Wednesday, December 21, 2011 7:20 PM
    Thursday, December 1, 2011 2:45 AM

All replies

  • You need to know the time relative to the first sample's timestamp, so you need to convert the first sample to absolute reference time. Your approach is nearly right, but you need to use IMediaFilter::Run so that you can pass in your own stream time offset. IMediaControl::Run uses the IMediaFilter implementation underneath. Query the graph itself for IMediaFilter, get the current absolute clock time, add on 10ms or so (if you're cued) and then pass this time to IMediaFilter::Run.

    G

    Tuesday, November 29, 2011 3:39 PM
  • Thanks for putting me on the right track.  It will be a few days before I finish updating my code and unit tests.  I'll keep this post open for a few more days in case I encounter any hiccups. 

    Ian

    • Marked as answer by IB00 Wednesday, December 21, 2011 7:20 PM
    Thursday, December 1, 2011 2:45 AM