Commit f41ad8d9 authored by Thomas Guillem's avatar 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 3eaa1607)
parent 31f2a813
......@@ -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.
......
......@@ -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;
}
......
......@@ -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;
......
......@@ -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,
......
......@@ -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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment