]> git.sesse.net Git - vlc/commitdiff
More VLM API stuff
authorClément Stenac <zorglub@videolan.org>
Wed, 15 Feb 2006 22:31:49 +0000 (22:31 +0000)
committerClément Stenac <zorglub@videolan.org>
Wed, 15 Feb 2006 22:31:49 +0000 (22:31 +0000)
include/vlc/libvlc.h
src/control/vlm.c
test/native/libvlc.c

index 08d5dab1038f4e0a9aa00835a3ddb050dc3bed71..ada485e5ca05db985e78113303f856bf82a14e08 100644 (file)
@@ -346,6 +346,42 @@ void libvlc_vlm_del_media( libvlc_instance_t *, char *, libvlc_exception_t * );
 void libvlc_vlm_set_enabled( libvlc_instance_t *, char *, int,
                              libvlc_exception_t *);
 
+/**
+ * Set the output for a media
+ * \param p_instance the instance
+ * \param psz_name the media to work on
+ * \param psz_output the output MRL (the parameter to the "sout" variable)
+ * \param p_exception an initialized exception
+ */
+void libvlc_vlm_set_output( libvlc_instance_t *, char *, char*,
+                            libvlc_exception_t *);
+
+/**
+ * Set a media's input MRL. This will delete all existing inputs and
+ * add the specified one.
+ * \param p_instance the instance
+ * \param psz_name the media to work on
+ * \param psz_input the input MRL
+ * \param p_exception an initialized exception
+ */
+void libvlc_vlm_set_input( libvlc_instance_t *, char *, char*,
+                           libvlc_exception_t *);
+
+
+
+/**
+ * Set output for a media
+ * \param p_instance the instance
+ * \param psz_name the media to work on
+ * \param b_loop the new status
+ * \param p_exception an initialized exception
+ */
+void libvlc_vlm_set_loop( libvlc_instance_t *, char *, int,
+                          libvlc_exception_t *);
+
+
+
+
 /**
  * Edit the parameters of a media. This will delete all existing inputs and
  * add the specified one.
index 6c95f7a5bd498cba9732a8c354d18cf8e460267e..f95c79fbda2a8678c74cda6ff56033bf3f4e1deb 100644 (file)
@@ -39,6 +39,13 @@ void InitVLM( libvlc_instance_t *p_instance )
                       libvlc_exception_raise( p_exception, \
                                          "Unable to create VLM" ); return; } }
 
+#define GET_MEDIA { p_media = vlm_MediaSearch( p_instance->p_vlm, psz_name );\
+                   if( !p_media ) \
+                   { \
+                        libvlc_exception_raise( p_exception, \
+                                                "Media %s does not exist", \
+                                                psz_name ); return; } }
+
 void libvlc_vlm_add_broadcast( libvlc_instance_t *p_instance, char *psz_name,
                                char *psz_input, char *psz_output,
                                int i_options, char **ppsz_options,
@@ -82,36 +89,103 @@ void libvlc_vlm_set_enabled( libvlc_instance_t *p_instance, char *psz_name,
 {
     vlm_media_t *p_media;
     CHECK_VLM;
-
+    GET_MEDIA;
     if( b_enabled != 0 ) b_enabled = 1;
-
-    p_media = vlm_MediaSearch( p_instance->p_vlm, psz_name );
-    if( !p_media )
-    {
-        libvlc_exception_raise( p_exception, "Media %s does not exist",
-                                psz_name );
-        return;
-    }
     p_media->b_enabled = b_enabled;
 }
 
+void libvlc_vlm_set_loop( libvlc_instance_t *p_instance, char *psz_name,
+                          int b_loop, libvlc_exception_t *p_exception )
+{
+    vlm_media_t *p_media;
+    CHECK_VLM;
+    GET_MEDIA;
+    if( b_loop != 0 ) b_loop = 1;
+    p_media->b_loop = b_loop;
+}
+
+void libvlc_vlm_set_output( libvlc_instance_t *p_instance, char *psz_name,
+                            char *psz_output,  libvlc_exception_t *p_exception )
+{
+    vlm_media_t *p_media;
+    int i_ret;
+    CHECK_VLM;
+    GET_MEDIA;
+
+    vlc_mutex_lock( &p_instance->p_vlm->lock );
+    i_ret = vlm_MediaSetup( p_instance->p_vlm, p_media, "output", psz_output );
+    if( i_ret )
+    { libvlc_exception_raise( p_exception, "Unable to set output" ); return;}
+    vlc_mutex_unlock( &p_instance->p_vlm->lock );
+}
+
+void libvlc_vlm_set_input( libvlc_instance_t *p_instance, char *psz_name,
+                           char *psz_input,  libvlc_exception_t *p_exception )
+{
+    vlm_media_t *p_media;
+    int i_ret;
+    CHECK_VLM;
+    GET_MEDIA;
+
+    vlc_mutex_lock( &p_instance->p_vlm->lock );
+
+    vlm_MediaSetup( p_instance->p_vlm, p_media, "inputdel", "all" );
+    if( i_ret )
+    { libvlc_exception_raise( p_exception, "Unable to change input" ); return;}
+    vlm_MediaSetup( p_instance->p_vlm, p_media, "input", psz_input );
+    if( i_ret )
+    { libvlc_exception_raise( p_exception, "Unable to change input" ); return;}
+
+    vlc_mutex_unlock( &p_instance->p_vlm->lock );
+}
+
+void libvlc_vlm_add_input( libvlc_instance_t *p_instance, char *psz_name,
+                           char *psz_input,  libvlc_exception_t *p_exception )
+{
+    vlm_media_t *p_media;
+    int i_ret;
+    CHECK_VLM;
+    GET_MEDIA;
+
+    vlc_mutex_lock( &p_instance->p_vlm->lock );
+
+    vlm_MediaSetup( p_instance->p_vlm, p_media, "input", psz_input );
+    if( i_ret )
+    { libvlc_exception_raise( p_exception, "Unable to change input" ); return;}
+
+    vlc_mutex_unlock( &p_instance->p_vlm->lock );
+}
+
+
+
+
 void libvlc_vlm_change_media( libvlc_instance_t *p_instance, char *psz_name,
                               char *psz_input, char *psz_output, int i_options,
                               char **ppsz_options, int b_enabled, int b_loop,
                               libvlc_exception_t *p_exception )
 {
     vlm_media_t *p_media;
+    int i_ret;
     CHECK_VLM;
+    GET_MEDIA;
     if( b_enabled != 0 ) b_enabled = 1;
     if( b_loop != 0 ) b_loop = 1;
 
-    p_media = vlm_MediaSearch( p_instance->p_vlm, psz_name );
-    if( !p_media )
-    {
-        libvlc_exception_raise( p_exception, "Media %s does not exist",
-                                psz_name );
-        return;
-    }
+    vlc_mutex_lock( &p_instance->p_vlm->lock );
+    i_ret = vlm_MediaSetup( p_instance->p_vlm, p_media, "output", psz_output );
+    if( i_ret ) libvlc_exception_raise( p_exception, "Unable to set output" );
     p_media->b_enabled = b_enabled;
     p_media->b_loop = b_loop;
+
+    i_ret = vlm_MediaSetup( p_instance->p_vlm, p_media, "output", psz_output );
+    if( i_ret )
+    { libvlc_exception_raise( p_exception, "Unable to set output" ); return;}
+    vlm_MediaSetup( p_instance->p_vlm, p_media, "inputdel", "all" );
+    if( i_ret )
+    { libvlc_exception_raise( p_exception, "Unable to change input" ); return;}
+    vlm_MediaSetup( p_instance->p_vlm, p_media, "input", psz_input );
+    if( i_ret )
+    { libvlc_exception_raise( p_exception, "Unable to change input" ); return;}
+
+    vlc_mutex_unlock( &p_instance->p_vlm->lock );
 }
index b3d96726650c6e9270406d9f9f76809ca619fa1f..b29ed3303e8a2343dab66fca58526b1296c234a3 100644 (file)
@@ -93,15 +93,55 @@ static PyObject *vlm_test( PyObject *self, PyObject *args )
 {
     libvlc_instance_t *p_instance;
     char *argv[] = { "vlc", "--quiet" };
+    char *ppsz_empty[] = {};
     libvlc_exception_t exception;
     libvlc_exception_init( &exception );
 
     p_instance = libvlc_new( 2, argv, &exception );
     ASSERT_NOEXCEPTION;
-   
+  
+    /* Test that working on unexisting streams fail */
     libvlc_vlm_set_enabled( p_instance, "test", 1, &exception );
     ASSERT_EXCEPTION;
     libvlc_exception_clear( &exception );
+    libvlc_vlm_set_input( p_instance, "test", "input", &exception );
+    ASSERT_EXCEPTION;
+    libvlc_exception_clear( &exception );
+    libvlc_vlm_del_media( p_instance, "test", &exception );
+    ASSERT_EXCEPTION;
+    libvlc_exception_clear( &exception );
+
+    /*******  Broadcast *******/
+    /* Now create a media */
+    libvlc_vlm_add_broadcast( p_instance, "test", "input_test", "output_test",
+                              0, ppsz_empty, 1, 1, &exception );
+    ASSERT_NOEXCEPTION;
+    libvlc_exception_clear( &exception );
+
+    /* Change its parameters */
+    libvlc_vlm_set_enabled( p_instance, "test", 0, &exception );
+    ASSERT_NOEXCEPTION;
+    libvlc_exception_clear( &exception );
+    libvlc_vlm_set_output( p_instance, "test", "output_test2", &exception );
+    ASSERT_NOEXCEPTION;
+    libvlc_exception_clear( &exception );
+
+    /* Check the parameters */
+    fprintf( stderr, "The code for this is not written yet\n");
+
+    /* Control it a bit */
+    fprintf( stderr, "The code for this is not written yet\n");
+
+    /* Try to delete it */
+    libvlc_vlm_del_media( p_instance, "test", &exception );
+    ASSERT_NOEXCEPTION;
+    libvlc_exception_clear( &exception );
+
+    libvlc_vlm_del_media( p_instance, "test", &exception );
+    ASSERT_EXCEPTION;
+    libvlc_exception_clear( &exception );
+
+    /*******  VOD *******/
 
     Py_INCREF( Py_None );
     return Py_None;