[vlc-devel] [PATCH 3/4] libvlc: add libvlc_media_player_add_slave
Thomas Guillem
thomas at gllm.fr
Fri May 27 12:45:15 CEST 2016
In order to add a slave when the media player is playing.
Maybe, this could be merged with libvlc_media_slaves_add() because the
difference between these 2 functions could be hard to understand for the user:
- libvlc_media_slaves_add() add slaves to a libvlc_media_t. Theses slaves will
be added to the input_thread when the media_player that play the medioa
will be playing. Slaves will be sorted by priority.
- libvlc_media_player_add_slave() add a slave to a playing
libvlc_media_player_t. This slave is directly added in the input_thread of
the media player. There is no priority in that case.
---
include/vlc/libvlc_media.h | 2 +-
include/vlc/libvlc_media_player.h | 22 ++++++++++++++++++++++
lib/media_player.c | 13 +++++++++++++
3 files changed, 36 insertions(+), 1 deletion(-)
diff --git a/include/vlc/libvlc_media.h b/include/vlc/libvlc_media.h
index bd8a9c4..a392368 100644
--- a/include/vlc/libvlc_media.h
+++ b/include/vlc/libvlc_media.h
@@ -786,9 +786,9 @@ libvlc_media_type_t libvlc_media_get_type( libvlc_media_t *p_md );
* \version LibVLC 3.0.0 and later.
*
* \param p_md media descriptor object
- * \param psz_uri Uri of the slave (should contain a valid scheme).
* \param i_type subtitle or audio
* \param i_priority from 0 (low priority) to 4 (high priority)
+ * \param psz_uri Uri of the slave (should contain a valid scheme).
*
* \return 0 on success, -1 on error.
*/
diff --git a/include/vlc/libvlc_media_player.h b/include/vlc/libvlc_media_player.h
index 456e99e..ce09027 100644
--- a/include/vlc/libvlc_media_player.h
+++ b/include/vlc/libvlc_media_player.h
@@ -955,6 +955,28 @@ LIBVLC_API void libvlc_media_player_navigate( libvlc_media_player_t* p_mi,
LIBVLC_API void libvlc_media_player_set_video_title_display( libvlc_media_player_t *p_mi, libvlc_position_t position, unsigned int timeout );
/**
+ * Add a slave to the current media player.
+ *
+ * \note This function must be called when the media player is playing. If you
+ * want to setup slaves before it's playing, you should use
+ * libvlc_media_slaves_add()
+ *
+ * \version LibVLC 3.0.0 and later.
+ *
+ * \see libvlc_media_slaves_add
+ *
+ * \param p_mi the media player
+ * \param i_type subtitle or audio
+ * \param psz_uri Uri of the slave (should contain a valid scheme).
+ *
+ * \return 0 on success, -1 on error.
+ */
+LIBVLC_API
+int libvlc_media_player_add_slave( libvlc_media_player_t *p_mi,
+ libvlc_media_slave_type_t i_type,
+ const char *psz_uri );
+
+/**
* Release (free) libvlc_track_description_t
*
* \param p_track_description the structure to release
diff --git a/lib/media_player.c b/lib/media_player.c
index b561daa..e1fa611 100644
--- a/lib/media_player.c
+++ b/lib/media_player.c
@@ -1891,6 +1891,19 @@ void libvlc_media_player_set_video_title_display( libvlc_media_player_t *p_mi, l
}
}
+int libvlc_media_player_add_slave( libvlc_media_player_t *p_mi,
+ libvlc_media_slave_type_t i_type,
+ const char *psz_uri )
+{
+ input_thread_t *p_input_thread = libvlc_get_input_thread ( p_mi );
+ if( p_input_thread == NULL )
+ return -1;
+
+ int i_ret = input_AddSlave( p_input_thread, i_type, psz_uri );
+ vlc_object_release( p_input_thread );
+ return i_ret == VLC_SUCCESS ? 0 : -1;
+}
+
/**
* Maximum size of a formatted equalizer amplification band frequency value.
*
--
2.8.1
More information about the vlc-devel
mailing list