views:

188

answers:

0

I'm using the standard CoreVideo Display Link + QTVisualContext to render a QuickTime movie into an NSOpenGLView subclass. I would now like to synchronize a timeline view with movie playback. The timeline view is implemented as a layer hosting view, hosting a CAOpenGLLayer subclass that renders the timeline. I chose this architecture because the CAOpenGLLayer gets a CVTimeStamp for rendering. I thought that I could use this time stamp to get the current movie time from the QTVisualContext.

The only way I've found to get the movie time from a CVTimeStamp is to copy the QTVisualContext into a CVImageBuffer (using QTVisualContextCopyImageForTime) and then retrieve the movie time from the CVImageBuffer's kCVBufferMovieTimeKey attachment. Obviously, this seems like a little overkill since I don't need the image. Furthermore, the documentation for QTVisualContextCopyImageForTime indicates that asking for a time before the a previous call is not allowed. Since I can't guarantee the order of events between the CoreAnimation thread and the CoreVideo display link thread, I've run into a dead end.

It seems that CVDisplayLinkTranslateTime should be able to translate the CVTimeStamp I get in the CAOpenGLLayer rendering method into a movie time and movie time base, but I'm not sure how to relate this (Display Link) time to the QuickTime movie's time. I don't necessarily know when the movie's time 0 is relative to the Display Link movie time.

So, is there a way to get the movie time for a CVTimeStamp directly from the QTVisualContext (or anywhere else in the QTMovie->QTVisualContext->Display Link->...) pathway?