Exemplo n.º 1
0
void libvlc_playlist_prev( libvlc_instance_t *p_instance,
                           libvlc_exception_t *p_e )
{
    if( playlist_Control( PL, PLAYLIST_SKIP, playlist_was_locked( p_instance ),
                          -1  ) != VLC_SUCCESS )
        RAISEVOID( "Empty playlist" );
}
Exemplo n.º 2
0
/********************************************************************
 * Events
 ********************************************************************/
void PlaylistManager::OnActivateItem( wxTreeEvent& event )
{
    playlist_item_t *p_item, *p_node;
    wxTreeItemId parent = treectrl->GetItemParent( event.GetItem() );
    PlaylistItem *p_wxitem = (PlaylistItem *)
        treectrl->GetItemData( event.GetItem() );

    if( !p_wxitem || !parent.IsOk() ) return;

    PlaylistItem *p_wxparent = (PlaylistItem *)treectrl->GetItemData( parent );
    if( !p_wxparent ) return;

    LockPlaylist( p_intf->p_sys, p_playlist );
    p_item = playlist_ItemGetById( p_playlist, p_wxitem->i_id );
    p_node = playlist_ItemGetById( p_playlist, p_wxparent->i_id );
    if( !p_item || p_item->i_children >= 0 )
    {
        p_node = p_item;
        p_item = NULL;
    }

    playlist_Control( p_playlist, PLAYLIST_VIEWPLAY, VIEW_CATEGORY,
                      p_node, p_item );
    UnlockPlaylist( p_intf->p_sys, p_playlist );
}
Exemplo n.º 3
0
void libvlc_playlist_play( libvlc_instance_t *p_instance, int i_id,
                           int i_options, char **ppsz_options,
                           libvlc_exception_t *p_e )
{
    VLC_UNUSED(p_e); VLC_UNUSED(i_options); VLC_UNUSED(ppsz_options);

    int did_lock = 0;
    assert( PL );
    ///\todo Handle additionnal options

    if( PL->items.i_size == 0 ) RAISEVOID( "Empty playlist" );
    if( i_id > 0 )
    {
        playlist_item_t *p_item;
        if (! playlist_was_locked( p_instance ) )
        {
            playlist_mark_locked( p_instance, 1 );
            vlc_object_lock( PL );
            did_lock = 1;
        }

        p_item = playlist_ItemGetByInputId( PL, i_id,
                                            PL->status.p_node );
        if( !p_item )
        {
            if( did_lock == 1 )
            {
                vlc_object_unlock( PL );
                playlist_mark_locked( p_instance, 0 );
            }
            RAISEVOID( "Unable to find item" );
        }

        playlist_Control( PL, PLAYLIST_VIEWPLAY, pl_Locked,
                          PL->status.p_node, p_item );
        if( did_lock == 1 )
        {
            vlc_object_unlock( PL );
            playlist_mark_locked( p_instance, 0 );
        }
    }
    else
    {
        playlist_Control( PL, PLAYLIST_PLAY,
                          playlist_was_locked( p_instance ) );
    }
}
Exemplo n.º 4
0
void libvlc_playlist_stop( libvlc_instance_t *p_instance,
                           libvlc_exception_t *p_e )
{
    assert( PL );
    if( playlist_Control( PL, PLAYLIST_STOP,
                          playlist_was_locked( p_instance ) ) != VLC_SUCCESS )
        RAISEVOID( "Empty playlist" );
}
Exemplo n.º 5
0
static int vlclua_playlist_gotoitem( lua_State * L )
{
    int i_id = luaL_checkinteger( L, 1 );
    playlist_t *p_playlist = vlclua_get_playlist_internal( L );
    PL_LOCK;
    playlist_Control( p_playlist, PLAYLIST_VIEWPLAY, true, NULL,
                      playlist_ItemGetById( p_playlist, i_id ) );
    PL_UNLOCK;
    return vlclua_push_ret( L, VLC_SUCCESS );
}
Exemplo n.º 6
0
void libvlc_playlist_play( libvlc_instance_t *p_instance, int i_id,
                           int i_options, char **ppsz_options )
{
    playlist_t *pl = libvlc_priv (p_instance->p_libvlc_int)->p_playlist;
    VLC_UNUSED(i_id); VLC_UNUSED(i_options); VLC_UNUSED(ppsz_options);

    assert( pl );
    if( pl->items.i_size == 0 )
        return;
    playlist_Control( pl, PLAYLIST_PLAY, false );
}
Exemplo n.º 7
0
void libvlc_InternalPlay(libvlc_int_t *libvlc)
{
    playlist_t *pl;

    vlc_mutex_lock(&lock);
    pl = libvlc_priv(libvlc)->playlist;
    vlc_mutex_unlock(&lock);

    if (pl != NULL && var_GetBool(pl, "playlist-autostart"))
        playlist_Control(pl, PLAYLIST_PLAY, false);
}
Exemplo n.º 8
0
void Playtree::action( VarTree *pElem )
{
    playlist_Lock( m_pPlaylist );

    playlist_item_t *pItem =
        playlist_ItemGetById( m_pPlaylist, pElem->getId() );
    if( pItem )
    {
        playlist_Control( m_pPlaylist, PLAYLIST_VIEWPLAY,
                          pl_Locked, pItem->p_parent, pItem );
    }

    playlist_Unlock( m_pPlaylist );
}
Exemplo n.º 9
0
/** **************************************************************************
 * \brief Add a media to the playlist
 *
 * \param id the item id
 * @todo this code must definitely be done by the ML core
 *****************************************************************************/
static void AddItemToPlaylist( int i_media_id, bool bPlay, media_library_t* p_ml,
        bool bRenew )
{

    input_item_t *p_item = ml_CreateInputItem( p_ml, i_media_id );
    if( !p_item )
    {
        msg_Dbg( p_ml, "unable to create input item for media %d",
                 i_media_id );
        return;
    }
    playlist_t *p_playlist = pl_Get( p_ml );
    playlist_item_t *p_playlist_item = NULL;

    playlist_Lock( p_playlist );
    if( !bRenew )
    {
        p_playlist_item = playlist_ItemGetByInput( p_playlist, p_item );
    }

    if( !p_playlist_item || p_playlist_item->i_id == 1 )
    {
        playlist_AddInput( p_playlist, p_item,
                           PLAYLIST_APPEND,
                           PLAYLIST_END, true, true );

        p_playlist_item = playlist_ItemGetByInput( p_playlist, p_item );
    }
    playlist_Unlock( p_playlist );

    if( !p_playlist_item || p_playlist_item->i_id == 1 )
    {
        msg_Dbg( p_ml, "could not find playlist item %s (%s:%d)",
                 p_item->psz_name, __FILE__, __LINE__ );
        return;
    }

    /* Auto play item */
    if( bPlay ) // || p_playlist->status.i_status == PLAYLIST_STOPPED )
    {
        playlist_Control( p_playlist, PLAYLIST_VIEWPLAY, false,
                          NULL, p_playlist_item );
    }
    vlc_gc_decref( p_item );
}
Exemplo n.º 10
0
	/* Set play time, play, hide this, show concludePreviewButton */
	void FilterWin::preview( Mod * p_mod )
	{
		// require input thread and playlist
		if (p_input == NULL || p_playlist == NULL)
			return;
		// require p_mod
		if (p_mod == NULL)
			p_mod = Moviesoap::p_editingMod;
		if (p_mod == NULL)
			return;
		// dump filter frame to Filter
		filterFrame->dump();
		// calculate start of preview
		mtime_t t_offset = 1000000;
		mtime_t start = p_mod->startTime();
		start = (start > t_offset) ? start - t_offset : 0;
		// change the time and control
		vlc_mutex_lock(&Moviesoap::lock); // todo del?
		var_SetTime( p_input, "time", start );
		vlc_mutex_unlock(&Moviesoap::lock); // todo del?
		playlist_Control( Moviesoap::p_playlist, PLAYLIST_PLAY, false );
		hide();
		concludePreviewButton->show();
	}
Exemplo n.º 11
0
/*****************************************************************************
 * Demux: The important stuff
 *****************************************************************************/
static int Demux( demux_t *p_demux )
{
    playlist_t *p_playlist;
    char       *psz_line;
    playlist_item_t *p_current;
    vlc_bool_t b_play;

    p_playlist = (playlist_t *) vlc_object_find( p_demux, VLC_OBJECT_PLAYLIST,
                                                 FIND_ANYWHERE );
    if( !p_playlist )
    {
        msg_Err( p_demux, "can't find playlist" );
        return -1;
    }

    b_play = E_(FindItem)( p_demux, p_playlist, &p_current );

    playlist_ItemToNode( p_playlist, p_current );
    p_current->input.i_type = ITEM_TYPE_PLAYLIST;

    while( (psz_line = stream_ReadLine( p_demux->s )) )
    {
        playlist_item_t *p_item;
        char **ppsz_options = NULL;
        int  i, i_options = 0;
        char *psz_name = NULL;

        if( !ParseLine( psz_line, &psz_name, &ppsz_options, &i_options ) )
        {
            free( psz_line );
            continue;
        }

        EnsureUTF8( psz_name );

        p_item = playlist_ItemNew( p_playlist, "dvb:", psz_name );
        for( i = 0; i< i_options; i++ )
        {
            EnsureUTF8( ppsz_options[i] );
            playlist_ItemAddOption( p_item, ppsz_options[i] );
        }
        playlist_NodeAddItem( p_playlist, p_item,
                              p_current->pp_parents[0]->i_view,
                              p_current, PLAYLIST_APPEND, PLAYLIST_END );

        /* We need to declare the parents of the node as the
         *                  * same of the parent's ones */
        playlist_CopyParents( p_current, p_item );
        vlc_input_item_CopyOptions( &p_current->input, &p_item->input );

        while( i_options-- ) free( ppsz_options[i_options] );
        if( ppsz_options ) free( ppsz_options );

        free( psz_line );
    }

    /* Go back and play the playlist */
    if( b_play && p_playlist->status.p_item &&
        p_playlist->status.p_item->i_children > 0 )
    {
        playlist_Control( p_playlist, PLAYLIST_VIEWPLAY,
                          p_playlist->status.i_view,
                          p_playlist->status.p_item,
                          p_playlist->status.p_item->pp_children[0] );
    }

    vlc_object_release( p_playlist );
    return VLC_SUCCESS;
}
Exemplo n.º 12
0
Arquivo: item.c Projeto: BossKing/vlc
static void input_item_add_subitem_tree ( const vlc_event_t * p_event,
                                          void * user_data )
{
    input_item_t *p_input = p_event->p_obj;
    playlist_t *p_playlist = (( playlist_item_t* ) user_data)->p_playlist;
    input_item_node_t *p_new_root = p_event->u.input_item_subitem_tree_added.p_root;

    PL_LOCK;

    playlist_item_t *p_item =
        playlist_ItemGetByInput( p_playlist, p_input );

    assert( p_item != NULL );

    bool b_current = get_current_status_item( p_playlist ) == p_item;
    bool b_autostart = var_GetBool( p_playlist, "playlist-autostart" );
    bool b_stop = p_item->i_flags & PLAYLIST_SUBITEM_STOP_FLAG;
    bool b_flat = false;

    p_item->i_flags &= ~PLAYLIST_SUBITEM_STOP_FLAG;

    /* We will have to flatten the tree out if we are in "the playlist" node and
    the user setting demands flat playlist */

    if( !pl_priv(p_playlist)->b_tree ) {
        playlist_item_t *p_up = p_item;
        while( p_up->p_parent )
        {
            if( p_up->p_parent == p_playlist->p_playing )
            {
                b_flat = true;
                break;
            }
            p_up = p_up->p_parent;
        }
    }

    int pos = 0;

    /* If we have to flatten out, then take the item's position in the parent as
    insertion point and delete the item */

    if( b_flat )
    {
        playlist_item_t *p_parent = p_item->p_parent;
        assert( p_parent != NULL );

        int i;
        for( i = 0; i < p_parent->i_children; i++ )
        {
            if( p_parent->pp_children[i] == p_item )
            {
                pos = i;
                break;
            }
        }
        assert( i < p_parent->i_children );

        playlist_DeleteItem( p_playlist, p_item, true );

        p_item = p_parent;
    }
    else
    {
        pos = p_item->i_children >= 0 ? p_item->i_children : 0;
    }

    /* At this point:
    "p_item" is the node where sub-items should be inserted,
    "pos" is the insertion position in that node */

    int last_pos = playlist_InsertInputItemTree( p_playlist,
                                                 p_item,
                                                 p_new_root,
                                                 pos,
                                                 b_flat );

    if( !b_flat ) var_SetInteger( p_playlist, "leaf-to-parent", p_item->i_id );

    //control playback only if it was the current playing item that got subitems
    if( b_current )
    {
        if( last_pos == pos || ( b_stop && !b_flat ) || !b_autostart )
        {
            /* We stop, either because no sub-item was actually created, or some
            flags/settings want us to do so at this point */
            PL_UNLOCK;
            playlist_Stop( p_playlist );
            return;
        }
        else
        {
            /* Continue to play, either random or the first new item */
            playlist_item_t *p_play_item;

            if( var_GetBool( p_playlist, "random" ) )
            {
                p_play_item = NULL;
            }
            else
            {
                /* Don't Play a directory if it can loop into a parent */
                if( p_new_root->b_can_loop )
                {
                    /* Play the first regular file */
                    for( ; pos < last_pos; pos++ )
                    {
                        if( p_item->pp_children[pos]->p_input->i_type != ITEM_TYPE_DIRECTORY )
                            break;
                    }
                    if( last_pos == pos )
                    {
                        PL_UNLOCK;
                        playlist_Stop( p_playlist );
                        return;
                    }
                }
                p_play_item = p_item->pp_children[pos];
                /* NOTE: this is a work around the general bug:
                if node-to-be-played contains sub-nodes, then second instead
                of first leaf starts playing (only in case the leafs have just
                been instered and playlist has not yet been rebuilt.)
                */
                while( p_play_item->i_children > 0 )
                    p_play_item = p_play_item->pp_children[0];
            }

            playlist_Control( p_playlist, PLAYLIST_VIEWPLAY,
                                  pl_Locked,
                                  get_current_status_node( p_playlist ),
                                  p_play_item );
        }
    }

    PL_UNLOCK;
}
Exemplo n.º 13
0
static int Demux( demux_t *p_demux )
{
    mtime_t        i_duration = -1;
    char          *psz_name = NULL;
    char          *psz_line;
    char          *psz_mrl = NULL;
    char          *psz_key;
    char          *psz_value;
    playlist_t    *p_playlist;
    int            i_position;
    int            i_item = -1;
    int            i_new_item = 0;
    int            i_key_length;
    playlist_item_t *p_parent;
    vlc_bool_t b_play;

    p_playlist = (playlist_t *) vlc_object_find( p_demux, VLC_OBJECT_PLAYLIST,
                                                 FIND_ANYWHERE );
    if( !p_playlist )
    {
        msg_Err( p_demux, "can't find playlist" );
        return -1;
    }

    b_play = E_(FindItem)( p_demux, p_playlist, &p_parent );
    p_parent->input.i_type = ITEM_TYPE_PLAYLIST;

    /* Change the item to a node */
    if( p_parent->i_children == -1)
    {
        playlist_ItemToNode( p_playlist,p_parent );
    }

    while( ( psz_line = stream_ReadLine( p_demux->s ) ) )
    {
        if( !strncasecmp( psz_line, "[playlist]", sizeof("[playlist]")-1 ) )
        {
            free( psz_line );
            continue;
        }
        psz_key = psz_line;
        psz_value = strchr( psz_line, '=' );
        if( psz_value )
        {
            *psz_value='\0';
            psz_value++;
        }
        else
        {
            msg_Warn( p_demux, "invalid line in pls file" );
            free( psz_line );
            continue;
        }
        if( !strcasecmp( psz_key, "version" ) )
        {
            msg_Dbg( p_demux, "pls file version: %s", psz_value );
            free( psz_line );
            continue;
        }
        /* find the number part of of file1, title1 or length1 etc */
        i_key_length = strlen( psz_key );
        if( i_key_length >= 5 ) /* file1 type case */
        {
            i_new_item = atoi( psz_key + 4 );
            if( i_new_item == 0 && i_key_length >= 6 ) /* title1 type case */
            {
                i_new_item = atoi( psz_key + 5 );
                if( i_new_item == 0 && i_key_length >= 7 ) /* length1 type case */
                {
                    i_new_item = atoi( psz_key + 6 );
                }
            }
        }
        if( i_new_item == 0 )
        {
            msg_Warn( p_demux, "couldn't find number of items" );
            free( psz_line );
            continue;
        }
        if( i_item == -1 )
        {
            i_item = i_new_item;
        }
        /* we found a new item, insert the previous */
        if( i_item != i_new_item )
        {
            if( psz_mrl )
            {
                playlist_item_t *p_item = playlist_ItemNew( p_playlist, psz_mrl,
                                                            psz_name );

                playlist_NodeAddItem( p_playlist,p_item,
                                      p_parent->pp_parents[0]->i_view,
                                      p_parent,
                                      PLAYLIST_APPEND, PLAYLIST_END );

                playlist_CopyParents( p_parent, p_item );
                if( i_duration != -1 )
                {
                    //playlist_SetDuration( p_playlist, i_position, i_duration );
                }
                i_position++;
                free( psz_mrl );
                psz_mrl = NULL;

                vlc_input_item_CopyOptions( &p_parent->input,
                                            &p_item->input );
            }
            else
            {
                msg_Warn( p_demux, "no file= part found for item %d", i_item );
            }
            if( psz_name )
            {
                free( psz_name );
                psz_name = NULL;
            }
            i_duration = -1;
            i_item = i_new_item;
            i_new_item = 0;
        }
        if( !strncasecmp( psz_key, "file", sizeof("file") -1 ) )
        {
            psz_mrl = E_(ProcessMRL)( psz_value, p_demux->p_sys->psz_prefix );
        }
        else if( !strncasecmp( psz_key, "title", sizeof("title") -1 ) )
        {
            psz_name = strdup( psz_value );
        }
        else if( !strncasecmp( psz_key, "length", sizeof("length") -1 ) )
        {
            i_duration = atoi( psz_value );
            if( i_duration != -1 )
            {
                i_duration *= 1000000;
            }
        }
        else
        {
            msg_Warn( p_demux, "unknown key found in pls file: %s", psz_key );
        }
        free( psz_line );
    }
    /* Add last object */
    if( psz_mrl )
    {
        playlist_item_t *p_item = playlist_ItemNew( p_playlist, psz_mrl,
                                                    psz_name );

        playlist_NodeAddItem( p_playlist,p_item,
                              p_parent->pp_parents[0]->i_view,
                              p_parent,
                              PLAYLIST_APPEND, PLAYLIST_END );

        playlist_CopyParents( p_parent, p_item );
        if( i_duration != -1 )
        {
            //playlist_SetDuration( p_playlist, i_position, i_duration );
        }
        free( psz_mrl );
        psz_mrl = NULL;

        vlc_input_item_CopyOptions( &p_parent->input,
                                    &p_item->input );
    }
    else
    {
        msg_Warn( p_demux, "no file= part found for item %d", i_item );
    }
    if( psz_name )
    {
        free( psz_name );
        psz_name = NULL;
    }

    if( b_play && p_playlist->status.p_item &&
        p_playlist->status.p_item->i_children > 0 )
    {
        playlist_Control( p_playlist, PLAYLIST_VIEWPLAY,
                          p_playlist->status.i_view,
                          p_playlist->status.p_item,
                          p_playlist->status.p_item->pp_children[0] );
    }
    vlc_object_release( p_playlist );
    return VLC_SUCCESS;
}
Exemplo n.º 14
0
void CmdPlaylistFirst::execute()
{
    playlist_Control(getPL(), PLAYLIST_PLAY, pl_Unlocked);
}
Exemplo n.º 15
0
static LRESULT HandleCadMessage(intf_thread_t* p_intf, HWND hwnd, WPARAM wParam, LPARAM lParam)
{
	intf_sys_t* const p_sys = p_intf->p_sys;

	switch (lParam)
	{
	case IPC_PLAY:
		{
			playlist_Play(pl_Get(p_intf->p_libvlc));
			return 1;
		}

	case IPC_PLAYPAUSE:
		{
			playlist_t* p_playlist = pl_Get(p_intf->p_libvlc);
			const bool playing = playlist_Status(p_playlist) == PLAYLIST_RUNNING;
			playlist_Control(p_playlist, playing ? PLAYLIST_PAUSE : PLAYLIST_PLAY, pl_Unlocked);
			return 1;
		}

	case IPC_PAUSE:
		{
			playlist_Pause(pl_Get(p_intf->p_libvlc));
			return 1;
		}

	case IPC_STOP:
		{
			playlist_Stop(pl_Get(p_intf->p_libvlc));
			return 1;
		}
			
	case IPC_NEXT:
		{
			playlist_Next(pl_Get(p_intf->p_libvlc));
			return 1;
		}

	case IPC_PREVIOUS:
		{
			playlist_Prev(pl_Get(p_intf->p_libvlc));
			return 1;
		}

	case IPC_SET_VOLUME:
		{
			playlist_VolumeSet(pl_Get(p_intf->p_libvlc), (int)wParam / 100.0f);
			return 1;
		}

	case IPC_GET_VOLUME:
		{
			// VLC can return a volume larger than 100% so we need to cap it to 100 here.
			const float volume = playlist_VolumeGet(pl_Get(p_intf->p_libvlc)) * 100.0f;
			return (LRESULT)min(volume, 100.0f);
		}

	case IPC_GET_DURATION:
		{
			unsigned int duration = 0;
			if (p_sys->p_input)
			{
				input_item_t* const p_item = input_GetItem(p_sys->p_input);
				duration = (unsigned int)(input_item_GetDuration(p_item) / 1000000);
			}
			return duration;
		}

	case IPC_GET_POSITION:
		{
			int pos = 0;
			if (p_sys->p_input)
			{
				pos = (int)(var_GetTime(p_sys->p_input, "time") / CLOCK_FREQ);
			}
			return pos;
		}

	case IPC_SET_POSITION:
		{
			if (p_sys->p_input)
			{
				var_SetTime(p_sys->p_input, "time", (int64_t)wParam * CLOCK_FREQ);
			}
			return 0;
		}

	case IPC_GET_SHUFFLE:
		{
			return (int)var_GetBool(pl_Get(p_intf->p_libvlc), "random");
		}

	case IPC_SET_SHUFFLE:
		{
			return (int)var_SetBool(pl_Get(p_intf->p_libvlc), "random", (bool)wParam);
		}

	case IPC_GET_REPEAT:
		{
			return (int)var_GetBool(pl_Get(p_intf->p_libvlc), "repeat");
		}

	case IPC_SET_REPEAT:
		{
			return (int)var_SetBool(pl_Get(p_intf->p_libvlc), "repeat", (bool)wParam);
		}

	case IPC_SET_RATING:
		{
			// VLC does not support ratings so send back 0.
			PostMessage(p_sys->cad_window, WM_USER, 0, IPC_RATING_CHANGED_NOTIFICATION);
			return 0;
		}

	case IPC_SET_CALLBACK_HWND:
		{
			p_sys->cad_window = (HWND)wParam;
			return 1;
		}

	case IPC_SHOW_WINDOW:
		{
			// TODO.
			return 0;
		}

	case IPC_GET_STATE:
		{
			const int status = playlist_Status(pl_Get(p_intf->p_libvlc));
			return
				status == PLAYLIST_RUNNING ? 1 :
				status == PLAYLIST_PAUSED ? 2 :
				0;
		}

	case IPC_SHUTDOWN_NOTIFICATION:
		{
			p_sys->cad_window = NULL;
			return 1;
		}

	case IPC_CLOSE:
		{
			libvlc_Quit(p_intf->p_libvlc);
			return 1;
		}

	case IPC_GET_CURRENT_TRACK:
		{
			if (!p_sys->p_input) return 0;
			input_item_t* p_item = input_GetItem(p_sys->p_input);

			char buffer[DATA_MAX_LENGTH];
			int buffer_len = 0;

			// If the i sstarts with file://, we assume that it is a local file and detailed
			// metadata is available. Otherwise, we assume it to be a network stream (i.e. radio)
			// with limited info (only a title).
			char* const file = decode_URI(input_item_GetURI(p_item));
			if (strncmp(file, "file://", 7) == 0)
			{
				char* const title = input_item_GetTitleFbName(p_item);
				char* const artist = input_item_GetArtist(p_item);
				char* const album = input_item_GetAlbum(p_item);
				char* const cover = decode_URI(input_item_GetArtworkURL(p_item));
				const unsigned int duration = input_item_GetDuration(p_item) / 1000000U;

				buffer_len = _snprintf(
					buffer, ARRAYSIZE(buffer), "%s\t%s\t%s\t\t\t\t\t%u\t%s\t\t%s\t\t\t\t\t\t\t",
					title ? title : "",
					artist ? artist : "",
					album ? album : "",
					duration,
					file ? &file[8] : "",
					cover ? &cover[8] : "");  // Skip the "file://" part.

				free(title);
				free(artist);
				free(album);
				free(cover);
			}
			else if (char* now_playing = input_item_GetNowPlaying(p_item))
			{
				char* artist = NULL;
				char* title = now_playing;
				char* pos = strstr(now_playing, " - ");
				if (pos)
				{
					pos[0] = '\0';
					artist = title;
					title = pos + 3;	// Skip the " - "
				}

				buffer_len = _snprintf(
					buffer, ARRAYSIZE(buffer), "%s\t%s\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t",
					title ? title : "",
					artist ? artist : "");

				free(now_playing);
			}

			free(file);

			if (buffer_len)
			{
				wchar_t buffer_w[DATA_MAX_LENGTH];
				const int buffer_w_len = MultiByteToWideChar(
					CP_UTF8, 0, buffer, buffer_len + 1, buffer_w, ARRAYSIZE(buffer_w));

				COPYDATASTRUCT cds;
				cds.dwData = IPC_CURRENT_TRACK_NOTIFICATION;
				cds.lpData = &buffer_w;
				cds.cbData = buffer_w_len * sizeof(buffer_w[0]);
				SendMessage(
					p_sys->cad_window, WM_COPYDATA, IPC_CURRENT_TRACK_NOTIFICATION, (LPARAM)&cds);
			}

			return 1;
		}
	}

	return 0;
}
Exemplo n.º 16
0
Arquivo: rpn.c Projeto: Kafay/vlc
void EvaluateRPN( intf_thread_t *p_intf, mvar_t  *vars,
                      rpn_stack_t *st, char *exp )
{
    intf_sys_t    *p_sys = p_intf->p_sys;

    while( exp != NULL && *exp != '\0' )
    {
        char *p, *s;

        /* skip space */
        while( *exp == ' ' )
        {
            exp++;
        }

        if( *exp == '\'' )
        {
            /* extract string */
            p = FirstWord( exp, exp );
            SSPush( st, exp );
            exp = p;
            continue;
        }

        /* extract token */
        p = FirstWord( exp, exp );
        s = exp;
        if( p == NULL )
        {
            exp += strlen( exp );
        }
        else
        {
            exp = p;
        }

        if( *s == '\0' )
        {
            break;
        }

        /* 1. Integer function */
        if( !strcmp( s, "!" ) )
        {
            SSPushN( st, ~SSPopN( st, vars ) );
        }
        else if( !strcmp( s, "^" ) )
        {
            SSPushN( st, SSPopN( st, vars ) ^ SSPopN( st, vars ) );
        }
        else if( !strcmp( s, "&" ) )
        {
            SSPushN( st, SSPopN( st, vars ) & SSPopN( st, vars ) );
        }
        else if( !strcmp( s, "|" ) )
        {
            SSPushN( st, SSPopN( st, vars ) | SSPopN( st, vars ) );
        }
        else if( !strcmp( s, "+" ) )
        {
            SSPushN( st, SSPopN( st, vars ) + SSPopN( st, vars ) );
        }
        else if( !strcmp( s, "-" ) )
        {
            int j = SSPopN( st, vars );
            int i = SSPopN( st, vars );
            SSPushN( st, i - j );
        }
        else if( !strcmp( s, "*" ) )
        {
            SSPushN( st, SSPopN( st, vars ) * SSPopN( st, vars ) );
        }
        else if( !strcmp( s, "/" ) )
        {
            int i, j;

            j = SSPopN( st, vars );
            i = SSPopN( st, vars );

            SSPushN( st, j != 0 ? i / j : 0 );
        }
        else if( !strcmp( s, "%" ) )
        {
            int i, j;

            j = SSPopN( st, vars );
            i = SSPopN( st, vars );

            SSPushN( st, j != 0 ? i % j : 0 );
        }
        /* 2. integer tests */
        else if( !strcmp( s, "=" ) )
        {
            SSPushN( st, SSPopN( st, vars ) == SSPopN( st, vars ) ? -1 : 0 );
        }
        else if( !strcmp( s, "!=" ) )
        {
            SSPushN( st, SSPopN( st, vars ) != SSPopN( st, vars ) ? -1 : 0 );
        }
        else if( !strcmp( s, "<" ) )
        {
            int j = SSPopN( st, vars );
            int i = SSPopN( st, vars );

            SSPushN( st, i < j ? -1 : 0 );
        }
        else if( !strcmp( s, ">" ) )
        {
            int j = SSPopN( st, vars );
            int i = SSPopN( st, vars );

            SSPushN( st, i > j ? -1 : 0 );
        }
        else if( !strcmp( s, "<=" ) )
        {
            int j = SSPopN( st, vars );
            int i = SSPopN( st, vars );

            SSPushN( st, i <= j ? -1 : 0 );
        }
        else if( !strcmp( s, ">=" ) )
        {
            int j = SSPopN( st, vars );
            int i = SSPopN( st, vars );

            SSPushN( st, i >= j ? -1 : 0 );
        }
        /* 3. string functions */
        else if( !strcmp( s, "strcat" ) )
        {
            char *s2 = SSPop( st );
            char *s1 = SSPop( st );
            char *str = malloc( strlen( s1 ) + strlen( s2 ) + 1 );

            strcpy( str, s1 );
            strcat( str, s2 );

            SSPush( st, str );
            free( s1 );
            free( s2 );
            free( str );
        }
        else if( !strcmp( s, "strcmp" ) )
        {
            char *s2 = SSPop( st );
            char *s1 = SSPop( st );

            SSPushN( st, strcmp( s1, s2 ) );
            free( s1 );
            free( s2 );
        }
        else if( !strcmp( s, "strncmp" ) )
        {
            int n = SSPopN( st, vars );
            char *s2 = SSPop( st );
            char *s1 = SSPop( st );

            SSPushN( st, strncmp( s1, s2 , n ) );
            free( s1 );
            free( s2 );
        }
        else if( !strcmp( s, "strsub" ) )
        {
            int n = SSPopN( st, vars );
            int m = SSPopN( st, vars );
            int i_len;
            char *s = SSPop( st );
            char *str;

            if( n >= m )
            {
                i_len = n - m + 1;
            }
            else
            {
                i_len = 0;
            }

            str = malloc( i_len + 1 );

            memcpy( str, s + m - 1, i_len );
            str[ i_len ] = '\0';

            SSPush( st, str );
            free( s );
            free( str );
        }
        else if( !strcmp( s, "strlen" ) )
        {
            char *str = SSPop( st );

            SSPushN( st, strlen( str ) );
            free( str );
        }
        else if( !strcmp( s, "str_replace" ) )
        {
            char *psz_to = SSPop( st );
            char *psz_from = SSPop( st );
            char *psz_in = SSPop( st );
            char *psz_in_current = psz_in;
            char *psz_out = malloc( strlen(psz_in) * strlen(psz_to) + 1 );
            char *psz_out_current = psz_out;

            while( (p = strstr( psz_in_current, psz_from )) != NULL )
            {
                memcpy( psz_out_current, psz_in_current, p - psz_in_current );
                psz_out_current += p - psz_in_current;
                strcpy( psz_out_current, psz_to );
                psz_out_current += strlen(psz_to);
                psz_in_current = p + strlen(psz_from);
            }
            strcpy( psz_out_current, psz_in_current );
            psz_out_current += strlen(psz_in_current);
            *psz_out_current = '\0';

            SSPush( st, psz_out );
            free( psz_to );
            free( psz_from );
            free( psz_in );
            free( psz_out );
        }
        else if( !strcmp( s, "url_extract" ) )
        {
            const char *url = mvar_GetValue( vars, "url_value" );
            char *name = SSPop( st );
            char *value = ExtractURIString( url, name );
            if( value != NULL )
            {
                decode_URI( value );
                SSPush( st, value );
                free( value );
            }
            else
                SSPush( st, "" );

            free( name );
        }
        else if( !strcmp( s, "url_encode" ) )
        {
            char *url = SSPop( st );
            char *value = vlc_UrlEncode( url );
            free( url );
            SSPush( st, value );
            free( value );
        }
        else if( !strcmp( s, "xml_encode" )
              || !strcmp( s, "htmlspecialchars" ) )
        {
            char *url = SSPop( st );
            char *value = convert_xml_special_chars( url );
            free( url );
            SSPush( st, value );
            free( value );
        }
        else if( !strcmp( s, "addslashes" ) )
        {
            char *psz_src = SSPop( st );
            char *psz_dest;
            char *str = psz_src;

            p = psz_dest = malloc( strlen( str ) * 2 + 1 );

            while( *str != '\0' )
            {
                if( *str == '"' || *str == '\'' || *str == '\\' )
                {
                    *p++ = '\\';
                }
                *p++ = *str;
                str++;
            }
            *p = '\0';

            SSPush( st, psz_dest );
            free( psz_src );
            free( psz_dest );
        }
        else if( !strcmp( s, "stripslashes" ) )
        {
            char *psz_src = SSPop( st );
            char *psz_dest;
            char *str = psz_src;

            p = psz_dest = strdup( psz_src );

            while( *str )
            {
                if( *str == '\\' && *(str + 1) )
                {
                    str++;
                }
                *p++ = *str++;
            }
            *p = '\0';

            SSPush( st, psz_dest );
            free( psz_src );
            free( psz_dest );
        }
        else if( !strcmp( s, "realpath" ) )
        {
            char *psz_src = SSPop( st );
            char *psz_dir = RealPath( psz_src );

            SSPush( st, psz_dir );
            free( psz_src );
            free( psz_dir );
        }
        /* 4. stack functions */
        else if( !strcmp( s, "dup" ) )
        {
            char *str = SSPop( st );
            SSPush( st, str );
            SSPush( st, str );
            free( str );
        }
        else if( !strcmp( s, "drop" ) )
        {
            char *str = SSPop( st );
            free( str );
        }
        else if( !strcmp( s, "swap" ) )
        {
            char *s1 = SSPop( st );
            char *s2 = SSPop( st );

            SSPush( st, s1 );
            SSPush( st, s2 );
            free( s1 );
            free( s2 );
        }
        else if( !strcmp( s, "flush" ) )
        {
            SSClean( st );
            SSInit( st );
        }
        else if( !strcmp( s, "store" ) )
        {
            char *value = SSPop( st );
            char *name  = SSPop( st );

            mvar_PushNewVar( vars, name, value );
            free( name );
            free( value );
        }
        else if( !strcmp( s, "value" ) )
        {
            char *name  = SSPop( st );
            const char *value = mvar_GetValue( vars, name );

            SSPush( st, value );

            free( name );
        }
        /* 5. player control */
        else if( !strcmp( s, "vlc_play" ) )
        {
            int i_id = SSPopN( st, vars );
            int i_ret;

            playlist_Lock( p_sys->p_playlist );
            i_ret = playlist_Control( p_sys->p_playlist, PLAYLIST_VIEWPLAY,
                                      pl_Locked, NULL,
                                      playlist_ItemGetById( p_sys->p_playlist,
                                      i_id ) );
            playlist_Unlock( p_sys->p_playlist );
            msg_Dbg( p_intf, "requested playlist item: %i", i_id );
            SSPushN( st, i_ret );
        }
        else if( !strcmp( s, "vlc_stop" ) )
        {
            playlist_Control( p_sys->p_playlist, PLAYLIST_STOP, pl_Unlocked );
            msg_Dbg( p_intf, "requested playlist stop" );
        }
        else if( !strcmp( s, "vlc_pause" ) )
        {
            playlist_Control( p_sys->p_playlist, PLAYLIST_PAUSE, pl_Unlocked );
            msg_Dbg( p_intf, "requested playlist pause" );
        }
        else if( !strcmp( s, "vlc_next" ) )
        {
            playlist_Control( p_sys->p_playlist, PLAYLIST_SKIP, pl_Unlocked, 1 );
            msg_Dbg( p_intf, "requested playlist next" );
        }
        else if( !strcmp( s, "vlc_previous" ) )
        {
            playlist_Control( p_sys->p_playlist, PLAYLIST_SKIP, pl_Unlocked, -1 );
            msg_Dbg( p_intf, "requested playlist previous" );
        }
        else if( !strcmp( s, "vlc_seek" ) )
        {
            char *psz_value = SSPop( st );
            HandleSeek( p_intf, psz_value );
            msg_Dbg( p_intf, "requested playlist seek: %s", psz_value );
            free( psz_value );
        }
        else if( !strcmp( s, "vlc_var_type" )
                  || !strcmp( s, "vlc_config_type" ) )
        {
            vlc_object_t *p_object;
            const char *psz_type = NULL;
            int i_type = 0;

            if( !strcmp( s, "vlc_var_type" ) )
            {
                char *psz_object = SSPop( st );
                char *psz_variable = SSPop( st );
                bool b_need_release;

                p_object = GetVLCObject( p_intf, psz_object, &b_need_release );

                if( p_object != NULL )
                    i_type = var_Type( p_object, psz_variable );
                free( psz_variable );
                free( psz_object );
                if( b_need_release && p_object != NULL )
                    vlc_object_release( p_object );
            }
            else
            {
                char *psz_variable = SSPop( st );
                p_object = VLC_OBJECT(p_intf);
                i_type = config_GetType( p_object, psz_variable );
                free( psz_variable );
            }

            if( p_object != NULL )
            {
                switch( i_type & VLC_VAR_TYPE )
                {
                case VLC_VAR_BOOL:
                    psz_type = "VLC_VAR_BOOL";
                    break;
                case VLC_VAR_INTEGER:
                    psz_type = "VLC_VAR_INTEGER";
                    break;
                case VLC_VAR_HOTKEY:
                    psz_type = "VLC_VAR_HOTKEY";
                    break;
                case VLC_VAR_STRING:
                    psz_type = "VLC_VAR_STRING";
                    break;
                case VLC_VAR_MODULE:
                    psz_type = "VLC_VAR_MODULE";
                    break;
                case VLC_VAR_FILE:
                    psz_type = "VLC_VAR_FILE";
                    break;
                case VLC_VAR_DIRECTORY:
                    psz_type = "VLC_VAR_DIRECTORY";
                    break;
                case VLC_VAR_VARIABLE:
                    psz_type = "VLC_VAR_VARIABLE";
                    break;
                case VLC_VAR_FLOAT:
                    psz_type = "VLC_VAR_FLOAT";
                    break;
                default:
                    psz_type = "UNDEFINED";
                }
            }
            else
                psz_type = "INVALID";

            SSPush( st, psz_type );
        }
        else if( !strcmp( s, "vlc_var_set" ) )
        {
            char *psz_object = SSPop( st );
            char *psz_variable = SSPop( st );
            bool b_need_release;

            vlc_object_t *p_object = GetVLCObject( p_intf, psz_object,
                                                   &b_need_release );

            if( p_object != NULL )
            {
                bool b_error = false;
                char *psz_value = NULL;
                vlc_value_t val;
                int i_type;

                i_type = var_Type( p_object, psz_variable );

                switch( i_type & VLC_VAR_TYPE )
                {
                case VLC_VAR_BOOL:
                    val.b_bool = SSPopN( st, vars );
                    msg_Dbg( p_intf, "requested %s var change: %s->%d",
                             psz_object, psz_variable, val.b_bool );
                    break;
                case VLC_VAR_INTEGER:
                case VLC_VAR_HOTKEY:
                    val.i_int = SSPopN( st, vars );
                    msg_Dbg( p_intf, "requested %s var change: %s->%d",
                             psz_object, psz_variable, val.i_int );
                    break;
                case VLC_VAR_STRING:
                case VLC_VAR_MODULE:
                case VLC_VAR_FILE:
                case VLC_VAR_DIRECTORY:
                case VLC_VAR_VARIABLE:
                    val.psz_string = psz_value = SSPop( st );
                    msg_Dbg( p_intf, "requested %s var change: %s->%s",
                             psz_object, psz_variable, psz_value );
                    break;
                case VLC_VAR_FLOAT:
                    psz_value = SSPop( st );
                    val.f_float = atof( psz_value );
                    msg_Dbg( p_intf, "requested %s var change: %s->%f",
                             psz_object, psz_variable, val.f_float );
                    break;
                default:
                    SSPopN( st, vars );
                    msg_Warn( p_intf, "invalid %s variable type %d (%s)",
                              psz_object, i_type & VLC_VAR_TYPE, psz_variable );
                    b_error = true;
                }

                if( !b_error )
                    var_Set( p_object, psz_variable, val );
                if( psz_value != NULL )
                    free( psz_value );
            }
            else
                msg_Warn( p_intf, "vlc_var_set called without an object" );
            free( psz_variable );
            free( psz_object );

            if( b_need_release && p_object != NULL )
                vlc_object_release( p_object );
        }
        else if( !strcmp( s, "vlc_var_get" ) )
        {
            char *psz_object = SSPop( st );
            char *psz_variable = SSPop( st );
            bool b_need_release;

            vlc_object_t *p_object = GetVLCObject( p_intf, psz_object,
                                                   &b_need_release );

            if( p_object != NULL )
            {
                vlc_value_t val;
                int i_type;

                i_type = var_Type( p_object, psz_variable );
                var_Get( p_object, psz_variable, &val );

                switch( i_type & VLC_VAR_TYPE )
                {
                case VLC_VAR_BOOL:
                    SSPushN( st, val.b_bool );
                    break;
                case VLC_VAR_INTEGER:
                case VLC_VAR_HOTKEY:
                    SSPushN( st, val.i_int );
                    break;
                case VLC_VAR_STRING:
                case VLC_VAR_MODULE:
                case VLC_VAR_FILE:
                case VLC_VAR_DIRECTORY:
                case VLC_VAR_VARIABLE:
                    SSPush( st, val.psz_string );
                    free( val.psz_string );
                    break;
                case VLC_VAR_FLOAT:
                {
                    char psz_value[20];
                    lldiv_t value = lldiv( val.f_float * 1000000, 1000000 );
                    snprintf( psz_value, sizeof(psz_value), "%lld.%06u",
                                    value.quot, (unsigned int)value.rem );
                    SSPush( st, psz_value );
                    break;
                }
                default:
                    msg_Warn( p_intf, "invalid %s variable type %d (%s)",
                              psz_object, i_type & VLC_VAR_TYPE, psz_variable );
                    SSPush( st, "" );
                }
            }
            else
            {
                msg_Warn( p_intf, "vlc_var_get called without an object" );
                SSPush( st, "" );
            }
            free( psz_variable );
            free( psz_object );

            if( b_need_release && p_object != NULL )
                vlc_object_release( p_object );
        }
        else if( !strcmp( s, "vlc_object_exists" ) )
        {
            char *psz_object = SSPop( st );
            bool b_need_release;

            vlc_object_t *p_object = GetVLCObject( p_intf, psz_object,
                                                   &b_need_release );
            if( b_need_release && p_object != NULL )
                vlc_object_release( p_object );

            if( p_object != NULL )
                SSPush( st, "1" );
            else
                SSPush( st, "0" );
        }
        else if( !strcmp( s, "vlc_config_set" ) )
        {
            char *psz_variable = SSPop( st );
            int i_type = config_GetType( p_intf, psz_variable );

            switch( i_type & VLC_VAR_TYPE )
            {
            case VLC_VAR_BOOL:
            case VLC_VAR_INTEGER:
                config_PutInt( p_intf, psz_variable, SSPopN( st, vars ) );
                break;
            case VLC_VAR_STRING:
            case VLC_VAR_MODULE:
            case VLC_VAR_FILE:
            case VLC_VAR_DIRECTORY:
            {
                char *psz_string = SSPop( st );
                config_PutPsz( p_intf, psz_variable, psz_string );
                free( psz_string );
                break;
            }
            case VLC_VAR_FLOAT:
            {
                char *psz_string = SSPop( st );
                config_PutFloat( p_intf, psz_variable, atof(psz_string) );
                free( psz_string );
                break;
            }
            default:
                msg_Warn( p_intf, "vlc_config_set called on unknown var (%s)",
                          psz_variable );
            }
            free( psz_variable );
        }
        else if( !strcmp( s, "vlc_config_get" ) )
        {
            char *psz_variable = SSPop( st );
            int i_type = config_GetType( p_intf, psz_variable );

            switch( i_type & VLC_VAR_TYPE )
            {
            case VLC_VAR_BOOL:
            case VLC_VAR_INTEGER:
                SSPushN( st, config_GetInt( p_intf, psz_variable ) );
                break;
            case VLC_VAR_STRING:
            case VLC_VAR_MODULE:
            case VLC_VAR_FILE:
            case VLC_VAR_DIRECTORY:
            {
                char *psz_string = config_GetPsz( p_intf, psz_variable );
                SSPush( st, psz_string );
                free( psz_string );
                break;
            }
            case VLC_VAR_FLOAT:
            {
                char psz_string[20];
                lldiv_t value = lldiv( config_GetFloat( p_intf, psz_variable )
                                       * 1000000, 1000000 );
                snprintf( psz_string, sizeof(psz_string), "%lld.%06u",
                          value.quot, (unsigned int)value.rem );
                SSPush( st, psz_string );
                break;
            }
            default:
                msg_Warn( p_intf, "vlc_config_get called on unknown var (%s)",
                          psz_variable );
                SSPush( st, "" );
            }
            free( psz_variable );
        }
        else if( !strcmp( s, "vlc_config_save" ) )
        {
            char *psz_module = SSPop( st );
            int i_result;

            if( !*psz_module )
            {
                free( psz_module );
                psz_module = NULL;
            }
            i_result = config_SaveConfigFile( p_intf, psz_module );

            if( psz_module != NULL )
                free( psz_module );
            SSPushN( st, i_result );
        }
        else if( !strcmp( s, "vlc_config_reset" ) )
        {
            config_ResetAll( p_intf );
        }
        /* 6. playlist functions */
        else if( !strcmp( s, "playlist_add" ) )
        {
            char *psz_name = SSPop( st );
            char *mrl = SSPop( st );
            input_item_t *p_input;
            int i_ret;

            p_input = MRLParse( p_intf, mrl, psz_name );

            char *psz_uri = input_item_GetURI( p_input );
            if( !p_input || !psz_uri || !*psz_uri )
            {
                i_ret = VLC_EGENERIC;
                msg_Dbg( p_intf, "invalid requested mrl: %s", mrl );
            }
            else
            {
                i_ret = playlist_AddInput( p_sys->p_playlist, p_input,
                                   PLAYLIST_APPEND, PLAYLIST_END, true,
                                   pl_Unlocked );
                if( i_ret == VLC_SUCCESS )
                {
                    playlist_item_t *p_item;
                    msg_Dbg( p_intf, "requested mrl add: %s", mrl );
                    playlist_Lock( p_sys->p_playlist );
                    p_item = playlist_ItemGetByInput( p_sys->p_playlist,
                                                      p_input );
                    if( p_item )
                        i_ret = p_item->i_id;
                    playlist_Unlock( p_sys->p_playlist );
                }
                else
                    msg_Warn( p_intf, "adding mrl %s failed", mrl );
                vlc_gc_decref( p_input );
            }
            free( psz_uri );
            SSPushN( st, i_ret );

            free( mrl );
            free( psz_name );
        }
        else if( !strcmp( s, "playlist_empty" ) )
        {
            playlist_Clear( p_sys->p_playlist, pl_Unlocked );
            msg_Dbg( p_intf, "requested playlist empty" );
        }
        else if( !strcmp( s, "playlist_delete" ) )
        {
            int i_id = SSPopN( st, vars );
            playlist_Lock( p_sys->p_playlist );
            playlist_item_t *p_item = playlist_ItemGetById( p_sys->p_playlist,
                                                            i_id );
            if( p_item )
            {
                playlist_DeleteFromInput( p_sys->p_playlist,
                                          p_item->p_input, pl_Locked );
                msg_Dbg( p_intf, "requested playlist delete: %d", i_id );
            }
            else
            {
                msg_Dbg( p_intf, "couldn't find playlist item to delete (%d)",
                         i_id );
            }
            playlist_Unlock( p_sys->p_playlist );
        }
        else if( !strcmp( s, "playlist_move" ) )
        {
            /*int i_newpos =*/ SSPopN( st, vars );
            /*int i_pos =*/ SSPopN( st, vars );
            /* FIXME FIXME TODO TODO XXX XXX
            do not release before fixing this
            if ( i_pos < i_newpos )
            {
                playlist_Move( p_sys->p_playlist, i_pos, i_newpos + 1 );
            }
            else
            {
                playlist_Move( p_sys->p_playlist, i_pos, i_newpos );
            }
            msg_Dbg( p_intf, "requested to move playlist item %d to %d",
                     i_pos, i_newpos);
               FIXME FIXME TODO TODO XXX XXX */
            msg_Err( p_intf, "moving using indexes is obsolete. We need to update this function" );
        }
        else if( !strcmp( s, "playlist_sort" ) )
        {
            int i_order = SSPopN( st, vars );
            int i_sort = SSPopN( st, vars );
            i_order = i_order % 2;
            i_sort = i_sort % 9;
            /* FIXME FIXME TODO TODO XXX XXX
            do not release before fixing this
            playlist_RecursiveNodeSort(  p_sys->p_playlist,
                                         p_sys->p_playlist->p_general,
                                         i_sort, i_order );
            msg_Dbg( p_intf, "requested sort playlist by : %d in order : %d",
                     i_sort, i_order );
               FIXME FIXME TODO TODO XXX XXX */
            msg_Err( p_intf, "this needs to be fixed to use the new playlist framework" );
        }
        else if( !strcmp( s, "services_discovery_add" ) )
        {
            char *psz_sd = SSPop( st );
            playlist_ServicesDiscoveryAdd( p_sys->p_playlist, psz_sd );
            free( psz_sd );
        }
        else if( !strcmp( s, "services_discovery_remove" ) )
        {
            char *psz_sd = SSPop( st );
            playlist_ServicesDiscoveryRemove( p_sys->p_playlist, psz_sd );
            free( psz_sd );
        }
        else if( !strcmp( s, "services_discovery_is_loaded" ) )
        {
            char *psz_sd = SSPop( st );
            SSPushN( st,
            playlist_IsServicesDiscoveryLoaded( p_sys->p_playlist, psz_sd ) );
            free( psz_sd );
        }
        else if( !strcmp( s, "vlc_volume_set" ) )
        {
            char *psz_vol = SSPop( st );
            int i_value;
            audio_volume_t i_volume;
            aout_VolumeGet( p_intf, &i_volume );
            if( psz_vol[0] == '+' )
            {
                i_value = atoi( psz_vol );
                if( (i_volume + i_value) > AOUT_VOLUME_MAX )
                    aout_VolumeSet( p_intf, AOUT_VOLUME_MAX );
                else
                    aout_VolumeSet( p_intf, i_volume + i_value );
            }
            else if( psz_vol[0] == '-' )
            {
                i_value = atoi( psz_vol );
                if( (i_volume + i_value) < AOUT_VOLUME_MIN )
                    aout_VolumeSet( p_intf, AOUT_VOLUME_MIN );
                else
                    aout_VolumeSet( p_intf, i_volume + i_value );
            }
            else if( strstr( psz_vol, "%") != NULL )
            {
                i_value = atoi( psz_vol );
                if( i_value < 0 ) i_value = 0;
                if( i_value > 400 ) i_value = 400;
                aout_VolumeSet( p_intf, (i_value * (AOUT_VOLUME_MAX - AOUT_VOLUME_MIN))/400+AOUT_VOLUME_MIN);
            }
            else
            {
                i_value = atoi( psz_vol );
                if( i_value > AOUT_VOLUME_MAX ) i_value = AOUT_VOLUME_MAX;
                if( i_value < AOUT_VOLUME_MIN ) i_value = AOUT_VOLUME_MIN;
                aout_VolumeSet( p_intf, i_value );
            }
            aout_VolumeGet( p_intf, &i_volume );
            free( psz_vol );
        }
        else if( !strcmp( s, "vlc_get_meta" ) )
        {
            char *psz_meta = SSPop( st );
            char *psz_val = NULL;
            if( p_sys->p_input && input_GetItem(p_sys->p_input) )
            {
#define p_item input_GetItem( p_sys->p_input )
                if( !strcmp( psz_meta, "ARTIST" ) )
                {
                    psz_val = input_item_GetArtist( p_item );
                }
                else if( !strcmp( psz_meta, "TITLE" ) )
                {
                    psz_val = input_item_GetTitle( p_item );
                    if( !psz_val )
                        psz_val = input_item_GetName( p_item );
                }
                else if( !strcmp( psz_meta, "ALBUM" ) )
                {
                    psz_val = input_item_GetAlbum( p_item );
                }
                else if( !strcmp( psz_meta, "GENRE" ) )
                {
                    psz_val = input_item_GetGenre( p_item );
                }
                else if( !strcmp( psz_meta, "COPYRIGHT" ) )
                {
                     psz_val = input_item_GetCopyright( p_item );
                }
                else if( !strcmp( psz_meta, "TRACK_NUMBER" ) )
                {
                    psz_val = input_item_GetTrackNum( p_item );
                }
                else if( !strcmp( psz_meta, "DESCRIPTION" ) )
                {
                    psz_val = input_item_GetDescription( p_item );
                }
                else if( !strcmp( psz_meta, "RATING" ) )
                {
                    psz_val = input_item_GetRating( p_item );
                }
                else if( !strcmp( psz_meta, "DATE" ) )
                {
                    psz_val = input_item_GetDate( p_item );
                }
                else if( !strcmp( psz_meta, "URL" ) )
                {
                    psz_val = input_item_GetURL( p_item );
                }
                else if( !strcmp( psz_meta, "LANGUAGE" ) )
                {
                    psz_val = input_item_GetLanguage( p_item );
                }
                else if( !strcmp( psz_meta, "NOW_PLAYING" ) )
                {
                    psz_val = input_item_GetNowPlaying( p_item );
                }
                else if( !strcmp( psz_meta, "PUBLISHER" ) )
                {
                    psz_val = input_item_GetPublisher( p_item );
                }
                else if( !strcmp( psz_meta, "ENCODED_BY" ) )
                {
                    psz_val = input_item_GetEncodedBy( p_item );
                }
                else if( !strcmp( psz_meta, "ART_URL" ) )
                {
                    psz_val = input_item_GetEncodedBy( p_item );
                }
                else if( !strcmp( psz_meta, "TRACK_ID" ) )
                {
                    psz_val = input_item_GetTrackID( p_item );
                }
#undef p_item
            }
            if( psz_val == NULL ) psz_val = strdup( "" );
            SSPush( st, psz_val );
            free( psz_meta );
            free( psz_val );
        }
#ifdef ENABLE_VLM
        else if( !strcmp( s, "vlm_command" ) || !strcmp( s, "vlm_cmd" ) )
        {
            char *psz_elt;
            char *psz_cmd = strdup( "" );
            char *psz_error;
            vlm_message_t *vlm_answer;

            /* make sure that we have a vlm object */
            if( p_intf->p_sys->p_vlm == NULL )
                p_intf->p_sys->p_vlm = vlm_New( p_intf );


            /* vlm command uses the ';' delimiter
             * (else we can't know when to stop) */
            while( strcmp( psz_elt = SSPop( st ), "" )
                   && strcmp( psz_elt, ";" ) )
            {
                char* psz_buf;
                if( asprintf( &psz_buf, "%s %s", psz_cmd, psz_elt ) == -1 )
                    psz_buf = NULL;
                free( psz_cmd );
                free( psz_elt );
                psz_cmd = psz_buf;
            }

            msg_Dbg( p_intf, "executing vlm command: %s", psz_cmd );
            vlm_ExecuteCommand( p_intf->p_sys->p_vlm, psz_cmd, &vlm_answer );

            if( vlm_answer->psz_value == NULL )
            {
                psz_error = strdup( "" );
            }
            else
            {
                if( asprintf( &psz_error , "%s : %s" , vlm_answer->psz_name,
                              vlm_answer->psz_value ) == -1 )
                    psz_error = NULL;
            }

            mvar_AppendNewVar( vars, "vlm_error", psz_error );
            /* this is kind of a duplicate but we need to have the message
             * without the command name for the "export" command */
            mvar_AppendNewVar( vars, "vlm_value", vlm_answer->psz_value );
            vlm_MessageDelete( vlm_answer );

            free( psz_cmd );
            free( psz_error );
        }
#endif /* ENABLE_VLM */
        else if( !strcmp( s, "snapshot" ) )
        {
            if( p_sys->p_input )
            {
                vout_thread_t *p_vout = input_GetVout( p_sys->p_input );
                if( p_vout )
                {
                    var_TriggerCallback( p_vout, "video-snapshot" );
                    vlc_object_release( p_vout );
                    msg_Dbg( p_intf, "requested snapshot" );
                }
            }
            break;

        }
        else
        {
            SSPush( st, s );
        }
    }
}
Exemplo n.º 17
0
	/* Pause play, hide concludePreviewButton, show this */
	void FilterWin::concludePreview()
	{
		show();
		playlist_Control( Moviesoap::p_playlist, PLAYLIST_PAUSE, false );
	}