summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdward Hervey <edward@centricular.com>2016-10-11 08:50:17 (GMT)
committerEdward Hervey <bilboed@bilboed.com>2016-10-11 10:37:57 (GMT)
commitdc703b50b3c90421b99b2dd44e51e9e43647827e (patch)
tree18ccb3705f079e26eb7942beb6f77d9cd8c5ee0a
parente8b24f9189518408e266cd78f7bb9385a6d78b6f (diff)
downloadgst-plugins-bad-dc703b50b3c90421b99b2dd44e51e9e43647827e.tar.gz
gst-plugins-bad-dc703b50b3c90421b99b2dd44e51e9e43647827e.tar.xz
mpegtsbase: Remove duplicated code
Just have one function to check for private section streams
-rw-r--r--gst/mpegtsdemux/mpegtsbase.c117
1 files changed, 49 insertions, 68 deletions
diff --git a/gst/mpegtsdemux/mpegtsbase.c b/gst/mpegtsdemux/mpegtsbase.c
index 4aa01e3..c8dd30d 100644
--- a/gst/mpegtsdemux/mpegtsbase.c
+++ b/gst/mpegtsdemux/mpegtsbase.c
@@ -518,6 +518,36 @@ mpegts_base_program_remove_stream (MpegTSBase * base,
program->streams[pid] = NULL;
}
+
+static gboolean
+_stream_is_private_section (GstMpegtsPMTStream * stream)
+{
+ switch (stream->stream_type) {
+ case GST_MPEGTS_STREAM_TYPE_SCTE_DSMCC_DCB:
+ case GST_MPEGTS_STREAM_TYPE_SCTE_SIGNALING:
+ {
+ guint32 registration_id =
+ get_registration_from_descriptors (stream->descriptors);
+ /* Not a private section stream */
+ if (registration_id != DRF_ID_CUEI && registration_id != DRF_ID_ETV1)
+ return FALSE;
+ }
+ case GST_MPEGTS_STREAM_TYPE_PRIVATE_SECTIONS:
+ case GST_MPEGTS_STREAM_TYPE_MHEG:
+ case GST_MPEGTS_STREAM_TYPE_DSM_CC:
+ case GST_MPEGTS_STREAM_TYPE_DSMCC_A:
+ case GST_MPEGTS_STREAM_TYPE_DSMCC_B:
+ case GST_MPEGTS_STREAM_TYPE_DSMCC_C:
+ case GST_MPEGTS_STREAM_TYPE_DSMCC_D:
+ case GST_MPEGTS_STREAM_TYPE_SL_FLEXMUX_SECTIONS:
+ case GST_MPEGTS_STREAM_TYPE_METADATA_SECTIONS:
+ /* known PSI streams */
+ return TRUE;
+ default:
+ return FALSE;
+ }
+}
+
/* Return TRUE if programs are equal */
static gboolean
mpegts_base_is_same_program (MpegTSBase * base, MpegTSBaseProgram * oldprogram,
@@ -595,35 +625,11 @@ mpegts_base_deactivate_program (MpegTSBase * base, MpegTSBaseProgram * program)
/* Only unset the is_pes/known_psi bit if the PID isn't used in any other active
* program */
if (!mpegts_pid_in_active_programs (base, stream->pid)) {
- switch (stream->stream_type) {
- case GST_MPEGTS_STREAM_TYPE_SCTE_DSMCC_DCB:
- case GST_MPEGTS_STREAM_TYPE_SCTE_SIGNALING:
- {
- guint32 registration_id =
- get_registration_from_descriptors (stream->descriptors);
-
- /* Not a private section stream */
- if (registration_id != DRF_ID_CUEI
- && registration_id != DRF_ID_ETV1)
- break;
- /* Fall through on purpose - remove this PID from known_psi */
- }
- case GST_MPEGTS_STREAM_TYPE_PRIVATE_SECTIONS:
- case GST_MPEGTS_STREAM_TYPE_MHEG:
- case GST_MPEGTS_STREAM_TYPE_DSM_CC:
- case GST_MPEGTS_STREAM_TYPE_DSMCC_A:
- case GST_MPEGTS_STREAM_TYPE_DSMCC_B:
- case GST_MPEGTS_STREAM_TYPE_DSMCC_C:
- case GST_MPEGTS_STREAM_TYPE_DSMCC_D:
- case GST_MPEGTS_STREAM_TYPE_SL_FLEXMUX_SECTIONS:
- case GST_MPEGTS_STREAM_TYPE_METADATA_SECTIONS:
- /* Set known PSI streams */
- if (base->parse_private_sections)
- MPEGTS_BIT_UNSET (base->known_psi, stream->pid);
- break;
- default:
- MPEGTS_BIT_UNSET (base->is_pes, stream->pid);
- break;
+ if (_stream_is_private_section (stream)) {
+ if (base->parse_private_sections)
+ MPEGTS_BIT_UNSET (base->known_psi, stream->pid);
+ } else {
+ MPEGTS_BIT_UNSET (base->is_pes, stream->pid);
}
}
}
@@ -672,49 +678,24 @@ mpegts_base_activate_program (MpegTSBase * base, MpegTSBaseProgram * program,
for (i = 0; i < pmt->streams->len; ++i) {
GstMpegtsPMTStream *stream = g_ptr_array_index (pmt->streams, i);
-
- switch (stream->stream_type) {
- case GST_MPEGTS_STREAM_TYPE_SCTE_DSMCC_DCB:
- case GST_MPEGTS_STREAM_TYPE_SCTE_SIGNALING:
- {
- guint32 registration_id =
- get_registration_from_descriptors (stream->descriptors);
- /* Not a private section stream */
- if (registration_id != DRF_ID_CUEI && registration_id != DRF_ID_ETV1)
- break;
- /* Fall through on purpose - remove this PID from known_psi */
+ if (_stream_is_private_section (stream)) {
+ if (base->parse_private_sections)
+ MPEGTS_BIT_SET (base->known_psi, stream->pid);
+ } else {
+ 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);
}
- case GST_MPEGTS_STREAM_TYPE_PRIVATE_SECTIONS:
- case GST_MPEGTS_STREAM_TYPE_MHEG:
- case GST_MPEGTS_STREAM_TYPE_DSM_CC:
- case GST_MPEGTS_STREAM_TYPE_DSMCC_A:
- case GST_MPEGTS_STREAM_TYPE_DSMCC_B:
- case GST_MPEGTS_STREAM_TYPE_DSMCC_C:
- case GST_MPEGTS_STREAM_TYPE_DSMCC_D:
- case GST_MPEGTS_STREAM_TYPE_SL_FLEXMUX_SECTIONS:
- case GST_MPEGTS_STREAM_TYPE_METADATA_SECTIONS:
- /* Set known PSI streams */
- if (base->parse_private_sections)
- 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, stream->pid);
}
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 */