Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
Re: shared context playing video
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: shared context playing video



Kind of answering my own question here: I've stumbled across the LiveVideoMixer2 example and it is largely doing what I want to do.

As I'm coding this up, one question remains in the back of my mind: can I have two NSOpenGLContexts and a QTVisualContext all share each other? 

Since the QTVisualContext is the one that is created every time a new movie is loaded, my approach is going to be:

Create NSOpenGLContextA with nil as shared context
Create NSOpenGLContextB with NSOpenGLContextA as shared context
Create QTVisualContext as needed with NSOpenGLContextA as shared context.

Thanks,
-Beth.

On Wed, Oct 7, 2009 at 9:55 AM, Beth S <email@hidden> wrote:
Hi there,

I've almost got this thing licked, but there's one last piece of the puzzle that I'm missing.  I'm trying to play back QT video spanned across two displays using shared opengl contexts.  These displays are on the same graphics card (otherwise my understanding is that shared OpenGL contexts on different GPUs can't share textures). 

My question is, if they are shared contexts and they share the PBO, how does the slave context know when there is a new frame available from the master?

The display link callback code from QTCoreVideo202 is below.  It's unclear to me how to make it work in the case of a shared PBO across two NSOpenGLViews.  Presumably only the master NSOpenGLView would need to load new frames, but how does the slave NSOpenGLView check for the master's new frame?  How does the slave NSOpenGLView reference the master's frame object?

- (CVReturn) getFrameForTime:(const CVTimeStamp *)timeStamp
                    flagsOut:(CVOptionFlags *)flagsOut
{
    // There is no autorelease pool when this method is called because it will
    // be called from another thread it's important to create one or you will
    // leak objects
   
    NSAutoreleasePool *pool = [NSAutoreleasePool new];
   
    // Check for new frame
   
    if (        ( [visualContext isValidVisualContext] )
            &&    ( [visualContext isNewImageAvailable:timeStamp] ) )
    {       
        // If we have a previous frame release it

        [self deleteCVPixelBuffer];
       
        // Get a "frame" (image image) from the Visual Context, indexed by
        // the provided time

        attributes->coreVideo.videoFrame = [visualContext copyImageForTime:timeStamp];
       
        // The above call may produce a null frame so check for this first
        // if we have a frame, then draw it
       
        if ( attributes->coreVideo.videoFrame != NULL )
        {
            [self drawRect:NSZeroRect];
        } // if
        else
        {
            NSLog( @"WARNING: QT Visual Context Copy Image for Time Error!" );
        } // else
    } // if
   
    [pool release];

    return kCVReturnSuccess;
} // getFrameForTime

Thanks!
Beth.

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Mac-opengl mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >shared context playing video (From: Beth S <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.