[vlc-devel] [PATCH 5/6] demux: add control calls to read the demuxer title/seekpoint
Steve Lhomme
robux4 at gmail.com
Fri Jun 10 14:20:13 CEST 2016
On Thu, Jun 9, 2016 at 8:13 PM, Rémi Denis-Courmont <remi at remlab.net> wrote:
> On Tuesday 07 June 2016 11:15:17 Steve Lhomme wrote:
>> this will become handy with the demux filters
>
> TBH, to handle asynchronous updates correctly, event callbacks would be
> required; this is especially true for pf_demux-less/threaded demuxers.
The problem with event callbacks is that the receiver needs to take
care of what thread is calling the callback and it may not want to
handle the event right away. That's probably a lot of complexity added
for a problem we don't have yet.
>> ---
>> include/vlc_demux.h | 5 ++++
>> src/input/demux.c | 68
>> ++++++++++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 70
>> insertions(+), 3 deletions(-)
>>
>> diff --git a/include/vlc_demux.h b/include/vlc_demux.h
>> index f4baeea..9a74908 100644
>> --- a/include/vlc_demux.h
>> +++ b/include/vlc_demux.h
>> @@ -187,6 +187,11 @@ enum demux_query_e
>> * arg1= int */
>> DEMUX_SET_SEEKPOINT, /* arg1= int can fail */
>>
>> + DEMUX_GET_UPDATE_FLAGS, /* arg1= int* can fail */
>> + DEMUX_CLEAR_UPDATE_FLAGS, /* arg1= const int* can fail */
>
>> + DEMUX_GET_TITLE, /* arg1= int* can fail */
>> + DEMUX_GET_SEEKPOINT, /* arg1= int* can fail */
>> +
>> /* I. Common queries to access_demux and demux */
>> /* POSITION double between 0.0 and 1.0 */
>> DEMUX_GET_POSITION = 0x300, /* arg1= double * res= */
>> diff --git a/src/input/demux.c b/src/input/demux.c
>> index baf1880..9178928 100644
>> --- a/src/input/demux.c
>> +++ b/src/input/demux.c
>> @@ -416,6 +416,58 @@ int demux_vaControl( demux_t *demux, int query, va_list
>> args ) }
>> }
>>
>> + switch( query )
>> + {
>> + case DEMUX_GET_UPDATE_FLAGS:
>> + {
>> + int ret;
>> + va_list ap;
>> +
>> + va_copy( ap, args );
>
> Why? Ditto below.
Because items in 'args' may have been skipped during the pf_control
call (whether it fails or succeeds). But we only need to access the
item on failure so I'll make it work that way.
>> + ret = demux->pf_control( demux, query, args );
>> + if (ret != VLC_SUCCESS)
>> + *va_arg( ap, int * ) = demux->info.i_update;
>> + va_end( ap );
>> + return VLC_SUCCESS;
>> + }
>> + case DEMUX_CLEAR_UPDATE_FLAGS:
>> + {
>> + int ret;
>> + va_list ap;
>> +
>> + va_copy( ap, args );
>> + ret = demux->pf_control( demux, query, args );
>> + if (ret != VLC_SUCCESS)
>> + demux->info.i_update &= ~(*va_arg( ap, const int * ));
>> + va_end( ap );
>> + return VLC_SUCCESS;
>> + }
>> + case DEMUX_GET_TITLE:
>> + {
>> + int ret;
>> + va_list ap;
>> +
>> + va_copy( ap, args );
>> + ret = demux->pf_control( demux, query, args );
>> + if (ret != VLC_SUCCESS)
>> + *va_arg( ap, int * ) = demux->info.i_title;
>> + va_end( ap );
>> + return VLC_SUCCESS;
>> + }
>> + case DEMUX_GET_SEEKPOINT:
>> + {
>> + int ret;
>> + va_list ap;
>> +
>> + va_copy( ap, args );
>> + ret = demux->pf_control( demux, query, args );
>> + if (ret != VLC_SUCCESS)
>> + *va_arg( ap, int * ) = demux->info.i_seekpoint;
>> + va_end( ap );
>> + return VLC_SUCCESS;
>> + }
>> + }
>> +
>> return demux->pf_control( demux, query, args );
>> }
>>
>> @@ -658,20 +710,30 @@ static bool SkipAPETag( demux_t *p_demux )
>>
>> int demux_GetUpdateFlags( demux_t *p_demux )
>> {
>> + int i_update;
>> + if ( demux_Control( p_demux, DEMUX_GET_UPDATE_FLAGS, &i_update ) ==
>> VLC_SUCCESS )
>> + return i_update;
>> return p_demux->info.i_update;
>> }
>>
>> void demux_ResetUpdateFlags( demux_t *p_demux, int i_flags )
>> {
>> - p_demux->info.i_update &= ~i_flags;
>> + if ( demux_Control( p_demux, DEMUX_CLEAR_UPDATE_FLAGS, &i_flags ) !=
>> VLC_SUCCESS )
>> + p_demux->info.i_update &= ~i_flags;
>> }
>>
>> int demux_GetTitle( demux_t *p_demux )
>> {
>> - return p_demux->info.i_title;
>> + int i_title;
>> + if ( demux_Control( p_demux, DEMUX_GET_TITLE, &i_title ) == VLC_SUCCESS
>> ) + return i_title;
>> + return 0;
>> }
>>
>> int demux_GetSeekpoint( demux_t *p_demux )
>> {
>> - return p_demux->info.i_seekpoint;
>> + int i_seekpoint;
>> + if ( demux_Control( p_demux, DEMUX_GET_SEEKPOINT, &i_seekpoint ) ==
>> VLC_SUCCESS )
>> + return i_seekpoint;
>> + return 0;
>> }
>
> --
> Rémi Denis-Courmont
> http://www.remlab.net/
>
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel
More information about the vlc-devel
mailing list