summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdward Hervey <edward@collabora.com>2013-07-12 14:31:17 +0200
committerEdward Hervey <edward@collabora.com>2013-08-26 08:23:37 +0200
commitc0abfda5ec9bebe60ede9442ce3d6d21998997dc (patch)
treedd57210fde60bf9239684917ee1f9187272d4fa7
parent7884f8b6e3b181305cb38c680cc8f025b845c18c (diff)
!!WIP mpegtsdemux: fast-startwip3
-rw-r--r--gst/mpegtsdemux/mpegtsbase.c47
-rw-r--r--gst/mpegtsdemux/mpegtspacketizer.c2
-rw-r--r--gst/mpegtsdemux/mpegtsparse.c2
3 files changed, 37 insertions, 14 deletions
diff --git a/gst/mpegtsdemux/mpegtsbase.c b/gst/mpegtsdemux/mpegtsbase.c
index aff1e2fce..b8bd31da3 100644
--- a/gst/mpegtsdemux/mpegtsbase.c
+++ b/gst/mpegtsdemux/mpegtsbase.c
@@ -176,6 +176,7 @@ mpegts_base_reset (MpegTSBase * base)
/* Known PIDs : PAT, TSDT, IPMP CIT */
MPEGTS_BIT_SET (base->known_psi, 0);
+#if 0
MPEGTS_BIT_SET (base->known_psi, 2);
MPEGTS_BIT_SET (base->known_psi, 3);
/* TDT, TOT, ST */
@@ -185,6 +186,7 @@ mpegts_base_reset (MpegTSBase * base)
/* ATSC */
MPEGTS_BIT_SET (base->known_psi, 0x1ffb);
+#endif
/* FIXME : Commenting the Following lines is to be in sync with the following
* commit
@@ -859,7 +861,7 @@ mpegts_base_apply_pmt (MpegTSBase * base, GstMpegTsSection * section)
GST_ERROR ("Could not get PMT (corrupted ?)");
return FALSE;
}
-
+#if 0
/* FIXME : not so sure this is valid anymore */
if (G_UNLIKELY (base->seen_pat == FALSE)) {
GST_WARNING ("Got pmt without pat first. Returning");
@@ -867,6 +869,7 @@ mpegts_base_apply_pmt (MpegTSBase * base, GstMpegTsSection * section)
mpegts_packetizer_remove_stream (base->packetizer, section->pid);
return TRUE;
}
+#endif
program_number = section->subtable_extension;
GST_DEBUG ("Applying PMT (program_number:%d, pid:0x%04x)",
@@ -878,12 +881,15 @@ mpegts_base_apply_pmt (MpegTSBase * base, GstMpegTsSection * section)
*/
old_program = mpegts_base_get_program (base, program_number);
- if (G_UNLIKELY (old_program == NULL))
- goto no_program;
+ if (G_UNLIKELY (old_program == NULL)) {
+ old_program = mpegts_base_add_program (base, section->subtable_extension,
+ section->pid);
+ } else {
- if (G_UNLIKELY (mpegts_base_is_same_program (base, old_program, section->pid,
- pmt)))
- goto same_program;
+ if (G_UNLIKELY (mpegts_base_is_same_program (base, old_program,
+ section->pid, pmt)))
+ goto same_program;
+ }
/* If the current program is active, this means we have a new program */
if (old_program->active) {
@@ -906,11 +912,11 @@ mpegts_base_apply_pmt (MpegTSBase * base, GstMpegTsSection * section)
return TRUE;
-no_program:
- {
- GST_ERROR ("Attempted to apply a PMT on a program that wasn't created");
- return TRUE;
- }
+/* no_program: */
+/* { */
+/* GST_ERROR ("Attempted to apply a PMT on a program that wasn't created"); */
+/* return TRUE; */
+/* } */
same_program:
{
@@ -1103,6 +1109,7 @@ query_upstream_latency (MpegTSBase * base)
base->queried_latency = TRUE;
}
+
static GstFlowReturn
mpegts_base_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
{
@@ -1151,6 +1158,7 @@ mpegts_base_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
/* If it's a known PES, push it */
if (MPEGTS_BIT_IS_SET (base->is_pes, packet.pid)) {
+ handle_pes:
/* push the packet downstream */
if (base->push_data)
res = klass->push (base, &packet, NULL);
@@ -1160,6 +1168,7 @@ mpegts_base_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
GList *others, *tmp;
GstMpegTsSection *section;
+ handle_psi:
section = mpegts_packetizer_push_section (packetizer, &packet, &others);
if (section)
mpegts_base_handle_psi (base, section);
@@ -1173,8 +1182,20 @@ mpegts_base_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
if (base->push_section)
res = klass->push (base, &packet, section);
- } else if (packet.payload && packet.pid != 0x1fff)
- GST_LOG ("PID 0x%04x Saw packet on a pid we don't handle", packet.pid);
+ } else if (packet.payload && packet.pid != 0x1fff
+ && packet.payload_unit_start_indicator) {
+ GST_LOG ("PID 0x%04x Saw packet on a pid we don't handle, analyzing",
+ packet.pid);
+ if ((GST_READ_UINT32_BE (packet.payload) & 0xffffff00) == 0x00000100) {
+ GST_DEBUG ("PID 0x%04x most likely a PES stream", packet.pid);
+ MPEGTS_BIT_SET (base->is_pes, packet.pid);
+ goto handle_pes;
+ } else if (packet.payload[0] < (packet.data_end - packet.payload)) {
+ GST_DEBUG ("PID 0x%04x most likely a PSI stream", packet.pid);
+ MPEGTS_BIT_SET (base->known_psi, packet.pid);
+ goto handle_psi;
+ }
+ }
next:
mpegts_packetizer_clear_packet (base->packetizer, &packet);
diff --git a/gst/mpegtsdemux/mpegtspacketizer.c b/gst/mpegtsdemux/mpegtspacketizer.c
index b65a3bfa2..fb87783ec 100644
--- a/gst/mpegtsdemux/mpegtspacketizer.c
+++ b/gst/mpegtsdemux/mpegtspacketizer.c
@@ -972,9 +972,9 @@ mpegts_packetizer_push_section (MpegTSPacketizer2 * packetizer,
}
/* If PUSI, skip pointer data and carry on to section start */
data += pointer;
- pointer = 0;
GST_LOG ("discont, but PUSI, skipped %d bytes and doing section start",
pointer);
+ pointer = 0;
goto section_start;
}
diff --git a/gst/mpegtsdemux/mpegtsparse.c b/gst/mpegtsdemux/mpegtsparse.c
index c80c51042..75af3851e 100644
--- a/gst/mpegtsdemux/mpegtsparse.c
+++ b/gst/mpegtsdemux/mpegtsparse.c
@@ -166,6 +166,7 @@ mpegts_parse_reset (MpegTSBase * base)
{
/* Set the various know PIDs we are interested in */
+#if 0
/* CAT */
MPEGTS_BIT_SET (base->known_psi, 1);
/* NIT, ST */
@@ -186,6 +187,7 @@ mpegts_parse_reset (MpegTSBase * base)
MPEGTS_BIT_SET (base->known_psi, 0x1e);
/* SIT */
MPEGTS_BIT_SET (base->known_psi, 0x1f);
+#endif
GST_MPEGTS_PARSE (base)->first = TRUE;
GST_MPEGTS_PARSE (base)->have_group_id = FALSE;