Exemple #1
0
void VideoSource::resizeBuffer()
{
    // get intended size so we can resize, since the width might change here
    RectangleBase intended;
    intended.setScale( intendedWidth, intendedHeight );
    float posX = getDestX();
    float posY = getDestY();
    if ( !lastFillFull )
    {
        posX += getCenterOffsetX();
        posY += getCenterOffsetY();
    }
    intended.setPos( posX, posY );

    listener->updatePixelCount( -( vwidth * vheight ) );
    vwidth = videoSink->getImageWidth();
    vheight = videoSink->getImageHeight();
    listener->updatePixelCount(  vwidth * vheight );

    if ( vheight > 0 )
        destAspect = (float)vwidth / (float)vheight;
    else
        destAspect = 1.33f;

    if ( animated )
        aspectAnimating = true;
    else
        aspect = destAspect;

    tex_width = GLUtil::getInstance()->pow2( vwidth );
    if ( videoSink->getImageFormat() == VIDEO_FORMAT_YUV420 )
        tex_height = GLUtil::getInstance()->pow2( 3*vheight/2 );
    else
        tex_height = GLUtil::getInstance()->pow2( vheight );

    gravUtil::logVerbose( "VideoSource::resizeBuffer: image size is %ix%i\n",
                          vwidth, vheight );
    gravUtil::logVerbose( "VideoSource::resizeBuffer: texture size is %ix%i\n",
                          tex_width, tex_height );

    // if it's not the first time we're allocating a texture
    // (ie, it's a resize) delete the previous texture
    if ( !init )
        glDeleteTextures( 1, &texid );

    glGenTextures( 1, &texid );

    glBindTexture( GL_TEXTURE_2D, texid );

    glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
    glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
    glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
    glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );

    unsigned char *buffer = new unsigned char[ tex_width * tex_height * 3 ];
    memset( buffer, 128, tex_width * tex_height * 3 );
    glTexImage2D( GL_TEXTURE_2D,
                  0,
                  GL_RGB,
                  tex_width,
                  tex_height,
                  0,
                  GL_LUMINANCE,
                  GL_UNSIGNED_BYTE,
                  buffer );
    delete[] buffer;

    // fill to intended size
    fillToRect( intended, lastFillFull );

    // update text bounds since the width might be different
    updateTextBounds();
}
Exemple #2
0
SessionManager::SessionManager( VideoListener* vl, AudioManager* al,
                                gravManager* g )
    : Group( 0.0f, -6.0f ), videoSessionListener( vl ),
      audioSessionListener( al ), objectManager( g )
{
    x = destX;
    y = destY - 10.0f; // for move-from-bottom animation

    sessionMutex = mutex_create();

    videoSessionCount = 0;
    audioSessionCount = 0;
    lockCount = 0;
    pause = false;

    rotatePos = -1;
    lastRotateSession = NULL;

    preserveChildAspect = false;

    locked = false;
    selectable = false;
    userMovable = false;

    setBorderScale( 0.0f );

    setName( "Session Manager" );

    RGBAColor mainColor;
    mainColor.R = 0.1f;
    mainColor.G = 0.1f;
    mainColor.B = 0.1f;
    mainColor.A = 0.1f;
    setColor( mainColor );

    videoSessions = new SessionGroup( getDestX(), getDestY() );
    videoSessions->setPos( x, y );
    videoSessions->setName( "Video" );
    videoSessions->setBorderScale( 0.005 );
    RGBAColor videoColor;
    videoColor.R = 0.1f;
    videoColor.G = 0.8f;
    videoColor.B = 0.1f;
    videoColor.A = 0.3f;
    videoSessions->setBaseColor( videoColor );

    availableVideoSessions = new SessionGroup( getDestX(), getDestY() );
    availableVideoSessions->setPos( x, y );
    availableVideoSessions->setName( "Available Video" );
    availableVideoSessions->setBorderScale( 0.005 );
    RGBAColor availableVideoColor;
    availableVideoColor.R = 0.1f;
    availableVideoColor.G = 0.1f;
    availableVideoColor.B = 0.8f;
    availableVideoColor.A = 0.3f;
    availableVideoSessions->setBaseColor( availableVideoColor );

    audioSessions = new SessionGroup( getDestX(), getDestY() );
    audioSessions->setPos( x, y );
    audioSessions->setName( "Audio" );
    audioSessions->setBorderScale( 0.005 );
    RGBAColor audioColor;
    audioColor.R = 0.8f;
    audioColor.G = 0.1f;
    audioColor.B = 0.1f;
    audioColor.A = 0.3f;
    audioSessions->setBaseColor( audioColor );

    avButton = new SessionGroupButton( getDestX(), getDestY() );
    avButton->setPos( x, y );
    avButton->setName( "Available Video Rotate Toggle" );
    avButton->setControlledGroup( availableVideoSessions );

    // note we don't add audio here - this just hides it visually
    add( videoSessions );
    add( availableVideoSessions );
    add( avButton );
    objectManager->lockSources();
    objectManager->addToDrawList( videoSessions );
    objectManager->addToDrawList( availableVideoSessions );
    objectManager->addToDrawList( avButton );
    objectManager->unlockSources();

    sessionMap[ VIDEOSESSION ] = videoSessions;
    sessionMap[ AVAILABLEVIDEOSESSION ] = availableVideoSessions;
    sessionMap[ AUDIOSESSION ] = audioSessions;

    show( false, true );
}