[vlc-commits] libvlc: add libvlc_media_player_add_slave
Thomas Guillem
git at videolan.org
Tue May 31 16:23:35 CEST 2016
vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Fri May 27 12:05:33 2016 +0200| [bfbeee7e5c57bc94f4daf66243281764fba033aa] | committer: Thomas Guillem
libvlc: add libvlc_media_player_add_slave
In order to add a slave when the media player is playing.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=bfbeee7e5c57bc94f4daf66243281764fba033aa
---
include/vlc/libvlc_media.h | 2 +-
include/vlc/libvlc_media_player.h | 21 +++++++++++++++++++++
lib/media_player.c | 25 +++++++++++++++++++++++++
3 files changed, 47 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..8b1f593 100644
--- a/include/vlc/libvlc_media_player.h
+++ b/include/vlc/libvlc_media_player.h
@@ -955,6 +955,27 @@ 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 If the player is playing, the slave will be added directly. This call
+ * will also update the slave list of the attached libvlc_media_t.
+ *
+ * \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..a2be453 100644
--- a/lib/media_player.c
+++ b/lib/media_player.c
@@ -1891,6 +1891,31 @@ 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 )
+ {
+ libvlc_media_t *p_media = libvlc_media_player_get_media( p_mi );
+ if( p_media == NULL )
+ return -1;
+
+ int i_ret = libvlc_media_slaves_add( p_media, i_type, 4, psz_uri );
+ libvlc_media_release( p_media );
+ return i_ret;
+ }
+ else
+ {
+ 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.
*
More information about the vlc-commits
mailing list