summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdward Hervey <bilboed@bilboed.com>2014-10-07 14:31:04 +0200
committerEdward Hervey <bilboed@bilboed.com>2015-03-11 10:39:37 +0100
commit4a1de07b762ede0db06ba7c05332aec40c91a545 (patch)
treedeb5666367a9edd52403505d3287d27ce980bbc2
parente7ec670e88983ecb57f46d2e3c9debe864d10f08 (diff)
mpegtsbase: Mark all PES/PSI streams accross resets/flushes
We now potentially reset/flush ourself in depth, yet it might be for the same program. In order to make sure we properly look for program PES/PSI PID, mark them, even if we already saw that given program before. Ensures we don't end up waiting forever for the program PMT, or for the individual streams
-rw-r--r--gst/mpegtsdemux/mpegtsbase.c86
1 files changed, 46 insertions, 40 deletions
diff --git a/gst/mpegtsdemux/mpegtsbase.c b/gst/mpegtsdemux/mpegtsbase.c
index bca213524..f18df5588 100644
--- a/gst/mpegtsdemux/mpegtsbase.c
+++ b/gst/mpegtsdemux/mpegtsbase.c
@@ -655,36 +655,13 @@ remove_marked_programs (gpointer key, MpegTSBaseProgram * program,
return FALSE;
}
+/* Properly set the PES/PSI flags for the give program */
static void
-mpegts_base_activate_program (MpegTSBase * base, MpegTSBaseProgram * program,
- guint16 pmt_pid, GstMpegtsSection * section, const GstMpegtsPMT * pmt,
- gboolean initial_program)
+mpegts_base_mark_program_streams (MpegTSBase * base, const GstMpegtsPMT * pmt)
{
guint i;
- MpegTSBaseClass *klass;
-
- if (G_UNLIKELY (program->active))
- return;
-
- GST_DEBUG ("Activating program %d", program->program_number);
-
- /* activate new pmt */
- if (program->section)
- gst_mpegts_section_unref (program->section);
- program->section = gst_mpegts_section_ref (section);
-
- program->pmt = pmt;
- program->pmt_pid = pmt_pid;
- program->pcr_pid = pmt->pcr_pid;
-
- /* extract top-level registration_id if present */
- program->registration_id =
- get_registration_from_descriptors (pmt->descriptors);
- GST_DEBUG ("program 0x%04x, registration_id %" SAFE_FOURCC_FORMAT,
- program->program_number, SAFE_FOURCC_ARGS (program->registration_id));
-
- program->initial_program = initial_program;
+ /* Yah ... recheck the PES bit is set where/when needed ... */
for (i = 0; i < pmt->streams->len; ++i) {
GstMpegtsPMTStream *stream = g_ptr_array_index (pmt->streams, i);
@@ -713,23 +690,49 @@ mpegts_base_activate_program (MpegTSBase * base, MpegTSBaseProgram * program,
MPEGTS_BIT_SET (base->known_psi, stream->pid);
break;
default:
- if (G_UNLIKELY (MPEGTS_BIT_IS_SET (base->is_pes, stream->pid)))
- GST_FIXME
- ("Refcounting issue. Setting twice a PID (0x%04x) as known PES",
- stream->pid);
- if (G_UNLIKELY (MPEGTS_BIT_IS_SET (base->known_psi, stream->pid))) {
- GST_FIXME
- ("Refcounting issue. Setting a known PSI PID (0x%04x) as known PES",
- stream->pid);
- MPEGTS_BIT_UNSET (base->known_psi, stream->pid);
- }
-
MPEGTS_BIT_SET (base->is_pes, stream->pid);
break;
}
+ }
+
+ MPEGTS_BIT_SET (base->is_pes, pmt->pcr_pid);
+}
+
+static void
+mpegts_base_activate_program (MpegTSBase * base, MpegTSBaseProgram * program,
+ guint16 pmt_pid, GstMpegtsSection * section, const GstMpegtsPMT * pmt,
+ gboolean initial_program)
+{
+ guint i;
+ MpegTSBaseClass *klass;
+
+ if (G_UNLIKELY (program->active))
+ return;
+
+ GST_DEBUG ("Activating program %d", program->program_number);
+
+ /* activate new pmt */
+ if (program->section)
+ gst_mpegts_section_unref (program->section);
+ program->section = gst_mpegts_section_ref (section);
+
+ program->pmt = pmt;
+ program->pmt_pid = pmt_pid;
+ program->pcr_pid = pmt->pcr_pid;
+
+ /* extract top-level registration_id if present */
+ program->registration_id =
+ get_registration_from_descriptors (pmt->descriptors);
+ GST_DEBUG ("program 0x%04x, registration_id %" SAFE_FOURCC_FORMAT,
+ program->program_number, SAFE_FOURCC_ARGS (program->registration_id));
+
+ program->initial_program = initial_program;
+
+ for (i = 0; i < pmt->streams->len; ++i) {
+ GstMpegtsPMTStream *stream = g_ptr_array_index (pmt->streams, i);
+
mpegts_base_program_add_stream (base, program,
stream->pid, stream->stream_type, stream);
-
}
/* We add the PCR pid last. If that PID is already used by one of the media
* streams above, no new stream will be created */
@@ -737,7 +740,9 @@ mpegts_base_activate_program (MpegTSBase * base, MpegTSBaseProgram * program,
MPEGTS_BIT_SET (base->is_pes, pmt->pcr_pid);
g_hash_table_foreach_remove (base->programs, (GHRFunc) remove_marked_programs,
- base);
+ base);
+
+ mpegts_base_mark_program_streams (base, pmt);
program->active = TRUE;
klass = GST_MPEGTS_BASE_GET_CLASS (base);
@@ -793,8 +798,8 @@ mpegts_base_apply_pat (MpegTSBase * base, GstMpegtsSection * section)
GST_FIXME
("Refcounting issue. Setting twice a PMT PID (0x%04x) as know PSI",
program->pmt_pid);
- MPEGTS_BIT_SET (base->known_psi, patp->network_or_program_map_PID);
}
+ MPEGTS_BIT_SET (base->known_psi, program->pmt_pid);
} else {
/* Create a new program */
program =
@@ -916,6 +921,7 @@ no_program:
same_program:
{
+ mpegts_base_mark_program_streams (base, pmt);
GST_DEBUG ("Not applying identical program");
return TRUE;
}