* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
#include "http.h"
#include "vlc_url.h"
+#include "vlc_meta.h"
+#include "vlc_strings.h"
static vlc_object_t *GetVLCObject( intf_thread_t *p_intf,
const char *psz_object,
vlc_object_t *p_object = NULL;
*pb_need_release = VLC_FALSE;
- if( !strcmp( psz_object, "VLC_OBJECT_ROOT" ) )
- i_object_type = VLC_OBJECT_ROOT;
- else if( !strcmp( psz_object, "VLC_OBJECT_VLC" ) )
- p_object = VLC_OBJECT(p_intf->p_vlc);
+ if( !strcmp( psz_object, "VLC_OBJECT_LIBVLC" ) )
+ p_object = VLC_OBJECT(p_intf->p_libvlc);
else if( !strcmp( psz_object, "VLC_OBJECT_INTF" ) )
p_object = VLC_OBJECT(p_intf);
else if( !strcmp( psz_object, "VLC_OBJECT_PLAYLIST" ) )
void E_(SSPushN)( rpn_stack_t *st, int i )
{
- char v[512];
+ char v[12];
- sprintf( v, "%d", i );
+ snprintf( v, sizeof (v), "%d", i );
E_(SSPush)( st, v );
}
{
char *url = E_(mvar_GetValue)( vars, "url_value" );
char *name = E_(SSPop)( st );
- char value[512];
- char *tmp;
-
- E_(ExtractURIValue)( url, name, value, 512 );
- unescape_URI( value );
- tmp = E_(FromUTF8)( p_intf, value );
- E_(SSPush)( st, tmp );
- free( tmp );
+ char *value = E_(ExtractURIString)( url, name );
+ if( value != NULL )
+ {
+ decode_URI( value );
+ E_(SSPush)( st, value );
+ free( value );
+ }
+ else
+ E_(SSPush)( st, "" );
+
free( name );
}
else if( !strcmp( s, "url_encode" ) )
{
char *url = E_(SSPop)( st );
- char *value;
-
- value = E_(ToUTF8)( p_intf, url );
- free( url );
- url = value;
- value = vlc_UrlEncode( url );
+ char *value = vlc_UrlEncode( url );
free( url );
E_(SSPush)( st, value );
free( value );
{
char *psz_src = E_(SSPop)( st );
char *psz_dest;
+ char *str = psz_src;
p = psz_dest = strdup( psz_src );
- while( *psz_src )
+ while( *str )
{
- if( *psz_src == '\\' && *(psz_src + 1) )
+ if( *str == '\\' && *(str + 1) )
{
- psz_src++;
+ str++;
}
- *p++ = *psz_src++;
+ *p++ = *str++;
}
*p = '\0';
int i_id = E_(SSPopN)( st, vars );
int i_ret;
- i_ret = playlist_Control( p_sys->p_playlist, PLAYLIST_ITEMPLAY,
+ i_ret = playlist_Control( p_sys->p_playlist, PLAYLIST_VIEWPLAY,
+ VLC_TRUE, NULL,
playlist_ItemGetById( p_sys->p_playlist,
- i_id ) );
+ i_id, VLC_TRUE ) );
msg_Dbg( p_intf, "requested playlist item: %i", i_id );
E_(SSPushN)( st, i_ret );
}
else if( !strcmp( s, "vlc_stop" ) )
{
- playlist_Control( p_sys->p_playlist, PLAYLIST_STOP );
+ playlist_Control( p_sys->p_playlist, PLAYLIST_STOP, VLC_TRUE );
msg_Dbg( p_intf, "requested playlist stop" );
}
else if( !strcmp( s, "vlc_pause" ) )
{
- playlist_Control( p_sys->p_playlist, PLAYLIST_PAUSE );
+ playlist_Control( p_sys->p_playlist, PLAYLIST_PAUSE, VLC_TRUE );
msg_Dbg( p_intf, "requested playlist pause" );
}
else if( !strcmp( s, "vlc_next" ) )
{
- playlist_Control( p_sys->p_playlist, PLAYLIST_SKIP, 1 );
+ playlist_Control( p_sys->p_playlist, PLAYLIST_SKIP, VLC_TRUE, 1 );
msg_Dbg( p_intf, "requested playlist next" );
}
else if( !strcmp( s, "vlc_previous" ) )
{
- playlist_Control( p_sys->p_playlist, PLAYLIST_SKIP, -1 );
+ playlist_Control( p_sys->p_playlist, PLAYLIST_SKIP, VLC_TRUE, -1 );
msg_Dbg( p_intf, "requested playlist previous" );
}
else if( !strcmp( s, "vlc_seek" ) )
{
char psz_value[20];
lldiv_t value = lldiv( val.f_float * 1000000, 1000000 );
- snprintf( psz_value, sizeof(psz_value), I64Fd".%06u",
+ snprintf( psz_value, sizeof(psz_value), "%lld.%06u",
value.quot, (unsigned int)value.rem );
E_(SSPush)( st, psz_value );
break;
char psz_string[20];
lldiv_t value = lldiv( config_GetFloat( p_intf, psz_variable )
* 1000000, 1000000 );
- snprintf( psz_string, sizeof(psz_string), I64Fd".%06u",
+ snprintf( psz_string, sizeof(psz_string), "%lld.%06u",
value.quot, (unsigned int)value.rem );
E_(SSPush)( st, psz_string );
break;
default:
msg_Warn( p_intf, "vlc_config_get called on unknown var (%s)",
psz_variable );
+ E_(SSPush)( st, "" );
}
free( psz_variable );
}
{
char *psz_name = E_(SSPop)( st );
char *mrl = E_(SSPop)( st );
- char *tmp;
- playlist_item_t *p_item;
- int i_id;
+ input_item_t *p_input;
+ int i_ret;
- tmp = E_(ToUTF8)( p_intf, psz_name );
- free( psz_name );
- psz_name = tmp;
- tmp = E_(ToUTF8)( p_intf, mrl );
- free( mrl );
- mrl = tmp;
+ p_input = E_(MRLParse)( p_intf, mrl, psz_name );
- if( !*psz_name )
+ char *psz_uri = input_item_GetURI( p_input );
+ if( !p_input || !psz_uri || !*psz_uri )
{
- p_item = E_(MRLParse)( p_intf, mrl, mrl );
- }
- else
- {
- p_item = E_(MRLParse)( p_intf, mrl, psz_name );
- }
-
- if( p_item == NULL || p_item->input.psz_uri == NULL ||
- !*p_item->input.psz_uri )
- {
- i_id = VLC_EGENERIC;
+ i_ret = VLC_EGENERIC;
msg_Dbg( p_intf, "invalid requested mrl: %s", mrl );
}
else
{
- i_id = playlist_AddItem( p_sys->p_playlist, p_item,
- PLAYLIST_APPEND, PLAYLIST_END );
- msg_Dbg( p_intf, "requested mrl add: %s", mrl );
+ i_ret = playlist_AddInput( p_sys->p_playlist, p_input,
+ PLAYLIST_APPEND, PLAYLIST_END, VLC_TRUE,
+ VLC_FALSE);
+ vlc_gc_decref( p_input );
+ if( i_ret == VLC_SUCCESS )
+ msg_Dbg( p_intf, "requested mrl add: %s", mrl );
+ else
+ msg_Warn( p_intf, "adding mrl %s failed", mrl );
}
- E_(SSPushN)( st, i_id );
+ free( psz_uri );
+ E_(SSPushN)( st, i_ret );
free( mrl );
free( psz_name );
}
else if( !strcmp( s, "playlist_empty" ) )
{
- playlist_LockClear( p_sys->p_playlist );
+ playlist_Clear( p_sys->p_playlist, VLC_FALSE );
msg_Dbg( p_intf, "requested playlist empty" );
}
else if( !strcmp( s, "playlist_delete" ) )
{
int i_id = E_(SSPopN)( st, vars );
- playlist_LockDelete( p_sys->p_playlist, i_id );
- msg_Dbg( p_intf, "requested playlist delete: %d", i_id );
+ playlist_item_t *p_item = playlist_ItemGetById( p_sys->p_playlist,
+ i_id, VLC_FALSE );
+ if( p_item )
+ {
+ playlist_DeleteFromInput( p_sys->p_playlist,
+ p_item->p_input->i_id, VLC_FALSE );
+ 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 );
+ }
}
else if( !strcmp( s, "playlist_move" ) )
{
- int i_newpos = E_(SSPopN)( st, vars );
- int i_pos = E_(SSPopN)( st, vars );
+ /*int i_newpos =*/ E_(SSPopN)( st, vars );
+ /*int i_pos =*/ E_(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 );
}
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_sort = E_(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" ) )
{
aout_VolumeGet( p_intf, &i_volume );
free( psz_vol );
}
+ else if( !strcmp( s, "vlc_get_meta" ) )
+ {
+ char *psz_meta = E_(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_ItemGetInfo( p_item,
+ _(VLC_META_INFO_CAT), _(VLC_META_ARTIST) );
+ }
+ else if( !strcmp( psz_meta, "TITLE" ) )
+ {
+ psz_val = input_ItemGetInfo( p_item,
+ _(VLC_META_INFO_CAT), _(VLC_META_TITLE) );
+ if( psz_val == NULL )
+ psz_val = strdup( p_item->psz_name );
+ }
+ else if( !strcmp( psz_meta, "ALBUM" ) )
+ {
+ psz_val = input_ItemGetInfo( p_item,
+ _(VLC_META_INFO_CAT), _(VLC_META_COLLECTION) );
+ }
+ else if( !strcmp( psz_meta, "GENRE" ) )
+ {
+ psz_val = input_ItemGetInfo( p_item,
+ _(VLC_META_INFO_CAT), _(VLC_META_GENRE) );
+ }
+ else
+ {
+ psz_val = input_ItemGetInfo( p_item,
+ _(VLC_META_INFO_CAT), psz_meta );
+ }
+#undef p_item
+ }
+ if( psz_val == NULL ) psz_val = strdup( "" );
+ E_(SSPush)( st, psz_val );
+ free( psz_meta );
+ free( psz_val );
+ }
else if( !strcmp( s, "vlm_command" ) || !strcmp( s, "vlm_cmd" ) )
{
char *psz_elt;
free( psz_cmd );
free( psz_error );
}
+ else if( !strcmp( s, "snapshot" ) )
+ {
+ if( p_sys->p_input )
+ {
+ vout_thread_t *p_vout;
+ p_vout = vlc_object_find( p_sys->p_input,
+ VLC_OBJECT_VOUT, FIND_CHILD );
+
+ if( p_vout )
+ {
+ vout_Control( p_vout, VOUT_SNAPSHOT );
+ vlc_object_release( p_vout );
+ msg_Dbg( p_intf, "requested snapshot" );
+ }
+ }
+ break;
+
+ }
else
{
E_(SSPush)( st, s );