예제 #1
0
파일: variables.c 프로젝트: Adatan/vlc
static void test_choices( libvlc_int_t *p_libvlc )
{
    vlc_value_t val, val2;
    var_Create( p_libvlc, "bla", VLC_VAR_INTEGER | VLC_VAR_HASCHOICE |
                                 VLC_VAR_ISCOMMAND );
    val.i_int = 1;
    val2.psz_string = (char*)"one";
    var_Change( p_libvlc, "bla", VLC_VAR_ADDCHOICE, &val, &val2 );

    val.i_int = 2;
    val2.psz_string = (char*)"two";
    var_Change( p_libvlc, "bla", VLC_VAR_ADDCHOICE, &val, &val2 );

    assert( var_CountChoices( p_libvlc, "bla" ) == 2 );

    var_Change( p_libvlc, "bla", VLC_VAR_DELCHOICE, &val, &val2 );
    assert( var_CountChoices( p_libvlc, "bla" ) == 1 );

    var_Change( p_libvlc, "bla", VLC_VAR_GETCHOICES, &val, &val2 );
    assert( val.p_list->i_count == 1 && val.p_list->p_values[0].i_int == 1 &&
            val2.p_list->i_count == 1 &&
            !strcmp( val2.p_list->p_values[0].psz_string, "one" ) );
    var_FreeList( &val, &val2 );

    var_Change( p_libvlc, "bla", VLC_VAR_CLEARCHOICES, NULL, NULL );
    assert( var_CountChoices( p_libvlc, "bla" ) == 0 );

    var_Destroy( p_libvlc, "bla" );
}
예제 #2
0
파일: variables.c 프로젝트: BossKing/vlc
static int vlclua_countchoices( lua_State *L )
{
    vlc_object_t **pp_obj = luaL_checkudata( L, 1, "vlc_object" );
    const char *psz_var = luaL_checkstring( L, 2 );
    int i_count = var_CountChoices( *pp_obj, psz_var );

    lua_pushinteger( L, i_count );
    return 1;
}
예제 #3
0
/*****************************************************************************
 * libvlc_audio_get_track_count : Get the number of available audio tracks
 *****************************************************************************/
int libvlc_audio_get_track_count( libvlc_media_player_t *p_mi )
{
    input_thread_t *p_input_thread = libvlc_get_input_thread( p_mi );
    int i_track_count;

    if( !p_input_thread )
        return -1;

    i_track_count = var_CountChoices( p_input_thread, "audio-es" );

    vlc_object_release( p_input_thread );
    return i_track_count;
}
/*****************************************************************************
 * ItemChange: Playlist item change callback
 *****************************************************************************/
static int ItemChange( vlc_object_t *p_this, const char *psz_var,
                       vlc_value_t oldval, vlc_value_t newval, void *p_data )
{
    input_thread_t      *p_input;
    intf_thread_t       *p_intf     = ( intf_thread_t* ) p_data;
    intf_sys_t          *p_sys      = p_intf->p_sys;
    input_item_t        *p_item;

    VLC_UNUSED( p_this ); VLC_UNUSED( psz_var );
    VLC_UNUSED( oldval ); VLC_UNUSED( newval );

    p_sys->b_state_cb       = false;
    p_sys->b_meta_read      = false;
    p_sys->b_submit         = false;

    p_input = playlist_CurrentInput( pl_Get( p_intf ) );

    if( !p_input || p_input->b_dead )
        return VLC_SUCCESS;

    p_item = input_GetItem( p_input );
    if( !p_item )
    {
        vlc_object_release( p_input );
        return VLC_SUCCESS;
    }

    if( var_CountChoices( p_input, "video-es" ) )
    {
        msg_Dbg( p_this, "Not an audio-only input, not submitting");
        vlc_object_release( p_input );
        return VLC_SUCCESS;
    }

    p_sys->time_total_pauses = 0;
    time( &p_sys->p_current_song.date );        /* to be sent to last.fm */
    p_sys->p_current_song.i_start = mdate();    /* only used locally */

    var_AddCallback( p_input, "intf-event", PlayingChange, p_intf );
    p_sys->b_state_cb = true;

    if( input_item_IsPreparsed( p_item ) )
        ReadMetaData( p_intf );
    /* if the input item was not preparsed, we'll do it in PlayingChange()
     * callback, when "state" == PLAYING_S */

    vlc_object_release( p_input );
    return VLC_SUCCESS;
}
예제 #5
0
void InputManager::UpdateTeletext()
{
    if( hasInput() )
    {
        const bool b_enabled = var_CountChoices( p_input, "teletext-es" ) > 0;
        const int i_teletext_es = var_GetInteger( p_input, "teletext-es" );

        /* Teletext is possible. Show the buttons */
        emit teletextPossible( b_enabled );

        /* If Teletext is selected */
        if( b_enabled && i_teletext_es >= 0 )
        {
            /* Then, find the current page */
            int i_page = 100;
            bool b_transparent = false;

            if( p_input_vbi )
            {
                var_DelCallback( p_input_vbi, "vbi-page", VbiEvent, this );
                vlc_object_release( p_input_vbi );
            }

            if( input_GetEsObjects( p_input, i_teletext_es, &p_input_vbi, NULL, NULL ) )
                p_input_vbi = NULL;

            if( p_input_vbi )
            {
                /* This callback is not remove explicitly, but interfaces
                 * are guaranted to outlive input */
                var_AddCallback( p_input_vbi, "vbi-page", VbiEvent, this );

                i_page = var_GetInteger( p_input_vbi, "vbi-page" );
                b_transparent = !var_GetBool( p_input_vbi, "vbi-opaque" );
            }
            emit newTelexPageSet( i_page );
            emit teletextTransparencyActivated( b_transparent );

        }
        emit teletextActivated( b_enabled && i_teletext_es >= 0 );
    }
    else
    {
        emit teletextActivated( false );
        emit teletextPossible( false );
    }
}
/*****************************************************************************
 * PlayingChange: Playing status change callback
 *****************************************************************************/
static int PlayingChange( vlc_object_t *p_this, const char *psz_var,
                       vlc_value_t oldval, vlc_value_t newval, void *p_data )
{
    VLC_UNUSED( oldval );

    intf_thread_t   *p_intf = ( intf_thread_t* ) p_data;
    intf_sys_t      *p_sys  = p_intf->p_sys;
    input_thread_t  *p_input = ( input_thread_t* )p_this;
    vlc_value_t     state_value;

    VLC_UNUSED( p_this ); VLC_UNUSED( psz_var );

    if( newval.i_int != INPUT_EVENT_STATE ) return VLC_SUCCESS;

    if( var_CountChoices( p_input, "video-es" ) )
    {
        msg_Dbg( p_this, "Not an audio-only input, not submitting");
        return VLC_SUCCESS;
    }

    state_value.i_int = 0;

    var_Get( p_input, "state", &state_value );


    if( !p_sys->b_meta_read && state_value.i_int >= PLAYING_S )
    {
        ReadMetaData( p_intf );
        return VLC_SUCCESS;
    }


    if( state_value.i_int >= END_S )
        AddToQueue( p_intf );
    else if( state_value.i_int == PAUSE_S )
        p_sys->time_pause = mdate();
    else if( p_sys->time_pause > 0 && state_value.i_int == PLAYING_S )
    {
        p_sys->time_total_pauses += ( mdate() - p_sys->time_pause );
        p_sys->time_pause = 0;
    }

    return VLC_SUCCESS;
}
예제 #7
0
/*****************************************************************************
 * InterfaceWindow::MessageReceived
 *****************************************************************************/
void InterfaceWindow::MessageReceived( BMessage * p_message )
{
    switch( p_message->what )
    {
        case B_ABOUT_REQUESTED:
        {
            BAlert * alert;

            alert = new BAlert( "VLC media player" VERSION,
                                "VLC media player" VERSION " (BeOS interface)\n\n"
                                "The VideoLAN team <*****@*****.**>\n"
                                "http://www.videolan.org/", _("OK") );
            alert->Go();
            break;
        }
        case TOGGLE_ON_TOP:
            break;

        case OPEN_FILE:
            _ShowFilePanel( B_REFS_RECEIVED, _("VLC media player: Open Media Files") );
            break;

        case LOAD_SUBFILE:
            _ShowFilePanel( SUBFILE_RECEIVED, _("VLC media player: Open Subtitle File") );
            break;
#if 0
        case OPEN_PLAYLIST:
            if (fPlaylistWindow->Lock())
            {
                if (fPlaylistWindow->IsHidden())
                    fPlaylistWindow->Show();
                else
                    fPlaylistWindow->Activate();
                fPlaylistWindow->Unlock();
            }
            break;
#endif
        case OPEN_DVD:
            {
                const char * psz_device;
                if( p_playlist &&
                    p_message->FindString( "device", &psz_device ) == B_OK )
                {
                    char psz_uri[1024];
                    memset( psz_uri, 0, 1024 );
                    snprintf( psz_uri, 1024, "dvdnav:%s", psz_device );
                    playlist_Add( p_playlist, psz_uri, psz_device,
                        PLAYLIST_APPEND | PLAYLIST_GO, PLAYLIST_END, true );
                }
                UpdatePlaylist();
            }
            break;

        case SUBFILE_RECEIVED:
        {
            entry_ref ref;
            if( p_message->FindRef( "refs", 0, &ref ) == B_OK )
            {
                BPath path( &ref );
                if ( path.InitCheck() == B_OK )
                    config_PutPsz( p_intf, "sub-file", path.Path() );
            }
            break;
        }

        case STOP_PLAYBACK:
            if( p_playlist )
            {
                playlist_Stop( p_playlist );
            }
            p_mediaControl->SetStatus(-1, INPUT_RATE_DEFAULT);
            break;

        case START_PLAYBACK:
        case PAUSE_PLAYBACK:
        {
            vlc_value_t val;
            val.i_int = PLAYING_S;
            if( p_input )
            {
                var_Get( p_input, "state", &val );
            }
            if( p_input && val.i_int != PAUSE_S )
            {
                val.i_int = PAUSE_S;
                var_Set( p_input, "state", val );
            }
            else
            {
                playlist_Play( p_playlist );
            }
            break;
        }
        case HEIGHTH_PLAY:
            if( p_input )
            {
                var_SetInteger( p_input, "rate", INPUT_RATE_DEFAULT * 8 );
            }
            break;

        case QUARTER_PLAY:
            if( p_input )
            {
                var_SetInteger( p_input, "rate", INPUT_RATE_DEFAULT * 4 );
            }
            break;

        case HALF_PLAY:
            if( p_input )
            {
                var_SetInteger( p_input, "rate", INPUT_RATE_DEFAULT * 2 );
            }
            break;

        case NORMAL_PLAY:
            if( p_input )
            {
                var_SetInteger( p_input, "rate", INPUT_RATE_DEFAULT );
            }
            break;

        case TWICE_PLAY:
            if( p_input )
            {
                var_SetInteger( p_input, "rate", INPUT_RATE_DEFAULT / 2 );
            }
            break;

        case FOUR_PLAY:
            if( p_input )
            {
                var_SetInteger( p_input, "rate", INPUT_RATE_DEFAULT / 4 );
            }
            break;

        case HEIGHT_PLAY:
            if( p_input )
            {
                var_SetInteger( p_input, "rate", INPUT_RATE_DEFAULT / 8 );
            }
            break;

        case SEEK_PLAYBACK:
            /* handled by semaphores */
            break;

        case VOLUME_CHG:
            aout_VolumeSet( p_intf, p_mediaControl->GetVolume() );
            break;

        case VOLUME_MUTE:
            aout_ToggleMute( p_intf, NULL );
            break;

        case SELECT_CHANNEL:
        {
            int32 channel;
            if( p_input )
            {
                if( p_message->FindInt32( "audio-es", &channel ) == B_OK )
                {
                    var_SetInteger( p_input, "audio-es", channel );
                }
                else if( p_message->FindInt32( "spu-es", &channel ) == B_OK )
                {
                    var_SetInteger( p_input, "spu-es", channel );
                }
            }
            break;
        }

        case PREV_TITLE:
            if( p_input )
            {
                var_TriggerCallback( p_input, "prev-title" );
            }
            break;

        case NEXT_TITLE:
            if( p_input )
            {
                var_TriggerCallback( p_input, "next-title" );
            }
            break;

        case TOGGLE_TITLE:
        {
            int32 index;
            if( p_input &&
                p_message->FindInt32( "index", &index ) == B_OK )
            {
                var_SetInteger( p_input, "title", index );
            }
            break;
        }

        case PREV_CHAPTER:
            if( p_input )
            {
                var_TriggerCallback( p_input, "prev-chapter" );
            }
            break;

        case NEXT_CHAPTER:
            if( p_input )
            {
                var_TriggerCallback( p_input, "next-chapter" );
            }
            break;

        case TOGGLE_CHAPTER:
        {
            int32 index;
            if( p_input &&
                p_message->FindInt32( "index", &index ) == B_OK )
            {
                var_SetInteger( p_input, "chapter", index );
            }
            break;
        }

        case PREV_FILE:
            if( p_playlist )
            {
                playlist_Prev( p_playlist );
            }
            break;

        case NEXT_FILE:
            if( p_playlist )
            {
                playlist_Next( p_playlist );
            }
            break;

        case NAVIGATE_PREV:
            if( p_input )
            {
                vlc_value_t val;

                /* First try to go to previous chapter */
                if( !var_Get( p_input, "chapter", &val ) )
                {
                    if( val.i_int > 1 )
                    {
                        var_TriggerCallback( p_input, "prev-chapter" );
                        break;
                    }
                }

                /* Try to go to previous title */
                if( !var_Get( p_input, "title", &val ) )
                {
                    if( val.i_int > 1 )
                    {
                        var_TriggerCallback( p_input, "prev-title" );
                        break;
                    }
                }

                /* Try to go to previous file */
                if( p_playlist )
                {
                    playlist_Prev( p_playlist );
                }
            }
            break;

        case NAVIGATE_NEXT:
            if( p_input )
            {
                /* First try to go to next chapter */
                if( !var_Get( p_input, "chapter", &val ) )
                {
                    int i_chapter_count = var_CountChoices( p_input, "chapter" );
                    if( i_chapter_count > val.i_int )
                    {
                        var_TriggerCallback( p_input, "next-chapter" );
                        break;
                    }
                }

                /* Try to go to next title */
                if( !var_Get( p_input, "title", &val ) )
                {
                    int i_title_count = var_CountChoices( p_input, "title" );
                    if( i_title_count > val.i_int )
                    {
                        var_TriggerCallback( p_input, "next-title" );
                        break;
                    }
                }

                /* Try to go to next file */
                if( p_playlist )
                {
                    playlist_Next( p_playlist );
                }
            }
            break;

        // drag'n'drop and system messages
        case MSG_SOUNDPLAY:
            // convert soundplay drag'n'drop message (containing paths)
            // to normal message (containing refs)
            {
                const char* path;
                for ( int32 i = 0; p_message->FindString( "path", i, &path ) == B_OK; i++ )
                {
                    entry_ref ref;
                    if ( get_ref_for_path( path, &ref ) == B_OK )
                        p_message->AddRef( "refs", &ref );
                }
            }
            // fall through
        case B_REFS_RECEIVED:
        case B_SIMPLE_DATA:
        {
            /* file(s) opened by the File menu -> append to the playlist;
               file(s) opened by drag & drop -> replace playlist;
               file(s) opened by 'shift' + drag & drop -> append */

            int32 count;
            type_code dummy;
            if( p_message->GetInfo( "refs", &dummy, &count ) != B_OK ||
                count < 1 )
            {
                break;
            }

            bool b_remove = ( p_message->WasDropped() &&
                                    !( modifiers() & B_SHIFT_KEY ) );

            if( b_remove && p_playlist )
            {
                playlist_Clear( p_playlist, true );
            }

            entry_ref ref;
            for( int i = 0; p_message->FindRef( "refs", i, &ref ) == B_OK; i++ )
            {
                BPath path( &ref );

                /* TODO: find out if this is a DVD icon */

                if( p_playlist )
                {
                    playlist_Add( p_playlist, path.Path(), NULL,
                       PLAYLIST_APPEND | PLAYLIST_GO, PLAYLIST_END, true );
                }
            }

            UpdatePlaylist();
            break;
        }

        case OPEN_PREFERENCES:
        {
            if( fPreferencesWindow->Lock() )
            {
                if (fPreferencesWindow->IsHidden())
                    fPreferencesWindow->Show();
                else
                    fPreferencesWindow->Activate();
                fPreferencesWindow->Unlock();
            }
            break;
        }

        case OPEN_MESSAGES:
        {
            if( fMessagesWindow->Lock() )
            {
                if (fMessagesWindow->IsHidden())
                    fMessagesWindow->Show();
                else
                    fMessagesWindow->Activate();
                fMessagesWindow->Unlock();
            }
            break;
        }
        case MSG_UPDATE:
            UpdateInterface();
            break;
        default:
            BWindow::MessageReceived( p_message );
            break;
    }
}