]> git.sesse.net Git - vlc/blobdiff - src/control/media_descriptor.c
control/media_instance.c: Silly debug code removal (thanks funman).
[vlc] / src / control / media_descriptor.c
index 953eecb9004b696476c61952df3835bb7c971980..2c4fee065e29f9e3103c6b977a6523a674478557 100644 (file)
@@ -248,7 +248,9 @@ libvlc_media_descriptor_t * libvlc_media_descriptor_new_from_input_item(
     p_md->p_input_item      = p_input_item;
     p_md->b_preparsed       = VLC_FALSE;
     p_md->i_refcount        = 1;
-    p_md->p_user_data       = NULL; // VLC.framework hook
+    p_md->p_user_data       = NULL;
+
+    p_md->state = libvlc_NothingSpecial;
 
     /* A media descriptor can be a playlist. When you open a playlist
      * It can give a bunch of item to read. */
@@ -261,8 +263,12 @@ libvlc_media_descriptor_t * libvlc_media_descriptor_new_from_input_item(
         libvlc_MediaDescriptorMetaChanged, p_e );
     libvlc_event_manager_register_event_type( p_md->p_event_manager,
         libvlc_MediaDescriptorSubItemAdded, p_e );
+    libvlc_event_manager_register_event_type( p_md->p_event_manager,
+        libvlc_MediaDescriptorFreed, p_e );
     libvlc_event_manager_register_event_type( p_md->p_event_manager,
         libvlc_MediaDescriptorDurationChanged, p_e );
+    libvlc_event_manager_register_event_type( p_md->p_event_manager,
+        libvlc_MediaDescriptorStateChanged, p_e );
 
     vlc_gc_incref( p_md->p_input_item );
 
@@ -293,9 +299,56 @@ libvlc_media_descriptor_t * libvlc_media_descriptor_new(
     p_md = libvlc_media_descriptor_new_from_input_item( p_instance,
                 p_input_item, p_e );
 
+    /* The p_input_item is retained in libvlc_media_descriptor_new_from_input_item */
+    vlc_gc_decref( p_input_item );
+    
     return p_md;
 }
 
+/**************************************************************************
+ * Create a new media descriptor object
+ **************************************************************************/
+libvlc_media_descriptor_t * libvlc_media_descriptor_new_as_node(
+                                   libvlc_instance_t *p_instance,
+                                   const char * psz_name,
+                                   libvlc_exception_t *p_e )
+{
+    input_item_t * p_input_item;
+    libvlc_media_descriptor_t * p_md;
+
+    p_input_item = input_ItemNew( p_instance->p_libvlc_int, "vlc:nop", psz_name );
+
+    if (!p_input_item)
+    {
+        libvlc_exception_raise( p_e, "Can't create md's input_item" );
+        return NULL;
+    }
+
+    p_md = libvlc_media_descriptor_new_from_input_item( p_instance,
+                p_input_item, p_e );
+
+    p_md->p_subitems = libvlc_media_list_new( p_md->p_libvlc_instance, NULL );
+
+    return p_md;
+}
+
+/**************************************************************************
+ * Add an option to the media descriptor,
+ * that will be used to determine how the media_instance will read the
+ * media_descriptor. This allow to use VLC advanced reading/streaming
+ * options in a per-media basis
+ *
+ * The options are detailled in vlc --long-help, for instance "--sout-all"
+ **************************************************************************/
+void libvlc_media_descriptor_add_option(
+                                   libvlc_media_descriptor_t * p_md,
+                                   const char * ppsz_option,
+                                   libvlc_exception_t *p_e )
+{
+    (void)p_e;
+    input_ItemAddOptionNoDup( p_md->p_input_item, ppsz_option );
+}
+
 /**************************************************************************
  * Delete a media descriptor object
  **************************************************************************/
@@ -316,6 +369,16 @@ void libvlc_media_descriptor_release( libvlc_media_descriptor_t *p_md )
     uninstall_input_item_observer( p_md );
     vlc_gc_decref( p_md->p_input_item );
 
+    /* Construct the event */
+    libvlc_event_t event;
+    event.type = libvlc_MediaDescriptorFreed;
+    event.u.media_descriptor_freed.md = p_md;
+
+    /* Send the event */
+    libvlc_event_send( p_md->p_event_manager, &event );
+
+    libvlc_event_manager_release( p_md->p_event_manager );
+
     char ** all_keys = vlc_dictionary_all_keys( &p_md->tags );
     for( i = 0; all_keys[i]; i++ )
     {
@@ -391,6 +454,41 @@ char * libvlc_media_descriptor_get_meta( libvlc_media_descriptor_t *p_md,
     return psz_meta;
 }
 
+/**************************************************************************
+ * Getter for state information
+ * Can be error, playing, buffering, NothingSpecial.
+ **************************************************************************/
+
+libvlc_state_t
+libvlc_media_descriptor_get_state( libvlc_media_descriptor_t *p_md,
+                                   libvlc_exception_t *p_e )
+{
+    (void)p_e;
+    return p_md->state;
+}
+
+/**************************************************************************
+ * Setter for state information (LibVLC Internal)
+ **************************************************************************/
+
+void
+libvlc_media_descriptor_set_state( libvlc_media_descriptor_t *p_md,
+                                   libvlc_state_t state,
+                                   libvlc_exception_t *p_e )
+{
+    (void)p_e;
+    libvlc_event_t event;
+
+    p_md->state = state;
+
+    /* Construct the event */
+    event.type = libvlc_MediaDescriptorStateChanged;
+    event.u.media_descriptor_state_changed.new_state = state;
+
+    /* Send the event */
+    libvlc_event_send( p_md->p_event_manager, &event );
+}
+
 /**************************************************************************
  * Add a tag
  **************************************************************************/
@@ -584,4 +682,5 @@ libvlc_media_descriptor_get_user_data( libvlc_media_descriptor_t * p_md,
     {
         return NULL;
     }
-}
\ No newline at end of file
+}
+