Commit 3a189811 authored by Christophe Massiot's avatar Christophe Massiot

* modules/control/http.c: New RPN functions: vlc_play, vlc_stop, vlc_pause,

   vlc_next, vlc_previous, playlist_empty. Miscellaneous coding style fixes.
parent 33a9e335
...@@ -25,11 +25,6 @@ ...@@ -25,11 +25,6 @@
/***************************************************************************** /*****************************************************************************
* Preamble * Preamble
*****************************************************************************/ *****************************************************************************/
/* TODO:
* - clean up ?
* - doc ! (mouarf ;)
*/
#include <stdlib.h> #include <stdlib.h>
#include <ctype.h> #include <ctype.h>
#include <vlc/vlc.h> #include <vlc/vlc.h>
...@@ -1698,7 +1693,7 @@ StrToMacroTypeTab [] = ...@@ -1698,7 +1693,7 @@ StrToMacroTypeTab [] =
{ "vlm_save", MVLC_VLM_SAVE }, { "vlm_save", MVLC_VLM_SAVE },
{ "rpn", MVLC_RPN }, { "rpn", MVLC_RPN },
{ "stack", MVLC_STACK }, { "stack", MVLC_STACK },
{ "foreach", MVLC_FOREACH }, { "foreach", MVLC_FOREACH },
{ "value", MVLC_VALUE }, { "value", MVLC_VALUE },
...@@ -1706,8 +1701,8 @@ StrToMacroTypeTab [] = ...@@ -1706,8 +1701,8 @@ StrToMacroTypeTab [] =
{ "if", MVLC_IF }, { "if", MVLC_IF },
{ "else", MVLC_ELSE }, { "else", MVLC_ELSE },
{ "end", MVLC_END }, { "end", MVLC_END },
{ "get", MVLC_GET }, { "get", MVLC_GET },
{ "set", MVLC_SET }, { "set", MVLC_SET },
{ "int", MVLC_INT }, { "int", MVLC_INT },
{ "float", MVLC_FLOAT }, { "float", MVLC_FLOAT },
{ "string", MVLC_STRING }, { "string", MVLC_STRING },
...@@ -1798,7 +1793,7 @@ static void MacroDo( httpd_file_sys_t *p_args, ...@@ -1798,7 +1793,7 @@ static void MacroDo( httpd_file_sys_t *p_args,
break; break;
} }
case MVLC_STOP: case MVLC_STOP:
playlist_Control( p_sys->p_playlist, PLAYLIST_STOP); playlist_Control( p_sys->p_playlist, PLAYLIST_STOP );
msg_Dbg( p_intf, "requested playlist stop" ); msg_Dbg( p_intf, "requested playlist stop" );
break; break;
case MVLC_PAUSE: case MVLC_PAUSE:
...@@ -1810,8 +1805,8 @@ static void MacroDo( httpd_file_sys_t *p_args, ...@@ -1810,8 +1805,8 @@ static void MacroDo( httpd_file_sys_t *p_args,
msg_Dbg( p_intf, "requested playlist next" ); msg_Dbg( p_intf, "requested playlist next" );
break; break;
case MVLC_PREVIOUS: case MVLC_PREVIOUS:
playlist_Control( p_sys->p_playlist, PLAYLIST_SKIP, -1); playlist_Control( p_sys->p_playlist, PLAYLIST_SKIP, -1 );
msg_Dbg( p_intf, "requested playlist next" ); msg_Dbg( p_intf, "requested playlist previous" );
break; break;
case MVLC_FULLSCREEN: case MVLC_FULLSCREEN:
{ {
...@@ -2029,33 +2024,36 @@ static void MacroDo( httpd_file_sys_t *p_args, ...@@ -2029,33 +2024,36 @@ static void MacroDo( httpd_file_sys_t *p_args,
{ {
aout_VolumeSet( p_intf , AOUT_VOLUME_MAX ); aout_VolumeSet( p_intf , AOUT_VOLUME_MAX );
msg_Dbg( p_intf, "requested volume set: max" ); msg_Dbg( p_intf, "requested volume set: max" );
} else }
else
{ {
aout_VolumeSet( p_intf , (i_volume + i_value) ); aout_VolumeSet( p_intf , (i_volume + i_value) );
msg_Dbg( p_intf, "requested volume set: +%i", (i_volume + i_value) ); msg_Dbg( p_intf, "requested volume set: +%i", (i_volume + i_value) );
} }
} else }
if( vol[0] == '-' ) else if( vol[0] == '-' )
{ {
i_value = atoi( vol + 1 ); i_value = atoi( vol + 1 );
if( (i_volume - i_value) < AOUT_VOLUME_MIN ) if( (i_volume - i_value) < AOUT_VOLUME_MIN )
{ {
aout_VolumeSet( p_intf , AOUT_VOLUME_MIN ); aout_VolumeSet( p_intf , AOUT_VOLUME_MIN );
msg_Dbg( p_intf, "requested volume set: min" ); msg_Dbg( p_intf, "requested volume set: min" );
} else }
else
{ {
aout_VolumeSet( p_intf , (i_volume - i_value) ); aout_VolumeSet( p_intf , (i_volume - i_value) );
msg_Dbg( p_intf, "requested volume set: -%i", (i_volume - i_value) ); msg_Dbg( p_intf, "requested volume set: -%i", (i_volume - i_value) );
} }
} else }
if( strstr(vol, "%") != NULL ) else if( strstr(vol, "%") != NULL )
{ {
i_value = atoi( vol ); i_value = atoi( vol );
if( (i_value <= 400) && (i_value>=0) ){ if( (i_value <= 400) && (i_value>=0) ){
aout_VolumeSet( p_intf, (i_value * (AOUT_VOLUME_MAX - AOUT_VOLUME_MIN))/400+AOUT_VOLUME_MIN); aout_VolumeSet( p_intf, (i_value * (AOUT_VOLUME_MAX - AOUT_VOLUME_MIN))/400+AOUT_VOLUME_MIN);
msg_Dbg( p_intf, "requested volume set: %i%%", atoi( vol )); msg_Dbg( p_intf, "requested volume set: %i%%", atoi( vol ));
} }
} else }
else
{ {
i_value = atoi( vol ); i_value = atoi( vol );
if( ( i_value <= AOUT_VOLUME_MAX ) && ( i_value >= AOUT_VOLUME_MIN ) ) if( ( i_value <= AOUT_VOLUME_MAX ) && ( i_value >= AOUT_VOLUME_MIN ) )
...@@ -2197,14 +2195,16 @@ static void MacroDo( httpd_file_sys_t *p_args, ...@@ -2197,14 +2195,16 @@ static void MacroDo( httpd_file_sys_t *p_args,
SORT_TITLE_NODES_FIRST, SORT_TITLE_NODES_FIRST,
( i_order == 0 ) ? ORDER_NORMAL : ORDER_REVERSE ); ( i_order == 0 ) ? ORDER_NORMAL : ORDER_REVERSE );
msg_Dbg( p_intf, "requested playlist sort by title (%d)" , i_order ); msg_Dbg( p_intf, "requested playlist sort by title (%d)" , i_order );
} else if( !strcmp( type , "author" ) ) }
else if( !strcmp( type , "author" ) )
{ {
playlist_RecursiveNodeSort( p_sys->p_playlist, /*playlist_ItemGetById( p_sys->p_playlist, i_item ),*/ playlist_RecursiveNodeSort( p_sys->p_playlist, /*playlist_ItemGetById( p_sys->p_playlist, i_item ),*/
p_sys->p_playlist->pp_views[0]->p_root, p_sys->p_playlist->pp_views[0]->p_root,
SORT_AUTHOR, SORT_AUTHOR,
( i_order == 0 ) ? ORDER_NORMAL : ORDER_REVERSE ); ( i_order == 0 ) ? ORDER_NORMAL : ORDER_REVERSE );
msg_Dbg( p_intf, "requested playlist sort by author (%d)" , i_order ); msg_Dbg( p_intf, "requested playlist sort by author (%d)" , i_order );
} else if( !strcmp( type , "shuffle" ) ) }
else if( !strcmp( type , "shuffle" ) )
{ {
playlist_RecursiveNodeSort( p_sys->p_playlist, /*playlist_ItemGetById( p_sys->p_playlist, i_item ),*/ playlist_RecursiveNodeSort( p_sys->p_playlist, /*playlist_ItemGetById( p_sys->p_playlist, i_item ),*/
p_sys->p_playlist->pp_views[0]->p_root, p_sys->p_playlist->pp_views[0]->p_root,
...@@ -2228,7 +2228,9 @@ static void MacroDo( httpd_file_sys_t *p_args, ...@@ -2228,7 +2228,9 @@ static void MacroDo( httpd_file_sys_t *p_args,
if ( i_pos < i_newpos ) if ( i_pos < i_newpos )
{ {
playlist_Move( p_sys->p_playlist, i_pos, i_newpos + 1 ); playlist_Move( p_sys->p_playlist, i_pos, i_newpos + 1 );
} else { }
else
{
playlist_Move( p_sys->p_playlist, i_pos, i_newpos ); playlist_Move( p_sys->p_playlist, i_pos, i_newpos );
} }
msg_Dbg( p_intf, "requested move playlist item %d to %d", i_pos, i_newpos); msg_Dbg( p_intf, "requested move playlist item %d to %d", i_pos, i_newpos);
...@@ -3095,7 +3097,7 @@ static void EvaluateRPN( intf_thread_t *p_intf, mvar_t *vars, ...@@ -3095,7 +3097,7 @@ static void EvaluateRPN( intf_thread_t *p_intf, mvar_t *vars,
{ {
char s[100], *p; char s[100], *p;
/* skip spcae */ /* skip space */
while( *exp == ' ' ) while( *exp == ' ' )
{ {
exp++; exp++;
...@@ -3108,6 +3110,9 @@ static void EvaluateRPN( intf_thread_t *p_intf, mvar_t *vars, ...@@ -3108,6 +3110,9 @@ static void EvaluateRPN( intf_thread_t *p_intf, mvar_t *vars,
exp++; exp++;
while( *exp && *exp != '\'' ) while( *exp && *exp != '\'' )
{ {
/* strip a level of backslashes */
if( *exp == '\\' && exp[1] != '\0' )
exp++;
*p++ = *exp++; *p++ = *exp++;
} }
*p = '\0'; *p = '\0';
...@@ -3362,7 +3367,7 @@ static void EvaluateRPN( intf_thread_t *p_intf, mvar_t *vars, ...@@ -3362,7 +3367,7 @@ static void EvaluateRPN( intf_thread_t *p_intf, mvar_t *vars,
free( value ); free( value );
} }
/* 5. player control */ /* 5. player control */
else if( !strcmp( s, "play" ) ) else if( !strcmp( s, "vlc_play" ) )
{ {
int i_id = SSPopN( st, vars ); int i_id = SSPopN( st, vars );
int i_ret; int i_ret;
...@@ -3373,6 +3378,26 @@ static void EvaluateRPN( intf_thread_t *p_intf, mvar_t *vars, ...@@ -3373,6 +3378,26 @@ static void EvaluateRPN( intf_thread_t *p_intf, mvar_t *vars,
msg_Dbg( p_intf, "requested playlist item: %i", i_id ); msg_Dbg( p_intf, "requested playlist item: %i", i_id );
SSPushN( st, i_ret ); SSPushN( st, i_ret );
} }
else if( !strcmp( s, "vlc_stop" ) )
{
playlist_Control( p_sys->p_playlist, PLAYLIST_STOP );
msg_Dbg( p_intf, "requested playlist stop" );
}
else if( !strcmp( s, "vlc_pause" ) )
{
playlist_Control( p_sys->p_playlist, PLAYLIST_PAUSE );
msg_Dbg( p_intf, "requested playlist pause" );
}
else if( !strcmp( s, "vlc_next" ) )
{
playlist_Control( p_sys->p_playlist, PLAYLIST_SKIP, 1 );
msg_Dbg( p_intf, "requested playlist next" );
}
else if( !strcmp( s, "vlc_previous" ) )
{
playlist_Control( p_sys->p_playlist, PLAYLIST_SKIP, -1 );
msg_Dbg( p_intf, "requested playlist previous" );
}
/* 6. playlist functions */ /* 6. playlist functions */
else if( !strcmp( s, "playlist_add" ) ) else if( !strcmp( s, "playlist_add" ) )
{ {
...@@ -3381,6 +3406,9 @@ static void EvaluateRPN( intf_thread_t *p_intf, mvar_t *vars, ...@@ -3381,6 +3406,9 @@ static void EvaluateRPN( intf_thread_t *p_intf, mvar_t *vars,
playlist_item_t *p_item; playlist_item_t *p_item;
int i_id; int i_id;
psz_name = ToUTF8( p_intf, psz_name );
mrl = ToUTF8( p_intf, mrl );
if( !*psz_name ) if( !*psz_name )
{ {
p_item = parse_MRL( p_intf, mrl, mrl ); p_item = parse_MRL( p_intf, mrl, mrl );
...@@ -3403,6 +3431,14 @@ static void EvaluateRPN( intf_thread_t *p_intf, mvar_t *vars, ...@@ -3403,6 +3431,14 @@ static void EvaluateRPN( intf_thread_t *p_intf, mvar_t *vars,
msg_Dbg( p_intf, "requested mrl add: %s", mrl ); msg_Dbg( p_intf, "requested mrl add: %s", mrl );
} }
SSPushN( st, i_id ); SSPushN( st, i_id );
free( mrl );
free( psz_name );
}
else if( !strcmp( s, "playlist_empty" ) )
{
playlist_LockClear( p_sys->p_playlist );
msg_Dbg( p_intf, "requested playlist empty" );
} }
else else
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment