Is the video time from QTVisualContext set by CVTimeStamp in the CAOpenGLLayer rendering method?

I am using the standard CoreVideo Display Link + QTVisualContext to render a QuickTime movie into a subclass NSOpenGLView. Now I would like to synchronize the timeline view with the movie playback. The timeline view is implemented as a presentation of the placement level by placing a subclass CAOpenGLLayerthat displays the timeline. I chose this architecture because it CAOpenGLLayergets CVTimeStampto render. I thought I could use this timestamp to get the current movie time from a QTVisualContext.

The only way I took the time to watch the movie using CVTimeStamp was to copy the QTVisualContext into CVImageBuffer (using QTVisualContextCopyImageForTime) and then get the video time from the CVImageBuffer attachment kCVBufferMovieTimeKey. Obviously, this seems a bit crowded since I don't need an image. In addition, the documentation for QTVisualContextCopyImageForTimeindicates that a time request prior to the previous call is not allowed. Since I cannot guarantee the order of events between the CoreAnimation stream and the display link stream in CoreVideo, I ran into a dead end.

It seems like I CVDisplayLinkTranslateTimeshould be able to translate the CVTimeStamp that I get in the rendering method CAOpenGLLayerinto the movie time and movie time base, but I'm not sure how to relate this (link display time) to QuickTime play time. I do not necessarily know when the video time is 0 relative to the viewing time in the display mode.

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

+3
source share

Source: https://habr.com/ru/post/1731440/


All Articles