From dfb101e0edf16733997dd33e4fb43071dc26d7b8 Mon Sep 17 00:00:00 2001 From: Douglas Bagnall Date: Sun, 10 Mar 2013 12:07:40 +1300 Subject: [PATCH] tsdemux: disentangle requested program number from active program number The program_number attribute was overloaded, trying to indicate both the currently playing program, and the program requested via the "program-number" property. The end result was that setting the property didn't work (see #690934). I added a new requested_program_number field rather than reviving the current_program_number field because it seemed this would result in fewer changes overall and be less confusing. It breaks symmetry with the "program-number" property, but it retains parallels with the likes of program->program_number. Because gst_ts_demux_reset is called after the properties have been parsed, requested_program_number is initialised in gst_ts_demux_init. Whether this is exactly the right place, I don't know. --- gst/mpegtsdemux/tsdemux.c | 14 ++++++++------ gst/mpegtsdemux/tsdemux.h | 3 ++- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/gst/mpegtsdemux/tsdemux.c b/gst/mpegtsdemux/tsdemux.c index cc09269..af6570e 100644 --- a/gst/mpegtsdemux/tsdemux.c +++ b/gst/mpegtsdemux/tsdemux.c @@ -341,6 +341,7 @@ gst_ts_demux_init (GstTSDemux * demux) /* We are not interested in sections (all handled by mpegtsbase) */ base->push_section = FALSE; + demux->requested_program_number = -1; demux->program_number = -1; gst_ts_demux_reset (base); } @@ -356,7 +357,7 @@ gst_ts_demux_set_property (GObject * object, guint prop_id, case PROP_PROGRAM_NUMBER: /* FIXME: do something if program is switched as opposed to set at * beginning */ - demux->program_number = g_value_get_int (value); + demux->requested_program_number = g_value_get_int (value); break; case PROP_EMIT_STATS: demux->emit_statistics = g_value_get_boolean (value); @@ -374,7 +375,7 @@ gst_ts_demux_get_property (GObject * object, guint prop_id, switch (prop_id) { case PROP_PROGRAM_NUMBER: - g_value_set_int (value, demux->program_number); + g_value_set_int (value, demux->requested_program_number); break; case PROP_EMIT_STATS: g_value_set_boolean (value, demux->emit_statistics); @@ -1099,11 +1100,12 @@ gst_ts_demux_program_started (MpegTSBase * base, MpegTSBaseProgram * program) { GstTSDemux *demux = GST_TS_DEMUX (base); - GST_DEBUG ("Current program %d, new program %d", - demux->program_number, program->program_number); + GST_DEBUG ("Current program %d, new program %d requested program %d", + (gint) demux->program_number, program->program_number, + demux->requested_program_number); - if (demux->program_number == -1 || - demux->program_number == program->program_number) { + if (demux->requested_program_number == program->program_number || + (demux->requested_program_number == -1 && demux->program_number == -1)) { GST_LOG ("program %d started", program->program_number); demux->program_number = program->program_number; diff --git a/gst/mpegtsdemux/tsdemux.h b/gst/mpegtsdemux/tsdemux.h index 603b593..f11c969 100644 --- a/gst/mpegtsdemux/tsdemux.h +++ b/gst/mpegtsdemux/tsdemux.h @@ -55,7 +55,8 @@ struct _GstTSDemux /* the following vars must be protected with the OBJECT_LOCK as they can be * accessed from the application thread and the streaming thread */ - guint program_number; /* Required program number (ignore:-1) */ + gint requested_program_number; /* Required program number (ignore:-1) */ + guint program_number; gboolean emit_statistics; /*< private >*/ -- 2.7.4