给VLC的rc(remote control)加入VOD功能:(只添加vod,其它的也很容易加上)
原先VOD的控制只能够在telnet interface下才可以调用,但有些时候我们需要在rc下作控制,以下patch实现这个功能,具体实现很简单直接调用VLM的相关函数即可,所以configure的时候需要把VLM加上。diff如下,有同类需要的请参考。
diff --git a/modules/control/chenee.c b/modules/control/chenee.c
index f887a40..c878e21 100644
--- a/modules/control/chenee.c
+++ b/modules/control/chenee.c
@@ -56,6 +56,7 @@
#include <vlc_network.h>
#include <vlc_url.h>
+#include <vlc_vlm.h>
#include <vlc_charset.h>
@@ -148,6 +149,9 @@ struct intf_sys_t
#define msg_rc( ... ) __msg_rc( p_intf, __VA_ARGS__ )
+//chenee
+static vlm_t *mediatheque;
+
LIBVLC_FORMAT(2, 3)
static void __msg_rc( intf_thread_t *p_intf, const char *psz_fmt, ... )
{
@@ -384,6 +388,8 @@ static void RegisterCallbacks( intf_thread_t *p_intf )
ADD( "intf", STRING, Intf )
ADD( "add", STRING, Playlist )
+ ADD( "new_ch1", STRING, Playlist )
+ ADD( "del_ch1", STRING, Playlist )
ADD( "repeat", STRING, Playlist )
ADD( "loop", STRING, Playlist )
ADD( "random", STRING, Playlist )
@@ -463,6 +469,11 @@ static void Run( intf_thread_t *p_intf )
p_buffer[0] = 0;
+ if( !(mediatheque = vlm_New( p_intf )) )
+ {
+ msg_Err( p_intf, "cannot start VLM" );
+ }
+
/* Register commands that will be cleaned up upon object destruction */
p_intf->p_sys->p_playlist = p_playlist;
RegisterCallbacks( p_intf );
@@ -829,6 +840,7 @@ static void Run( intf_thread_t *p_intf )
vlc_object_release( p_input );
}
+ vlm_Delete( mediatheque );
pl_Release( p_intf );
var_DelCallback( p_intf->p_libvlc, "volume-change", VolumeChanged, p_intf );
@@ -889,6 +901,8 @@ static void Help( intf_thread_t *p_intf, bool b_longhelp)
msg_rc("%s", _("| strack [X] . . . . . . . . . set/get subtitles track"));
msg_rc("%s", _("| key [hotkey name] . . . . . . simulate hotkey press"));
msg_rc("%s", _("| menu . . [on|off|up|down|left|right|select] use menu"));
+ msg_rc("%s", _("| new_ch1. .filename ..... . . . . . add chanel 1 vod"));
+ msg_rc("%s", _("| del_ch1. . . . . . . . ......... . del chanel 1 vod"));
msg_rc( "| ");
if (b_longhelp)
@@ -1400,6 +1414,29 @@ static int Playlist( vlc_object_t *p_this, char const *psz_cmd,
}
}
}
+ //chenee come here!
+ else if( !strcmp( psz_cmd, "new_ch1" ) &&
+ newval.psz_string && *newval.psz_string )
+ {
+ input_item_t *p_item = parse_MRL( p_intf, newval.psz_string );
+
+ vlm_message_t *message;
+ char new1[] = "new ch1 vod enabled";
+ vlm_ExecuteCommand( mediatheque, new1, &message );
+ char addfile[1024];
+ sprintf(addfile,"setup ch1 input %s",newval.psz_string);
+ vlm_ExecuteCommand( mediatheque, addfile, &message );
+ printf("new the chanel 1/n");
+ vlm_MessageDelete( message );
+ }
+ else if( !strcmp( psz_cmd, "del_ch1" ) )
+ {
+ vlm_message_t *message;
+ char del1[] = "del ch1";
+ vlm_ExecuteCommand( mediatheque, del1, &message );
+ printf("del the chanel 1/n");
+ vlm_MessageDelete( message );
+ }
else if( !strcmp( psz_cmd, "enqueue" ) &&
newval.psz_string && *newval.psz_string )
{