Commit 9e8ed400 authored by Jérome Decoodt's avatar Jérome Decoodt

Work to support new playlist in http interface.

+ correct a bug in the <vlc id="foreach" param1="integer" /> macro
+ add a <vlc id="stack" /> to print the rpn stack in debug messages
+ add the != operator in rpn evaluation

Compatibility with old pages should be respected...
parent 727e57b4
...@@ -870,8 +870,8 @@ static mvar_t *mvar_IntegerSetNew( char *name, char *arg ) ...@@ -870,8 +870,8 @@ static mvar_t *mvar_IntegerSetNew( char *name, char *arg )
{ {
int i; int i;
if( ( i_start < i_stop && i_step > 0 ) || if( ( i_start <= i_stop && i_step > 0 ) ||
( i_start > i_stop && i_step < 0 ) ) ( i_start >= i_stop && i_step < 0 ) )
{ {
for( i = i_start; ; i += i_step ) for( i = i_start; ; i += i_step )
{ {
...@@ -897,31 +897,79 @@ static mvar_t *mvar_IntegerSetNew( char *name, char *arg ) ...@@ -897,31 +897,79 @@ static mvar_t *mvar_IntegerSetNew( char *name, char *arg )
return s; return s;
} }
static mvar_t *mvar_PlaylistSetNew( char *name, playlist_t *p_pl ) void PlaylistListNode( playlist_t *p_pl, playlist_item_t *p_node,
char *name, mvar_t *s, int i_depth )
{ {
mvar_t *s = mvar_New( name, "set" ); if( p_node != NULL )
int i; {
if (p_node->i_children == -1)
{
char value[512];
mvar_t *itm = mvar_New( name, "set" );
fprintf( stderr," mvar_PlaylistSetNew: name=`%s'\n", name ); sprintf( value, "%d", ( p_pl->status.p_item == p_node )? 1 : 0 );
mvar_AppendNewVar( itm, "current", value );
vlc_mutex_lock( &p_pl->object_lock ); sprintf( value, "%d", p_node->input.i_id );
for( i = 0; i < p_pl->i_size; i++ ) mvar_AppendNewVar( itm, "index", value );
mvar_AppendNewVar( itm, "name", p_node->input.psz_name );
mvar_AppendNewVar( itm, "uri", p_node->input.psz_uri );
sprintf( value, "Item");
mvar_AppendNewVar( itm, "type", value );
sprintf( value, "%d", i_depth );
mvar_AppendNewVar( itm, "depth", value );
mvar_AppendVar( s, itm );
}
else
{ {
mvar_t *itm = mvar_New( name, "set" );
char value[512]; char value[512];
int i_child;
mvar_t *itm = mvar_New( name, "set" );
mvar_t *itm_end = mvar_New( name, "set" );
sprintf( value, "%d", i == p_pl->i_index ? 1 : 0 ); mvar_AppendNewVar( itm, "name", p_node->input.psz_name );
mvar_AppendNewVar( itm, "current", value ); mvar_AppendNewVar( itm, "uri", p_node->input.psz_name );
sprintf( value, "%d", i ); sprintf( value, "Node" );
mvar_AppendNewVar( itm, "type", value );
sprintf( value, "%d", p_node->input.i_id );
mvar_AppendNewVar( itm, "index", value ); mvar_AppendNewVar( itm, "index", value );
mvar_AppendNewVar( itm, "name", p_pl->pp_items[i]->input.psz_name ); sprintf( value, "%d", p_node->i_children);
mvar_AppendNewVar( itm, "i_children", value );
mvar_AppendNewVar( itm, "uri", p_pl->pp_items[i]->input.psz_uri ); sprintf( value, "%d", i_depth );
mvar_AppendNewVar( itm, "depth", value );
mvar_AppendVar( s, itm ); mvar_AppendVar( s, itm );
for (i_child = 0 ; i_child < p_node->i_children ; i_child++)
PlaylistListNode( p_pl, p_node->pp_children[i_child], name, s, i_depth + 1);
}
} }
}
static mvar_t *mvar_PlaylistSetNew( char *name, playlist_t *p_pl )
{
mvar_t *s = mvar_New( name, "set" );
fprintf( stderr," mvar_PlaylistSetNew: name=`%s'\n", name );
vlc_mutex_lock( &p_pl->object_lock );
playlist_view_t *p_view;
p_view = playlist_ViewFind( p_pl, VIEW_CATEGORY ); /* FIXME */
if( p_view != NULL )
PlaylistListNode( p_pl, p_view->p_root, name, s, 0 );
vlc_mutex_unlock( &p_pl->object_lock ); vlc_mutex_unlock( &p_pl->object_lock );
return s; return s;
...@@ -1416,6 +1464,7 @@ enum macroType ...@@ -1416,6 +1464,7 @@ enum macroType
MVLC_FOREACH, MVLC_FOREACH,
MVLC_IF, MVLC_IF,
MVLC_RPN, MVLC_RPN,
MVLC_STACK,
MVLC_ELSE, MVLC_ELSE,
MVLC_END, MVLC_END,
MVLC_GET, MVLC_GET,
...@@ -1469,6 +1518,7 @@ StrToMacroTypeTab [] = ...@@ -1469,6 +1518,7 @@ StrToMacroTypeTab [] =
{ "vlm_save", MVLC_VLM_SAVE }, { "vlm_save", MVLC_VLM_SAVE },
{ "rpn", MVLC_RPN }, { "rpn", MVLC_RPN },
{ "stack", MVLC_STACK },
{ "foreach", MVLC_FOREACH }, { "foreach", MVLC_FOREACH },
{ "value", MVLC_VALUE }, { "value", MVLC_VALUE },
...@@ -1561,8 +1611,9 @@ static void MacroDo( httpd_file_sys_t *p_args, ...@@ -1561,8 +1611,9 @@ static void MacroDo( httpd_file_sys_t *p_args,
uri_extract_value( p_request, "item", item, 512 ); uri_extract_value( p_request, "item", item, 512 );
i_item = atoi( item ); i_item = atoi( item );
playlist_Control( p_sys->p_playlist, PLAYLIST_GOTO, playlist_Control( p_sys->p_playlist, PLAYLIST_ITEMPLAY,
i_item ); playlist_ItemGetById( p_sys->p_playlist,
i_item ) );
msg_Dbg( p_intf, "requested playlist item: %i", i_item ); msg_Dbg( p_intf, "requested playlist item: %i", i_item );
break; break;
} }
...@@ -1877,24 +1928,15 @@ static void MacroDo( httpd_file_sys_t *p_args, ...@@ -1877,24 +1928,15 @@ static void MacroDo( httpd_file_sys_t *p_args,
i_nb_items++; i_nb_items++;
} }
/* The items need to be deleted from in reversed order */
if( i_nb_items ) if( i_nb_items )
{ {
int i; int i;
for( i = 0; i < i_nb_items; i++ ) for( i = 0; i < i_nb_items; i++ )
{ {
int j, i_index = 0; playlist_LockDelete( p_sys->p_playlist, p_items[i] );
for( j = 0; j < i_nb_items; j++ )
{
if( p_items[j] > p_items[i_index] )
i_index = j;
}
playlist_LockDelete( p_sys->p_playlist,
p_items[i_index] );
msg_Dbg( p_intf, "requested playlist delete: %d", msg_Dbg( p_intf, "requested playlist delete: %d",
p_items[i_index] ); p_items[i] );
p_items[i_index] = -1; p_items[i] = -1;
} }
} }
...@@ -1920,17 +1962,17 @@ static void MacroDo( httpd_file_sys_t *p_args, ...@@ -1920,17 +1962,17 @@ static void MacroDo( httpd_file_sys_t *p_args,
i_nb_items++; i_nb_items++;
} }
/* The items need to be deleted from in reversed order */ for( i = p_sys->p_playlist->i_size - 1 ; i >= 0; i-- )
for( i = p_sys->p_playlist->i_size - 1; i >= 0 ; i-- )
{ {
/* Check if the item is in the keep list */ /* Check if the item is in the keep list */
for( j = 0 ; j < i_nb_items ; j++ ) for( j = 0 ; j < i_nb_items ; j++ )
{ {
if( p_items[j] == i ) break; if( p_items[j] ==
p_sys->p_playlist->pp_items[i]->input.i_id ) break;
} }
if( j == i_nb_items ) if( j == i_nb_items )
{ {
playlist_LockDelete( p_sys->p_playlist, i ); playlist_LockDelete( p_sys->p_playlist, p_sys->p_playlist->pp_items[i]->input.i_id );
msg_Dbg( p_intf, "requested playlist delete: %d", msg_Dbg( p_intf, "requested playlist delete: %d",
i ); i );
} }
...@@ -1949,25 +1991,38 @@ static void MacroDo( httpd_file_sys_t *p_args, ...@@ -1949,25 +1991,38 @@ static void MacroDo( httpd_file_sys_t *p_args,
{ {
char type[12]; char type[12];
char order[2]; char order[2];
char item[512];
int i_order; int i_order;
int i_item;
uri_extract_value( p_request, "type", type, 12 ); uri_extract_value( p_request, "type", type, 12 );
uri_extract_value( p_request, "order", order, 2 ); uri_extract_value( p_request, "order", order, 2 );
uri_extract_value( p_request, "item", item, 512 );
i_item = atoi( item );
if( order[0] == '0' ) i_order = ORDER_NORMAL; if( order[0] == '0' ) i_order = ORDER_NORMAL;
else i_order = ORDER_REVERSE; else i_order = ORDER_REVERSE;
if( !strcmp( type , "title" ) ) if( !strcmp( type , "title" ) )
{ {
playlist_SortTitle( p_sys->p_playlist , i_order ); playlist_RecursiveNodeSort( p_sys->p_playlist, /*playlist_ItemGetById( p_sys->p_playlist, i_item ),*/
p_sys->p_playlist->pp_views[0]->p_root,
SORT_TITLE_NODES_FIRST,
( 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_SortAuthor( p_sys->p_playlist , i_order ); playlist_RecursiveNodeSort( p_sys->p_playlist, /*playlist_ItemGetById( p_sys->p_playlist, i_item ),*/
p_sys->p_playlist->pp_views[0]->p_root,
SORT_AUTHOR,
( 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_Sort( p_sys->p_playlist , SORT_RANDOM, ORDER_NORMAL ); playlist_RecursiveNodeSort( p_sys->p_playlist, /*playlist_ItemGetById( p_sys->p_playlist, i_item ),*/
p_sys->p_playlist->pp_views[0]->p_root,
SORT_RANDOM,
( i_order == 0 ) ? ORDER_NORMAL : ORDER_REVERSE );
msg_Dbg( p_intf, "requested playlist shuffle"); msg_Dbg( p_intf, "requested playlist shuffle");
} }
...@@ -2262,6 +2317,16 @@ static void MacroDo( httpd_file_sys_t *p_args, ...@@ -2262,6 +2317,16 @@ static void MacroDo( httpd_file_sys_t *p_args,
EvaluateRPN( p_args->vars, &p_args->stack, m->param1 ); EvaluateRPN( p_args->vars, &p_args->stack, m->param1 );
break; break;
/* Usefull for learning stack management */
case MVLC_STACK:
{
int i;
msg_Dbg( p_intf, "stack" );
for (i=0;i<(&p_args->stack)->i_stack;i++)
msg_Dbg( p_intf, "%d -> %s", i, (&p_args->stack)->stack[i] );
break;
}
case MVLC_UNKNOWN: case MVLC_UNKNOWN:
default: default:
PRINTS( "<!-- invalid macro id=`%s' -->", m->id ); PRINTS( "<!-- invalid macro id=`%s' -->", m->id );
...@@ -2921,6 +2986,10 @@ static void EvaluateRPN( mvar_t *vars, rpn_stack_t *st, char *exp ) ...@@ -2921,6 +2986,10 @@ static void EvaluateRPN( mvar_t *vars, rpn_stack_t *st, char *exp )
{ {
SSPushN( st, SSPopN( st, vars ) == SSPopN( st, vars ) ? -1 : 0 ); 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, "<" ) ) else if( !strcmp( s, "<" ) )
{ {
int j = SSPopN( st, vars ); int j = SSPopN( st, vars );
......
...@@ -7,17 +7,31 @@ ...@@ -7,17 +7,31 @@
<title>VLC media player</title> <title>VLC media player</title>
<link href="/style.css" title="Default" rel="stylesheet" type="text/css" /> <link href="/style.css" title="Default" rel="stylesheet" type="text/css" />
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<vlc id="if" param1="url_param"/>
<meta http-equiv="refresh" content="0;URL=/" />
<vlc id="end" />
<vlc id="control" param1="stop,pause,previous,next,add,sout,play,delete,empty,seek,fullscreen,keep,volume,sort,move" /> <vlc id="control" param1="stop,pause,previous,next,add,sout,play,delete,empty,seek,fullscreen,keep,volume,sort,move" />
<vlc id="set" param1="sout" param2="string" /> <vlc id="set" param1="sout" param2="string" />
</head> <script type="text/javascript">
<body> function changeMe(item)
{
if (item.parentNode.parentNode.lastChild.style.display=="none")
{
item.parentNode.parentNode.lastChild.style.display="block";
item.alt="[-]";
item.src="cone_minus.png";
}
else
{
item.parentNode.parentNode.lastChild.style.display="none";
item.alt="[+]";
item.src="cone_plus.png";
}
}
</script>
</head>
<body>
<!-- left menu --> <!-- left menu -->
<div class="left"> <div class="left">
<div class="sectitle">Playback control</div> <div class="sectitle">Playback control</div>
...@@ -90,18 +104,45 @@ ...@@ -90,18 +104,45 @@
</div> </div>
<div class="section"> <div class="section">
<table>
<tr>
<td>
<table>
<tr>
<td>
<form method="get" action=""> <form method="get" action="">
<ul id="playlist">
<vlc id="rpn" param1="first_item 0 store" />
<vlc id="rpn" param1="last_depth 0 store" />
<vlc id="foreach" param1="pl" param2="playlist" />
<vlc id="if" param1="pl.depth value last_depth value <" />
<vlc id="rpn" param1="pl.depth value ':' last_depth value 1 - ':' 1 strcat strcat strcat strcat" />
<vlc id="foreach" param1="the_final_countdown" param2="integer" />
</ul></li>
<vlc id="end" />
<vlc id="end" />
<vlc id="if" param1="pl.type value 'Node' strcmp" />
<vlc id="rpn" param1="1 +" />
<li>
<input type="checkbox" name="item" value="<vlc id="value" param1="pl.index" />"/>
<vlc id="if" param1="pl.current" />
<strong>
<vlc id="end" />
<a href="?control=play&amp;item=<vlc id="value" param1="pl.index" />">
<vlc id="value" param1="pl.name" /><vlc id="if" param1="pl.uri value pl.name value strcmp"/> (<vlc id="value" param1="pl.uri" />)<vlc id="end"/></a>
<vlc id="if" param1="pl.current" />
</strong>
<vlc id="end" />
</li>
<vlc id="else" />
<li>
<form method="get" action="">
<img alt="[-]" src="cone_minus.png" onclick='changeMe(this)'/>
<vlc id="if" param1="first_item value 0 ="/>
Playlist
<vlc id="rpn" param1="first_item 1 store" />
<vlc id="else"/>
<vlc id="value" param1="pl.name" /> (<vlc id="value" param1="pl.i_children" /> item<vlc id="if" param1="pl.i_children 1 >" />s<vlc id="end" />)
<vlc id="end"/>
<input type="hidden" name="item" value="<vlc id="value" param1="pl.index" />" />
<input type="submit" name="control" value="sort" /> by <input type="submit" name="control" value="sort" /> by
<select name="type"> <select name="type">
<option value="title">title</option> <option value="title">title</option>
<option value="group">group</option>
<option value="author">author</option>
<option value="shuffle">shuffle</option> <option value="shuffle">shuffle</option>
</select> with </select> with
<select name="order"> <select name="order">
...@@ -109,59 +150,35 @@ ...@@ -109,59 +150,35 @@
<option value="1">reverse order</option> <option value="1">reverse order</option>
</select> </select>
</form> </form>
</td>
<td> <vlc id="if" param1="pl.i_children 0 !=" />
<form method="get" action=""> <ul>
Move the item number <vlc id="else" />
<input type="text" name="psz_pos" size="5" /> to </li>
<input type="text" name="psz_newpos" size="5" />
<input type="submit" name="control" value="move" />
</form>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<form method="get" action="">
<table>
<vlc id="rpn" param1="0"/>
<vlc id="foreach" param1="pl" param2="playlist" />
<tr class="<vlc id="if" param1="pl.index 2 % 0 =" />line1<vlc id="else" />line2<vlc id="end" />">
<td>
<input type="checkbox" name="item" value="<vlc id="value" param1="pl.index" />"/>
<vlc id="if" param1="pl.current" />
<strong>
<vlc id="end" /> <vlc id="end" />
<a href="?control=play&amp;item=<vlc id="value" param1="pl.index" />">
<vlc id="value" param1="pl.index" /> - <vlc id="value" param1="pl.uri" /><vlc id="if" param1="pl.uri value pl.name value strcmp"/> (<vlc id="value" param1="pl.name" />)<vlc id="end"/></a>
<vlc id="if" param1="pl.current" />
</strong>
<vlc id="end" /> <vlc id="end" />
</td>
</tr> <vlc id="rpn" param1="last_depth pl.depth value store" />
<vlc id="rpn" param1="1 +"/>
<vlc id="end" /> <vlc id="end" />
<vlc id="if" param1="0 ="/> <vlc id="rpn" param1="0 ':' last_depth value 1 - ':' 1 strcat strcat strcat strcat" />
<tr class="ligne1"> <vlc id="foreach" param1="the_final_countdown" param2="integer" />
<td>empty playlist</td> </ul></li>
</tr> <vlc id="end" />
<vlc id="end"/>
</table> </ul>
<input type="submit" name="control" value="delete" /> <input type="submit" name="control" value="delete" />
<input type="submit" name="control" value="empty" />
<input type="submit" name="control" value="keep" /> <input type="submit" name="control" value="keep" />
</form> </form>
</td>
</tr>
</table>
</div> </div>
</div> </div>
<!-- end main content --> <!-- end main content -->
<p style="text-align:center;font-size:1.2em;"> <vlc id="value" param1="copyright" /> </p> <p style="text-align:center;font-size:1.2em;"> <vlc id="value" param1="copyright" /> </p>
<script language="javascript" type="text/javascript"> <script type="text/javascript">
got_time = <vlc id="value" param1="stream_time" />; got_time = <vlc id="value" param1="stream_time" />;
hours = Math.floor(got_time/ 3600); hours = Math.floor(got_time/ 3600);
minutes = Math.floor((got_time/60) % 60); minutes = Math.floor((got_time/60) % 60);
......
...@@ -88,3 +88,7 @@ form { ...@@ -88,3 +88,7 @@ form {
margin: 0pt; margin: 0pt;
padding: 0pt; padding: 0pt;
} }
ul#playlist, ul#playlist ul{
list-style-type: none;
}
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