예제 #1
0
void ProcessManagerX11::Open(const FB::BrowserHostPtr& host, const std::string &path)
{
    host->ScheduleOnMainThread(boost::shared_ptr<ProcessManagerX11>(), boost::bind(&ProcessManagerX11::_open, this, host, path));
}
예제 #2
0
파일: FBVLC.cpp 프로젝트: zhaoxiaohui/fbvlc
//libvlc events arrives from separate thread
void FBVLC::OnLibVlcEvent_proxy(const libvlc_event_t* e, void *param)
{
    FBVLC* fbvlc = static_cast<FBVLC*>(param);

    FBVLCAPIPtr api  = boost::static_pointer_cast<FBVLCAPI>( fbvlc->getRootJSAPI() );
    FB::BrowserHostPtr h = fbvlc->m_host;

    void (FBVLCAPI::*event_to_fire)(void) = 0;

    switch ( e->type ) {
    case libvlc_MediaPlayerMediaChanged:
        event_to_fire = &FBVLCAPI::fire_MediaPlayerMediaChanged;
        break;
    case libvlc_MediaPlayerNothingSpecial:
        event_to_fire = &FBVLCAPI::fire_MediaPlayerNothingSpecial;
        break;
    case libvlc_MediaPlayerOpening:
        event_to_fire = &FBVLCAPI::fire_MediaPlayerOpening;
        break;
    case libvlc_MediaPlayerBuffering:
        event_to_fire = &FBVLCAPI::fire_MediaPlayerBuffering;
        break;
    case libvlc_MediaPlayerPlaying:
        event_to_fire = &FBVLCAPI::fire_MediaPlayerPlaying;
        break;
    case libvlc_MediaPlayerPaused:
        event_to_fire = &FBVLCAPI::fire_MediaPlayerPaused;
        break;
    case libvlc_MediaPlayerStopped:
        event_to_fire = &FBVLCAPI::fire_MediaPlayerStopped;
        break;
    case libvlc_MediaPlayerForward:
        event_to_fire = &FBVLCAPI::fire_MediaPlayerForward;
        break;
    case libvlc_MediaPlayerBackward:
        event_to_fire = &FBVLCAPI::fire_MediaPlayerBackward;
        break;
    case libvlc_MediaPlayerEndReached:
        event_to_fire = &FBVLCAPI::fire_MediaPlayerEndReached;
        break;
    case libvlc_MediaPlayerEncounteredError:
        event_to_fire = &FBVLCAPI::fire_MediaPlayerEncounteredError;
        break;
    case libvlc_MediaPlayerTimeChanged:
        event_to_fire = &FBVLCAPI::fire_MediaPlayerTimeChanged;
        break;
    case libvlc_MediaPlayerPositionChanged:
        event_to_fire = &FBVLCAPI::fire_MediaPlayerPositionChanged;
        break;
    case libvlc_MediaPlayerSeekableChanged:
        event_to_fire = &FBVLCAPI::fire_MediaPlayerSeekableChanged;
        break;
    case libvlc_MediaPlayerPausableChanged:
        event_to_fire = &FBVLCAPI::fire_MediaPlayerPausableChanged;
        break;
    //case libvlc_MediaPlayerTitleChanged:
    //    event_to_fire = &FBVLCAPI::fire_MediaPlayerTitleChanged;
    //    break;
    //case libvlc_MediaPlayerSnapshotTaken:
    //    event_to_fire = &FBVLCAPI::fire_MediaPlayerSnapshotTaken;
    //    break;
    //case libvlc_MediaPlayerLengthChanged:
    //    event_to_fire = &FBVLCAPI::fire_MediaPlayerLengthChanged;
    //    break;
    //case libvlc_MediaPlayerVout:
    //    event_to_fire = &FBVLCAPI::fire_MediaPlayerVout;
    //    break;
    };

    if ( event_to_fire ) {
        h->ScheduleOnMainThread( api, boost::bind( event_to_fire, api.get() ) );
    }
}
예제 #3
0
//libvlc events arrives from separate thread
void Chimera::media_player_event( const libvlc_event_t* e )
{
    JSRootAPIPtr api  = boost::static_pointer_cast<JSRootAPI>( getRootJSAPI() );
    FB::BrowserHostPtr h = m_host;

    void (JSRootAPI::*event_to_fire)(void) = 0;
    bool fireStateChanged = false;
    libvlc_state_t newState;

    bool scheduleNotPlaying = false;

    switch ( e->type ) {
    case libvlc_MediaPlayerMediaChanged:
        event_to_fire = &JSRootAPI::fire_MediaPlayerMediaChanged;
        break;
    case libvlc_MediaPlayerNothingSpecial:
        event_to_fire = &JSRootAPI::fire_MediaPlayerNothingSpecial;
        fireStateChanged = true;
        newState = libvlc_NothingSpecial;
        break;
    case libvlc_MediaPlayerOpening:
        event_to_fire = &JSRootAPI::fire_MediaPlayerOpening;
        fireStateChanged = true;
        newState = libvlc_Opening;
        break;
    case libvlc_MediaPlayerBuffering:
        h->ScheduleOnMainThread( api,
                                 boost::bind( &JSRootAPI::fire_MediaPlayerBuffering,
                                              api.get(),
                                              e->u.media_player_buffering.new_cache ) );
        fireStateChanged = true;
        newState = libvlc_Buffering;
        break;
    case libvlc_MediaPlayerPlaying: {
        boost::shared_ptr<Chimera> thisPtr = FB::ptr_cast<Chimera>( shared_from_this() );
        h->ScheduleOnMainThread( thisPtr,
                                 boost::bind( &Chimera::onMediaPlayerPlaying,
                                              thisPtr ) );

        event_to_fire = &JSRootAPI::fire_MediaPlayerPlaying;
        fireStateChanged = true;
        newState = libvlc_Playing;
        break;
    }
    case libvlc_MediaPlayerPaused:
        event_to_fire = &JSRootAPI::fire_MediaPlayerPaused;
        scheduleNotPlaying = true;
        fireStateChanged = true;
        newState = libvlc_Paused;
        break;
    case libvlc_MediaPlayerStopped:
        event_to_fire = &JSRootAPI::fire_MediaPlayerStopped;
        scheduleNotPlaying = true;
        fireStateChanged = true;
        newState = libvlc_Stopped;
        break;
    case libvlc_MediaPlayerForward:
        event_to_fire = &JSRootAPI::fire_MediaPlayerForward;
        break;
    case libvlc_MediaPlayerBackward:
        event_to_fire = &JSRootAPI::fire_MediaPlayerBackward;
        break;
    case libvlc_MediaPlayerEndReached:
        event_to_fire = &JSRootAPI::fire_MediaPlayerEndReached;
        scheduleNotPlaying = true;
        fireStateChanged = true;
        newState = libvlc_Ended;
        break;
    case libvlc_MediaPlayerEncounteredError:
        event_to_fire = &JSRootAPI::fire_MediaPlayerEncounteredError;
        scheduleNotPlaying = true;
        fireStateChanged = true;
        newState = libvlc_Error;
        break;
    case libvlc_MediaPlayerTimeChanged: {
        double new_time = static_cast<double>( e->u.media_player_time_changed.new_time );
        h->ScheduleOnMainThread( api,
                                 boost::bind( &JSRootAPI::fire_MediaPlayerTimeChanged,
                                              api.get(),
                                              new_time ) );
        break;
    }
    case libvlc_MediaPlayerPositionChanged:
        h->ScheduleOnMainThread( api,
                                 boost::bind( &JSRootAPI::fire_MediaPlayerPositionChanged,
                                              api.get(),
                                              e->u.media_player_position_changed.new_position ) );
        break;
    case libvlc_MediaPlayerSeekableChanged:
        h->ScheduleOnMainThread( api,
                                 boost::bind( &JSRootAPI::fire_MediaPlayerSeekableChanged,
                                              api.get(),
                                              e->u.media_player_seekable_changed.new_seekable != 0 ) );
        break;
    case libvlc_MediaPlayerPausableChanged:
        h->ScheduleOnMainThread( api,
                                 boost::bind( &JSRootAPI::fire_MediaPlayerPausableChanged,
                                              api.get(),
                                              e->u.media_player_pausable_changed.new_pausable != 0 ) );
        break;
    //case libvlc_MediaPlayerTitleChanged:
    //    event_to_fire = &JSRootAPI::fire_MediaPlayerTitleChanged;
    //    break;
    //case libvlc_MediaPlayerSnapshotTaken:
    //    event_to_fire = &JSRootAPI::fire_MediaPlayerSnapshotTaken;
    //    break;
    case libvlc_MediaPlayerLengthChanged: {
       double new_length =
           static_cast<double>( e->u.media_player_length_changed.new_length );
        h->ScheduleOnMainThread( api,
                                 boost::bind( &JSRootAPI::fire_MediaPlayerLengthChanged,
                                              api.get(),
                                              new_length ) );

        break;
    }
    //case libvlc_MediaPlayerVout:
    //    event_to_fire = &JSRootAPI::fire_MediaPlayerVout;
    //    break;
    };

    if( event_to_fire ) {
        h->ScheduleOnMainThread( api, boost::bind( event_to_fire, api.get() ) );
    }

    if( fireStateChanged ) {
        h->ScheduleOnMainThread( api,
                                 boost::bind( &JSRootAPI::fire_MediaPlayerStateChanged,
                                              api.get(),
                                              newState ) );
    }

    if( scheduleNotPlaying ) {
        boost::shared_ptr<Chimera> thisPtr = FB::ptr_cast<Chimera>( shared_from_this() );
        h->ScheduleOnMainThread( thisPtr,
                                 boost::bind( &Chimera::onMediaPlayerNotPlaying,
                                              thisPtr ) );
    }
}