[vlc-commits] lib: fix libvlc_media_player_set_renderer
Thomas Guillem
git at videolan.org
Fri Dec 1 15:11:58 CET 2017
vlc/vlc-3.0 | branch: master | Thomas Guillem <thomas at gllm.fr> | Fri Dec 1 15:06:07 2017 +0100| [f41ad8d916b79535861ca41ab0d510f933b04944] | committer: Thomas Guillem
lib: fix libvlc_media_player_set_renderer
Use the new input control: INPUT_SET_RENDERER to setup a renderer.
(cherry picked from commit 3eaa1607ec817bca17a9f446902a8c418885fffb)
> http://git.videolan.org/gitweb.cgi/vlc/vlc-3.0.git/?a=commit;h=f41ad8d916b79535861ca41ab0d510f933b04944
---
include/vlc/libvlc_media_player.h | 2 +-
lib/media_player.c | 28 +++++++++++++++++++---------
lib/media_player_internal.h | 1 +
lib/renderer_discoverer.c | 6 +++---
lib/renderer_discoverer_internal.h | 4 ++--
5 files changed, 26 insertions(+), 15 deletions(-)
diff --git a/include/vlc/libvlc_media_player.h b/include/vlc/libvlc_media_player.h
index 2e0b56c066..4336df9442 100644
--- a/include/vlc/libvlc_media_player.h
+++ b/include/vlc/libvlc_media_player.h
@@ -288,7 +288,7 @@ LIBVLC_API void libvlc_media_player_stop ( libvlc_media_player_t *p_mi );
* \version LibVLC 3.0.0 or later
*/
LIBVLC_API int libvlc_media_player_set_renderer( libvlc_media_player_t *p_mi,
- const libvlc_renderer_item_t *p_item );
+ libvlc_renderer_item_t *p_item );
/**
* Callback prototype to allocate and lock a picture buffer.
diff --git a/lib/media_player.c b/lib/media_player.c
index daef2faedd..3d159f7123 100644
--- a/lib/media_player.c
+++ b/lib/media_player.c
@@ -728,6 +728,7 @@ libvlc_media_player_new( libvlc_instance_t *instance )
mp->state = libvlc_NothingSpecial;
mp->p_libvlc_instance = instance;
mp->input.p_thread = NULL;
+ mp->input.p_renderer = NULL;
mp->input.p_resource = input_resource_New(VLC_OBJECT(mp));
if (unlikely(mp->input.p_resource == NULL))
{
@@ -808,6 +809,9 @@ static void libvlc_media_player_destroy( libvlc_media_player_t *p_mi )
release_input_thread(p_mi);
input_resource_Terminate( p_mi->input.p_resource );
input_resource_Release( p_mi->input.p_resource );
+ if( p_mi->input.p_renderer )
+ vlc_renderer_item_release( p_mi->input.p_renderer );
+
vlc_mutex_destroy( &p_mi->input.lock );
libvlc_event_manager_destroy(&p_mi->event_manager);
@@ -967,7 +971,8 @@ int libvlc_media_player_play( libvlc_media_player_t *p_mi )
media_attach_preparsed_event( p_mi->p_md );
p_input_thread = input_Create( p_mi, p_mi->p_md->p_input_item, NULL,
- p_mi->input.p_resource, NULL );
+ p_mi->input.p_resource,
+ p_mi->input.p_renderer );
unlock(p_mi);
if( !p_input_thread )
{
@@ -1064,16 +1069,21 @@ void libvlc_media_player_stop( libvlc_media_player_t *p_mi )
}
int libvlc_media_player_set_renderer( libvlc_media_player_t *p_mi,
- const libvlc_renderer_item_t *p_litem )
+ libvlc_renderer_item_t *p_litem )
{
- const vlc_renderer_item_t *p_item = libvlc_renderer_item_to_vlc( p_litem );
- char *psz_sout;
- if( asprintf( &psz_sout, "#%s", vlc_renderer_item_sout( p_item ) ) == -1 )
- return -1;
+ vlc_renderer_item_t *p_item =
+ p_litem ? libvlc_renderer_item_to_vlc( p_litem ) : NULL;
+
+ lock_input( p_mi );
+ input_thread_t *p_input_thread = p_mi->input.p_thread;
+ if( p_input_thread )
+ input_Control( p_input_thread, INPUT_SET_RENDERER, p_item );
+
+ if( p_mi->input.p_renderer )
+ vlc_renderer_item_release( p_mi->input.p_renderer );
+ p_mi->input.p_renderer = p_item ? vlc_renderer_item_hold( p_item ) : NULL;
+ unlock_input( p_mi );
- var_SetString( p_mi, "sout", psz_sout );
- var_SetString( p_mi, "demux-filter", vlc_renderer_item_demux_filter( p_item ) );
- free( psz_sout );
return 0;
}
diff --git a/lib/media_player_internal.h b/lib/media_player_internal.h
index a8475c673f..a9acff1766 100644
--- a/lib/media_player_internal.h
+++ b/lib/media_player_internal.h
@@ -47,6 +47,7 @@ struct libvlc_media_player_t
{
input_thread_t *p_thread;
input_resource_t *p_resource;
+ vlc_renderer_item_t *p_renderer;
vlc_mutex_t lock;
} input;
diff --git a/lib/renderer_discoverer.c b/lib/renderer_discoverer.c
index a9aaee35c5..f66f5d1e0c 100644
--- a/lib/renderer_discoverer.c
+++ b/lib/renderer_discoverer.c
@@ -47,10 +47,10 @@ static_assert( VLC_RENDERER_CAN_AUDIO == LIBVLC_RENDERER_CAN_AUDIO &&
VLC_RENDERER_CAN_VIDEO == LIBVLC_RENDERER_CAN_VIDEO,
"core/libvlc renderer flags mismatch" );
-const vlc_renderer_item_t *
-libvlc_renderer_item_to_vlc( const libvlc_renderer_item_t *p_item )
+vlc_renderer_item_t *
+libvlc_renderer_item_to_vlc( libvlc_renderer_item_t *p_item )
{
- return (const vlc_renderer_item_t*) p_item;
+ return (vlc_renderer_item_t*) p_item;
}
static void renderer_discovery_item_added( vlc_renderer_discovery_t *rd,
diff --git a/lib/renderer_discoverer_internal.h b/lib/renderer_discoverer_internal.h
index 880b92ef91..e84009b765 100644
--- a/lib/renderer_discoverer_internal.h
+++ b/lib/renderer_discoverer_internal.h
@@ -27,7 +27,7 @@
#include <vlc_renderer_discovery.h>
-const vlc_renderer_item_t *
-libvlc_renderer_item_to_vlc( const libvlc_renderer_item_t *p_item );
+vlc_renderer_item_t *
+libvlc_renderer_item_to_vlc( libvlc_renderer_item_t *p_item );
#endif
More information about the vlc-commits
mailing list