Ejemplo n.º 1
0
bool SessionEntry::initSession( VPMSessionListener* listener )
{
    if ( !isSessionEnabled() )
    {
        VPMSessionFactory* factory = VPMSessionFactory::getInstance();
        session = factory->createSession( address.c_str(), *listener );

        session->enableVideo( !audio );
        session->enableAudio( audio );
        session->enableOther( false );

        if ( !session->initialise() )
        {
            gravUtil::logError( "SessionEntry::init: failed to initialize on "
                                "address %s\n", address.c_str() );
            initialized = false;
            // might as well delete the session object here to prevent potential
            // memleaks (ie, reinitializing a session that failed to init)
            disableSession();
            setBaseColor( failedColor );
            inFailedState = true;
            return false;
        }

        if ( encryptionKey.compare( "__NO_KEY__" ) != 0 )
        {
            session->setEncryptionKey( encryptionKey.c_str() );
        }

        sessionTS = random32();

        initialized = true;
        inFailedState = false;
        resetColor();
        return true;
    }
    else
    {
        gravUtil::logWarning( "SessionEntry::init: session %s already "
                                "initialized\n", address.c_str() );
        return false;
    }
}
Ejemplo n.º 2
0
void SessionManager::unrotate( bool audio )
{
    lockSessions();

    SessionEntry* current = NULL;
    if ( rotatePos >= 0 && rotatePos < availableVideoSessions->numObjects() )
        current =
            dynamic_cast<SessionEntry*>( (*availableVideoSessions)[ rotatePos ] );

    rotatePos = -1;
    lastRotateSession = NULL;

    if ( current != NULL )
    {
        disableSession( current );
    }

    unlockSessions();
}
Ejemplo n.º 3
0
bool SessionManager::shiftSession( SessionEntry* entry )
{
    Group* to;
    Group* from = entry->getGroup();

    if ( from == videoSessions )
    {
        to = availableVideoSessions;
        disableSession( entry );
    }
    else if ( from = availableVideoSessions )
    {
        to = videoSessions;

        if ( !entry->isSessionEnabled() )
        {
            initSession( entry );
        }

        int i = indexOf( entry );
        // shift rotate position back if what we're removing is before or at it,
        // so we don't skip any
        if ( i <= rotatePos && i != -1 )
            rotatePos--;
    }
    else
    {
        const char* name = from != NULL ? from->getName().c_str() : "NULL";
        gravUtil::logWarning( "SessionManager::shiftSession: invalid source "
                              "group input (%s)\n", name );
        return false;
    }

    from->remove( entry );
    to->add( entry );

    recalculateSize();

    return true;
}
Ejemplo n.º 4
0
SessionEntry::~SessionEntry()
{
    gravUtil::logVerbose( "~SessionEntry (%s)\n", address.c_str() );
    disableSession();
}
Ejemplo n.º 5
0
bool SessionManager::rotateTo( std::string addr, bool audio )
{
    lockSessions();

    int numSessions = availableVideoSessions->numObjects();
    int lastRotatePos = rotatePos;
    if ( lastRotatePos != -1 )
        lastRotateSession =
            dynamic_cast<SessionEntry*>( (*availableVideoSessions)[ rotatePos ] );
    if ( numSessions == 0 )
    {
        unlockSessions();
        return false;
    }

    SessionEntry* current;

    // if arg is an empty string, just rotate to next. otherwise, figure out
    // rotate pos of string arg
    if ( addr.compare( "" ) == 0 )
    {
        if ( ++rotatePos >= numSessions )
        {
            rotatePos = 0;
        }
        current =
            dynamic_cast<SessionEntry*>( (*availableVideoSessions)[ rotatePos ] );
    }
    else
    {
        current = findSessionByAddress( addr, AVAILABLEVIDEOSESSION );

        if ( current != NULL )
        {
            rotatePos = indexOf( current );
        }
    }

    if ( current == NULL )
    {
        gravUtil::logWarning( "SessionManager::rotateTo: session %s"
                              " not found\n", addr.c_str() );
        unlockSessions();
        return false;
    }

    // only rotate if there is a valid old one & it isn't the same as
    // current
    if ( lastRotateSession != NULL && current != NULL &&
            lastRotateSession != current )
    {
        disableSession( lastRotateSession );
        initSession( current );
    }
    // case for first rotate
    else if ( lastRotatePos == -1 )
    {
        initSession( current );
    }

    unlockSessions();

    return true;
}