[vlc-commits] access: bluray: keep es pair in fake es out
Francois Cartegnie
git at videolan.org
Wed Oct 17 20:39:20 CEST 2018
vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Tue Oct 16 14:26:05 2018 +0200| [5c22ba84ba79819768a2256ef876200e9014b045] | committer: Francois Cartegnie
access: bluray: keep es pair in fake es out
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=5c22ba84ba79819768a2256ef876200e9014b045
---
modules/access/bluray.c | 67 ++++++++++++++++++++++++++++---------------------
1 file changed, 39 insertions(+), 28 deletions(-)
diff --git a/modules/access/bluray.c b/modules/access/bluray.c
index 79c24bb27f..f1a7f07a02 100644
--- a/modules/access/bluray.c
+++ b/modules/access/bluray.c
@@ -191,7 +191,6 @@ typedef struct
/* TS stream */
es_out_t *p_out;
- vlc_array_t es; /* es_pair_t */
int i_audio_stream_idx; /* Selected audio stream. -1 if default */
int i_spu_stream_idx; /* Selected subtitle stream. -1 if default */
bool b_spu_enable; /* enabled / disabled */
@@ -914,7 +913,6 @@ static int blurayOpen(vlc_object_t *object)
}
}
- vlc_array_init(&p_sys->es);
p_sys->p_out = esOutNew(VLC_OBJECT(p_demux), p_demux->out, p_demux);
if (unlikely(p_sys->p_out == NULL))
goto error;
@@ -973,10 +971,7 @@ static void blurayClose(vlc_object_t *object)
if (p_sys->p_parser)
vlc_demux_chained_Delete(p_sys->p_parser);
- if (p_sys->p_out != NULL)
- es_out_Delete(p_sys->p_out);
- assert(vlc_array_count(&p_sys->es) == 0);
- vlc_array_clear(&p_sys->es);
+ es_out_Delete(p_sys->p_out);
/* Titles */
for (unsigned int i = 0; i < p_sys->i_title; i++)
@@ -1080,10 +1075,17 @@ typedef struct
{
es_out_t *p_dst_out;
vlc_object_t *p_obj;
+ vlc_array_t es; /* es_pair_t */
void *priv;
es_out_t es_out;
} bluray_esout_priv_t;
+enum
+{
+ BLURAY_ES_OUT_CONTROL_SET_ES_BY_PID = ES_OUT_PRIVATE_START,
+ BLURAY_ES_OUT_CONTROL_UNSET_ES_BY_PID,
+};
+
static es_out_id_t *bluray_esOutAdd(es_out_t *p_out, const es_format_t *p_fmt)
{
bluray_esout_priv_t *esout_priv = container_of(p_out, bluray_esout_priv_t, es_out);
@@ -1122,11 +1124,11 @@ static es_out_id_t *bluray_esOutAdd(es_out_t *p_out, const es_format_t *p_fmt)
es_out_id_t *p_es = es_out_Add(esout_priv->p_dst_out, &fmt);
if (p_fmt->i_id >= 0) {
/* Ensure we are not overriding anything */
- es_pair_t *p_pair = getEsPairByPID(&p_sys->es, p_fmt->i_id);
+ es_pair_t *p_pair = getEsPairByPID(&esout_priv->es, p_fmt->i_id);
if (p_pair == NULL)
{
msg_Info(p_demux, "Adding ES %d", p_fmt->i_id);
- if (es_pair_Add(&p_sys->es, p_fmt->i_id, p_es) && b_select)
+ if (es_pair_Add(&esout_priv->es, p_fmt->i_id, p_es) && b_select)
es_out_Control(p_demux->out, ES_OUT_SET_ES, p_es);
}
}
@@ -1155,9 +1157,9 @@ static void bluray_esOutDel(es_out_t *p_out, es_out_id_t *p_es)
demux_t *p_demux = esout_priv->priv;
demux_sys_t *p_sys = p_demux->p_sys;
- es_pair_t *p_pair = getEsPairByES(&p_sys->es, p_es);
+ es_pair_t *p_pair = getEsPairByES(&esout_priv->es, p_es);
if (p_pair)
- es_pair_Remove(&p_sys->es, p_pair);
+ es_pair_Remove(&esout_priv->es, p_pair);
vlc_mutex_lock(&p_sys->bdj_overlay_lock);
if (p_es == p_sys->p_video_es)
@@ -1170,19 +1172,32 @@ static void bluray_esOutDel(es_out_t *p_out, es_out_id_t *p_es)
static int bluray_esOutControl(es_out_t *p_out, int i_query, va_list args)
{
bluray_esout_priv_t *esout_priv = container_of(p_out, bluray_esout_priv_t, es_out);
+ switch(i_query)
+ {
+ case BLURAY_ES_OUT_CONTROL_SET_ES_BY_PID:
+ case BLURAY_ES_OUT_CONTROL_UNSET_ES_BY_PID:
+ {
+ bool b_select = (i_query == BLURAY_ES_OUT_CONTROL_SET_ES_BY_PID);
+ es_pair_t *p_pair = getEsPairByPID(&esout_priv->es, va_arg(args, int));
+ if(unlikely(!p_pair))
+ return VLC_EGENERIC;
+ return es_out_Control(esout_priv->p_dst_out,
+ b_select ? ES_OUT_SET_ES : ES_OUT_UNSET_ES,
+ p_pair->p_es);
+ };
- return es_out_vaControl(esout_priv->p_dst_out, i_query, args);
+ default:
+ return es_out_vaControl(esout_priv->p_dst_out, i_query, args);
+ }
}
static void bluray_esOutDestroy(es_out_t *p_out)
{
bluray_esout_priv_t *esout_priv = container_of(p_out, bluray_esout_priv_t, es_out);
- demux_t *p_demux = esout_priv->priv;
- demux_sys_t *p_sys = p_demux->p_sys;
- for (size_t i = 0; i < vlc_array_count(&p_sys->es); ++i)
- free(vlc_array_item_at_index(&p_sys->es, i));
- vlc_array_clear(&p_sys->es);
+ for (size_t i = 0; i < vlc_array_count(&esout_priv->es); ++i)
+ free(vlc_array_item_at_index(&esout_priv->es, i));
+ vlc_array_clear(&esout_priv->es);
free(esout_priv);
}
@@ -1200,6 +1215,7 @@ static es_out_t *esOutNew(vlc_object_t *p_obj, es_out_t *p_dst_out, void *priv)
if (unlikely(esout_priv == NULL))
return NULL;
+ vlc_array_init(&esout_priv->es);
esout_priv->p_dst_out = p_dst_out;
esout_priv->p_obj = p_obj;
esout_priv->priv = priv;
@@ -2321,19 +2337,14 @@ static void blurayStreamSelect(demux_t *p_demux, uint32_t i_type, uint32_t i_id)
i_pid = blurayGetStreamPID(p_sys, i_type, i_id);
}
- if (i_pid > 0) {
- es_pair_t *p_pair = getEsPairByPID(&p_sys->es, i_pid);
- if (p_pair)
+ if (i_pid > 0)
+ {
+ if (i_type == BD_EVENT_PG_TEXTST_STREAM && !p_sys->b_spu_enable)
+ es_out_Control(p_sys->p_out, BLURAY_ES_OUT_CONTROL_UNSET_ES_BY_PID, i_pid);
+ else
{
- assert(p_pair->p_es);
-
- if (i_type == BD_EVENT_PG_TEXTST_STREAM && !p_sys->b_spu_enable)
- es_out_Control(p_demux->out, ES_OUT_UNSET_ES, p_pair->p_es);
- else
- {
- es_out_Control(p_demux->out, ES_OUT_SET_ES, p_pair->p_es);
- blurayStreamSelected(p_sys, i_pid);
- }
+ es_out_Control(p_sys->p_out, BLURAY_ES_OUT_CONTROL_SET_ES_BY_PID, i_pid);
+ blurayStreamSelected(p_sys, i_pid);
}
}
}
More information about the vlc-commits
mailing list