mirror of
https://code.videolan.org/videolan/vlc
synced 2024-09-12 13:44:56 +02:00
Allows requesting active aout/vout from an input with associated events.
This commit is contained in:
parent
c884cebcac
commit
ba2c2b69c9
@ -545,9 +545,6 @@ typedef enum input_event_type_e
|
|||||||
/* "record" has changed */
|
/* "record" has changed */
|
||||||
INPUT_EVENT_RECORD,
|
INPUT_EVENT_RECORD,
|
||||||
|
|
||||||
/* A vout has been created/deleted by *the input* */
|
|
||||||
INPUT_EVENT_VOUT,
|
|
||||||
|
|
||||||
/* input_item_t media has changed */
|
/* input_item_t media has changed */
|
||||||
INPUT_EVENT_ITEM_META,
|
INPUT_EVENT_ITEM_META,
|
||||||
/* input_item_t info has changed */
|
/* input_item_t info has changed */
|
||||||
@ -571,6 +568,11 @@ typedef enum input_event_type_e
|
|||||||
/* cache" has changed */
|
/* cache" has changed */
|
||||||
INPUT_EVENT_CACHE,
|
INPUT_EVENT_CACHE,
|
||||||
|
|
||||||
|
/* A aout_instance_t object has been created/deleted by *the input* */
|
||||||
|
INPUT_EVENT_AOUT,
|
||||||
|
/* A vout_thread_t object has been created/deleted by *the input* */
|
||||||
|
INPUT_EVENT_VOUT,
|
||||||
|
|
||||||
} input_event_type_e;
|
} input_event_type_e;
|
||||||
|
|
||||||
/** @}*/
|
/** @}*/
|
||||||
@ -584,12 +586,13 @@ typedef enum input_event_type_e
|
|||||||
#define input_CreateThread(a,b) __input_CreateThread(VLC_OBJECT(a),b)
|
#define input_CreateThread(a,b) __input_CreateThread(VLC_OBJECT(a),b)
|
||||||
VLC_EXPORT( input_thread_t *, __input_CreateThread, ( vlc_object_t *, input_item_t * ) );
|
VLC_EXPORT( input_thread_t *, __input_CreateThread, ( vlc_object_t *, input_item_t * ) );
|
||||||
|
|
||||||
|
VLC_EXPORT( void, input_StopThread, ( input_thread_t * ) );
|
||||||
|
|
||||||
#define input_Preparse(a,b) __input_Preparse(VLC_OBJECT(a),b)
|
#define input_Preparse(a,b) __input_Preparse(VLC_OBJECT(a),b)
|
||||||
VLC_EXPORT( int, __input_Preparse, ( vlc_object_t *, input_item_t * ) );
|
VLC_EXPORT( int, __input_Preparse, ( vlc_object_t *, input_item_t * ) );
|
||||||
|
|
||||||
#define input_Read(a,b,c) __input_Read(VLC_OBJECT(a),b, c)
|
#define input_Read(a,b,c) __input_Read(VLC_OBJECT(a),b, c)
|
||||||
VLC_EXPORT( int, __input_Read, ( vlc_object_t *, input_item_t *, bool ) );
|
VLC_EXPORT( int, __input_Read, ( vlc_object_t *, input_item_t *, bool ) );
|
||||||
VLC_EXPORT( void, input_StopThread, ( input_thread_t * ) );
|
|
||||||
|
|
||||||
enum input_query_e
|
enum input_query_e
|
||||||
{
|
{
|
||||||
@ -653,6 +656,11 @@ enum input_query_e
|
|||||||
|
|
||||||
/* ES */
|
/* ES */
|
||||||
INPUT_RESTART_ES, /* arg1=int (-AUDIO/VIDEO/SPU_ES for the whole category) */
|
INPUT_RESTART_ES, /* arg1=int (-AUDIO/VIDEO/SPU_ES for the whole category) */
|
||||||
|
|
||||||
|
/* Input ressources
|
||||||
|
* XXX You must call vlc_object_release as soon as possible */
|
||||||
|
INPUT_GET_AOUT, /* arg1=aout_instance_t ** res=can fail */
|
||||||
|
INPUT_GET_VOUTS, /* arg1=vout_thread_t ***, int * res=can fail */
|
||||||
};
|
};
|
||||||
|
|
||||||
VLC_EXPORT( int, input_vaControl,( input_thread_t *, int i_query, va_list ) );
|
VLC_EXPORT( int, input_vaControl,( input_thread_t *, int i_query, va_list ) );
|
||||||
|
@ -32,6 +32,7 @@
|
|||||||
|
|
||||||
#include "input_internal.h"
|
#include "input_internal.h"
|
||||||
#include "event.h"
|
#include "event.h"
|
||||||
|
#include "ressource.h"
|
||||||
|
|
||||||
|
|
||||||
static void UpdateBookmarksOption( input_thread_t * );
|
static void UpdateBookmarksOption( input_thread_t * );
|
||||||
@ -412,6 +413,28 @@ int input_vaControl( input_thread_t *p_input, int i_query, va_list args )
|
|||||||
input_ControlPush( p_input, INPUT_CONTROL_RESTART_ES, &val );
|
input_ControlPush( p_input, INPUT_CONTROL_RESTART_ES, &val );
|
||||||
return VLC_SUCCESS;
|
return VLC_SUCCESS;
|
||||||
|
|
||||||
|
case INPUT_GET_AOUT:
|
||||||
|
{
|
||||||
|
aout_instance_t *p_aout = input_ressource_HoldAout( p_input->p->p_ressource );
|
||||||
|
if( !p_aout )
|
||||||
|
return VLC_EGENERIC;
|
||||||
|
|
||||||
|
aout_instance_t **pp_aout = (aout_instance_t**)va_arg( args, aout_instance_t** );
|
||||||
|
*pp_aout = p_aout;
|
||||||
|
return VLC_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
case INPUT_GET_VOUTS:
|
||||||
|
{
|
||||||
|
vout_thread_t ***ppp_vout = (vout_thread_t***)va_arg( args, vout_thread_t*** );
|
||||||
|
int *pi_vout = (int*)va_arg( args, int* );
|
||||||
|
|
||||||
|
input_ressource_HoldVouts( p_input->p->p_ressource, ppp_vout, pi_vout );
|
||||||
|
if( *pi_vout <= 0 )
|
||||||
|
return VLC_EGENERIC;
|
||||||
|
return VLC_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
msg_Err( p_input, "unknown query in input_vaControl" );
|
msg_Err( p_input, "unknown query in input_vaControl" );
|
||||||
return VLC_EGENERIC;
|
return VLC_EGENERIC;
|
||||||
|
@ -2032,6 +2032,7 @@ static void DeleteDecoder( decoder_t * p_dec )
|
|||||||
{
|
{
|
||||||
input_ressource_RequestAout( p_owner->p_input->p->p_ressource,
|
input_ressource_RequestAout( p_owner->p_input->p->p_ressource,
|
||||||
p_owner->p_aout );
|
p_owner->p_aout );
|
||||||
|
input_SendEventAout( p_owner->p_input );
|
||||||
p_owner->p_aout = NULL;
|
p_owner->p_aout = NULL;
|
||||||
}
|
}
|
||||||
if( p_owner->p_vout )
|
if( p_owner->p_vout )
|
||||||
@ -2039,7 +2040,7 @@ static void DeleteDecoder( decoder_t * p_dec )
|
|||||||
/* Hack to make sure all the the pictures are freed by the decoder */
|
/* Hack to make sure all the the pictures are freed by the decoder */
|
||||||
vout_FixLeaks( p_owner->p_vout, true );
|
vout_FixLeaks( p_owner->p_vout, true );
|
||||||
|
|
||||||
/* We are about to die. Reattach video output to p_vlc. */
|
/* */
|
||||||
input_ressource_RequestVout( p_owner->p_input->p->p_ressource, p_owner->p_vout, NULL );
|
input_ressource_RequestVout( p_owner->p_input->p->p_ressource, p_owner->p_vout, NULL );
|
||||||
input_SendEventVout( p_owner->p_input );
|
input_SendEventVout( p_owner->p_input );
|
||||||
}
|
}
|
||||||
@ -2195,6 +2196,8 @@ static aout_buffer_t *aout_new_buffer( decoder_t *p_dec, int i_samples )
|
|||||||
|
|
||||||
vlc_mutex_unlock( &p_owner->lock );
|
vlc_mutex_unlock( &p_owner->lock );
|
||||||
|
|
||||||
|
input_SendEventAout( p_owner->p_input );
|
||||||
|
|
||||||
if( p_owner->p_aout_input == NULL )
|
if( p_owner->p_aout_input == NULL )
|
||||||
{
|
{
|
||||||
msg_Err( p_dec, "failed to create audio output" );
|
msg_Err( p_dec, "failed to create audio output" );
|
||||||
|
@ -319,6 +319,11 @@ void input_SendEventVout( input_thread_t *p_input )
|
|||||||
Trigger( p_input, INPUT_EVENT_VOUT );
|
Trigger( p_input, INPUT_EVENT_VOUT );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void input_SendEventAout( input_thread_t *p_input )
|
||||||
|
{
|
||||||
|
Trigger( p_input, INPUT_EVENT_AOUT );
|
||||||
|
}
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
* Event for control.c/input.c
|
* Event for control.c/input.c
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
@ -69,6 +69,7 @@ void input_SendEventTeletext( input_thread_t *p_input, int i_id );
|
|||||||
* Event for decoder.c
|
* Event for decoder.c
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
void input_SendEventVout( input_thread_t *p_input );
|
void input_SendEventVout( input_thread_t *p_input );
|
||||||
|
void input_SendEventAout( input_thread_t *p_input );
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
* Event for control.c/input.c
|
* Event for control.c/input.c
|
||||||
|
@ -189,6 +189,28 @@ static vout_thread_t *HoldVout( input_ressource_t *p_ressource )
|
|||||||
|
|
||||||
return p_vout;
|
return p_vout;
|
||||||
}
|
}
|
||||||
|
static void HoldVouts( input_ressource_t *p_ressource, vout_thread_t ***ppp_vout, int *pi_vout )
|
||||||
|
{
|
||||||
|
vout_thread_t **pp_vout;
|
||||||
|
|
||||||
|
*pi_vout = 0;
|
||||||
|
*ppp_vout = NULL;
|
||||||
|
if( p_ressource->i_vout <= 0 )
|
||||||
|
return;
|
||||||
|
|
||||||
|
pp_vout = calloc( p_ressource->i_vout, sizeof(*pp_vout) );
|
||||||
|
if( !pp_vout )
|
||||||
|
return;
|
||||||
|
|
||||||
|
*ppp_vout = pp_vout;
|
||||||
|
*pi_vout = p_ressource->i_vout;
|
||||||
|
|
||||||
|
for( int i = 0; i < p_ressource->i_vout; i++ )
|
||||||
|
{
|
||||||
|
pp_vout[i] = p_ressource->pp_vout[i];
|
||||||
|
vlc_object_hold( pp_vout[i] );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* */
|
/* */
|
||||||
static void DestroyAout( input_ressource_t *p_ressource )
|
static void DestroyAout( input_ressource_t *p_ressource )
|
||||||
@ -228,7 +250,18 @@ static aout_instance_t *RequestAout( input_ressource_t *p_ressource, aout_instan
|
|||||||
return p_ressource->p_aout;
|
return p_ressource->p_aout;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
static aout_instance_t *HoldAout( input_ressource_t *p_ressource )
|
||||||
|
{
|
||||||
|
if( !p_ressource->p_aout )
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
/* TODO FIXME: p_ressource->pp_vout order is NOT stable */
|
||||||
|
aout_instance_t *p_aout = p_ressource->p_aout;
|
||||||
|
|
||||||
|
vlc_object_hold( p_aout );
|
||||||
|
|
||||||
|
return p_aout;
|
||||||
|
}
|
||||||
/* */
|
/* */
|
||||||
input_ressource_t *input_ressource_New( void )
|
input_ressource_t *input_ressource_New( void )
|
||||||
{
|
{
|
||||||
@ -290,6 +323,12 @@ vout_thread_t *input_ressource_HoldVout( input_ressource_t *p_ressource )
|
|||||||
|
|
||||||
return p_ret;
|
return p_ret;
|
||||||
}
|
}
|
||||||
|
void input_ressource_HoldVouts( input_ressource_t *p_ressource, vout_thread_t ***ppp_vout, int *pi_vout )
|
||||||
|
{
|
||||||
|
vlc_mutex_lock( &p_ressource->lock );
|
||||||
|
HoldVouts( p_ressource, ppp_vout, pi_vout );
|
||||||
|
vlc_mutex_unlock( &p_ressource->lock );
|
||||||
|
}
|
||||||
void input_ressource_TerminateVout( input_ressource_t *p_ressource )
|
void input_ressource_TerminateVout( input_ressource_t *p_ressource )
|
||||||
{
|
{
|
||||||
input_ressource_RequestVout( p_ressource, NULL, NULL );
|
input_ressource_RequestVout( p_ressource, NULL, NULL );
|
||||||
@ -304,7 +343,14 @@ aout_instance_t *input_ressource_RequestAout( input_ressource_t *p_ressource, ao
|
|||||||
|
|
||||||
return p_ret;
|
return p_ret;
|
||||||
}
|
}
|
||||||
|
aout_instance_t *input_ressource_HoldAout( input_ressource_t *p_ressource )
|
||||||
|
{
|
||||||
|
vlc_mutex_lock( &p_ressource->lock );
|
||||||
|
aout_instance_t *p_ret = HoldAout( p_ressource );
|
||||||
|
vlc_mutex_unlock( &p_ressource->lock );
|
||||||
|
|
||||||
|
return p_ret;
|
||||||
|
}
|
||||||
/* */
|
/* */
|
||||||
sout_instance_t *input_ressource_RequestSout( input_ressource_t *p_ressource, sout_instance_t *p_sout, const char *psz_sout )
|
sout_instance_t *input_ressource_RequestSout( input_ressource_t *p_ressource, sout_instance_t *p_sout, const char *psz_sout )
|
||||||
{
|
{
|
||||||
|
@ -50,17 +50,31 @@ sout_instance_t *input_ressource_RequestSout( input_ressource_t *, sout_instance
|
|||||||
*/
|
*/
|
||||||
aout_instance_t *input_ressource_RequestAout( input_ressource_t *, aout_instance_t * );
|
aout_instance_t *input_ressource_RequestAout( input_ressource_t *, aout_instance_t * );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This function return the current aout if any.
|
||||||
|
*
|
||||||
|
* You must call vlc_object_release on the value returned (if non NULL).
|
||||||
|
*/
|
||||||
|
aout_instance_t *input_ressource_HoldAout( input_ressource_t *p_ressource );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function handles vout request.
|
* This function handles vout request.
|
||||||
*/
|
*/
|
||||||
vout_thread_t *input_ressource_RequestVout( input_ressource_t *, vout_thread_t *, video_format_t * );
|
vout_thread_t *input_ressource_RequestVout( input_ressource_t *, vout_thread_t *, video_format_t * );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function return the current vout if any.
|
* This function return one of the current vout if any.
|
||||||
*
|
*
|
||||||
* You must call vlc_object_release on the value returned (if non NULL).
|
* You must call vlc_object_release on the value returned (if non NULL).
|
||||||
*/
|
*/
|
||||||
vout_thread_t *input_ressource_HoldVout( input_ressource_t * );
|
vout_thread_t *input_ressource_HoldVout( input_ressource_t * );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This function return all current vouts if any.
|
||||||
|
*
|
||||||
|
* You must call vlc_object_release on all values returned (if non NULL).
|
||||||
|
*/
|
||||||
|
void input_ressource_HoldVouts( input_ressource_t *, vout_thread_t ***, int * );
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user