[vlc-devel] [PATCH 02/16] Add call to demux control when setting ES list
Roland Bewick
roland.bewick at gmail.com
Tue May 21 20:08:26 CEST 2019
---
include/vlc_demux.h | 3 +-
modules/access/bluray.c | 18 ++++
modules/demux/asf/asf.c | 98 ++++++++++++++--------
modules/demux/mock.c | 2 +
modules/demux/mpeg/ts.c | 12 +++
modules/stream_out/chromecast/chromecast_demux.cpp | 2 +-
src/input/demux.c | 1 +
src/input/input.c | 4 +-
8 files changed, 103 insertions(+), 37 deletions(-)
diff --git a/include/vlc_demux.h b/include/vlc_demux.h
index 9930c0957d..7b24f0906a 100644
--- a/include/vlc_demux.h
+++ b/include/vlc_demux.h
@@ -197,7 +197,8 @@ enum demux_query_e
DEMUX_SET_GROUP_DEFAULT,
DEMUX_SET_GROUP_ALL,
DEMUX_SET_GROUP_LIST, /* arg1= size_t, arg2= const int *, can fail */
- DEMUX_SET_ES, /* arg1= int can fail */
+ DEMUX_SET_ES, /* arg1= int can fail */
+ DEMUX_SET_ES_LIST, /* arg1= int can fail */
/* Ask the demux to demux until the given date at the next pf_demux call
* but not more (and not less, at the precision available of course).
diff --git a/modules/access/bluray.c b/modules/access/bluray.c
index cd88dcc4cf..8774c94c2a 100644
--- a/modules/access/bluray.c
+++ b/modules/access/bluray.c
@@ -2415,6 +2415,24 @@ static int blurayControl(demux_t *p_demux, int query, va_list args)
blurayOnUserStreamSelection(p_demux, i_id);
break;
}
+ case DEMUX_SET_ES_LIST:
+ {
+ vlc_es_id_t **es_id_list = va_arg( args, vlc_es_id_t ** );
+ size_t count;
+ for( count = 0; ; count++ )
+ {
+ vlc_es_id_t *es_id = es_id_list[count];
+ if( es_id == NULL )
+ break;
+ }
+ if (count == 1)
+ {
+ /* For now, only support single track selection */
+ int i_id = vlc_es_id_GetInputId(es_id_list[0]);
+ blurayOnUserStreamSelection(p_demux, i_id);
+ }
+ break;
+ }
case DEMUX_SET_TITLE:
{
int i_title = va_arg(args, int);
diff --git a/modules/demux/asf/asf.c b/modules/demux/asf/asf.c
index 8a72c706f9..3ffe6285cc 100644
--- a/modules/demux/asf/asf.c
+++ b/modules/demux/asf/asf.c
@@ -406,6 +406,51 @@ static void SeekPrepare( demux_t *p_demux )
es_out_Control( p_demux->out, ES_OUT_RESET_PCR );
}
+static int SetStreamById( demux_t *p_demux, int id )
+{
+ demux_sys_t *p_sys = p_demux->p_sys;
+
+ int i_ret;
+ if ( id >= 0 )
+ {
+ msg_Dbg( p_demux, "Requesting access to enable stream %d", id );
+ i_ret = vlc_stream_Control( p_demux->s,
+ STREAM_SET_PRIVATE_ID_STATE, id, true );
+ }
+ else
+ { /* i contains -1 * es_category */
+ msg_Dbg( p_demux, "Requesting access to disable stream %d", id );
+ i_ret = vlc_stream_Control( p_demux->s,
+ STREAM_SET_PRIVATE_ID_STATE, id,
+ false );
+ }
+
+ if ( i_ret == VLC_SUCCESS )
+ {
+ asf_track_t *tk;
+ if( id >= 0 )
+ {
+ tk = p_sys->track[id];
+ }
+ else
+ {
+ for( int j = 0; j < MAX_ASF_TRACKS ; j++ )
+ {
+ tk = p_sys->track[j];
+ if( !tk || !tk->p_fmt || tk->i_cat != -1 * id )
+ continue;
+ FlushQueue( tk );
+ tk->i_time = VLC_TICK_INVALID;
+ }
+ }
+
+ p_sys->i_seek_track = 0;
+ if ( ( tk && tk->i_cat == VIDEO_ES ) || id == -1 * VIDEO_ES )
+ WaitKeyframe( p_demux );
+ }
+ return i_ret;
+}
+
/*****************************************************************************
* Control:
*****************************************************************************/
@@ -450,45 +495,30 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
case DEMUX_SET_ES:
{
i = va_arg( args, int );
- int i_ret;
- if ( i >= 0 )
+
+ return SetStreamById( p_demux, i );
+ }
+
+ case DEMUX_SET_ES_LIST:
+ {
+ vlc_es_id_t **es_id_list = va_arg( args, vlc_es_id_t ** );
+ size_t count;
+ for( count = 0; ; count++ )
+ {
+ vlc_es_id_t *es_id = es_id_list[count];
+ if( es_id == NULL )
+ break;
+ }
+ if (count == 1)
{
- msg_Dbg( p_demux, "Requesting access to enable stream %d", i );
- i_ret = vlc_stream_Control( p_demux->s,
- STREAM_SET_PRIVATE_ID_STATE, i, true );
+ /* For now, only support single track selection */
+ i = vlc_es_id_GetInputId(es_id_list[0]);
+ return SetStreamById( p_demux, i );
}
else
- { /* i contains -1 * es_category */
- msg_Dbg( p_demux, "Requesting access to disable stream %d", i );
- i_ret = vlc_stream_Control( p_demux->s,
- STREAM_SET_PRIVATE_ID_STATE, i,
- false );
- }
-
- if ( i_ret == VLC_SUCCESS )
{
- asf_track_t *tk;
- if( i >= 0 )
- {
- tk = p_sys->track[i];
- }
- else
- {
- for( int j = 0; j < MAX_ASF_TRACKS ; j++ )
- {
- tk = p_sys->track[j];
- if( !tk || !tk->p_fmt || tk->i_cat != -1 * i )
- continue;
- FlushQueue( tk );
- tk->i_time = VLC_TICK_INVALID;
- }
- }
-
- p_sys->i_seek_track = 0;
- if ( ( tk && tk->i_cat == VIDEO_ES ) || i == -1 * VIDEO_ES )
- WaitKeyframe( p_demux );
+ return VLC_SUCCESS;
}
- return i_ret;
}
case DEMUX_GET_POSITION:
diff --git a/modules/demux/mock.c b/modules/demux/mock.c
index 03d282606b..b01fb2c342 100644
--- a/modules/demux/mock.c
+++ b/modules/demux/mock.c
@@ -287,6 +287,8 @@ Control(demux_t *demux, int query, va_list args)
return VLC_EGENERIC;
case DEMUX_SET_ES:
return VLC_EGENERIC;
+ case DEMUX_SET_ES_LIST:
+ return VLC_EGENERIC;
case DEMUX_SET_NEXT_DEMUX_TIME:
return VLC_EGENERIC;
case DEMUX_GET_FPS:
diff --git a/modules/demux/mpeg/ts.c b/modules/demux/mpeg/ts.c
index 3ff513a2e9..10d28cdbd5 100644
--- a/modules/demux/mpeg/ts.c
+++ b/modules/demux/mpeg/ts.c
@@ -1116,6 +1116,18 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
return VLC_SUCCESS;
}
+ case DEMUX_SET_ES_LIST:
+ {
+ vlc_es_id_t **es_id_list = va_arg( args, vlc_es_id_t ** );
+ VLC_UNUSED(es_id_list);
+
+ msg_Dbg( p_demux, "DEMUX_SET_ES_LIST" );
+
+ if( p_sys->seltype != PROGRAM_ALL ) /* Won't change anything */
+ UpdatePESFilters( p_demux, false );
+
+ return VLC_SUCCESS;
+ }
case DEMUX_GET_TITLE_INFO:
{
diff --git a/modules/stream_out/chromecast/chromecast_demux.cpp b/modules/stream_out/chromecast/chromecast_demux.cpp
index 7a97b9cadc..32cb98010b 100644
--- a/modules/stream_out/chromecast/chromecast_demux.cpp
+++ b/modules/stream_out/chromecast/chromecast_demux.cpp
@@ -377,7 +377,7 @@ struct demux_cc
setPauseState( paused != 0 );
break;
}
- case DEMUX_SET_ES:
+ case DEMUX_SET_ES: case DEMUX_SET_ES_LIST:
/* Seek back to the last known pos when changing tracks. This will
* flush sout streams, make sout del/add called right away and
* clear CC buffers. */
diff --git a/src/input/demux.c b/src/input/demux.c
index d7b5ce3711..b69053d7ff 100644
--- a/src/input/demux.c
+++ b/src/input/demux.c
@@ -379,6 +379,7 @@ int demux_vaControlHelper( stream_t *s,
case DEMUX_SET_GROUP_ALL:
case DEMUX_SET_GROUP_LIST:
case DEMUX_SET_ES:
+ case DEMUX_SET_ES_LIST:
case DEMUX_GET_ATTACHMENTS:
case DEMUX_CAN_RECORD:
case DEMUX_TEST_AND_CLEAR_FLAGS:
diff --git a/src/input/input.c b/src/input/input.c
index eea40b59c1..31761c9671 100644
--- a/src/input/input.c
+++ b/src/input/input.c
@@ -2148,7 +2148,9 @@ static bool Control( input_thread_t *p_input,
ES_OUT_SET_ES_LIST, param.list.cat,
param.list.ids ) == VLC_SUCCESS )
{
- /* TODO: demux_Control(..., DEMUX_SET_ES_LIST, ... ) */
+ demux_Control( input_priv(p_input)->master->p_demux,
+ DEMUX_SET_ES_LIST,
+ param.list.ids );
}
break;
}
--
2.11.0
More information about the vlc-devel
mailing list