tsbase: parse the mgt and add listed EIT/ETT pids to the known psi
authorThiago Santos <ts.santos@sisa.samsung.com>
Fri, 16 May 2014 18:39:48 +0000 (15:39 -0300)
committerEdward Hervey <bilboed@bilboed.com>
Thu, 29 May 2014 08:37:59 +0000 (10:37 +0200)
This will make tsbase also parse the EITs and ETTs from ATSC streams that have
their pids reported on the MGT and post to the bus

https://bugzilla.gnome.org/show_bug.cgi?id=730435

gst/mpegtsdemux/mpegtsbase.c

index 0fef7c720d40fff91a61ccf75ddd97091d7b0d47..101f999e685062f013396cc73be29dd4102d8097 100644 (file)
@@ -88,6 +88,8 @@ static GstStateChangeReturn mpegts_base_change_state (GstElement * element,
     GstStateChange transition);
 static gboolean mpegts_base_get_tags_from_eit (MpegTSBase * base,
     GstMpegTsSection * section);
+static gboolean mpegts_base_parse_atsc_mgt (MpegTSBase * base,
+    GstMpegTsSection * section);
 static gboolean remove_each_program (gpointer key, MpegTSBaseProgram * program,
     MpegTSBase * base);
 
@@ -915,6 +917,9 @@ mpegts_base_handle_psi (MpegTSBase * base, GstMpegTsSection * section)
       /* some tag xtraction + posting */
       post_message = mpegts_base_get_tags_from_eit (base, section);
       break;
+    case GST_MPEGTS_SECTION_ATSC_MGT:
+      post_message = mpegts_base_parse_atsc_mgt (base, section);
+      break;
     default:
       break;
   }
@@ -926,6 +931,29 @@ mpegts_base_handle_psi (MpegTSBase * base, GstMpegTsSection * section)
   gst_mpegts_section_unref (section);
 }
 
+static gboolean
+mpegts_base_parse_atsc_mgt (MpegTSBase * base, GstMpegTsSection * section)
+{
+  const GstMpegTsAtscMGT *mgt;
+  gint i;
+
+  mgt = gst_mpegts_section_get_atsc_mgt (section);
+  if (G_UNLIKELY (mgt == NULL))
+    return FALSE;
+
+  for (i = 0; i < mgt->tables->len; ++i) {
+    GstMpegTsAtscMGTTable *table = g_ptr_array_index (mgt->tables, i);
+
+    if ((table->table_type >= GST_MPEG_TS_ATSC_MGT_TABLE_TYPE_EIT0 &&
+            table->table_type <= GST_MPEG_TS_ATSC_MGT_TABLE_TYPE_EIT127) ||
+        (table->table_type >= GST_MPEG_TS_ATSC_MGT_TABLE_TYPE_ETT0 &&
+            table->table_type <= GST_MPEG_TS_ATSC_MGT_TABLE_TYPE_ETT127)) {
+      MPEGTS_BIT_SET (base->known_psi, table->pid);
+    }
+  }
+
+  return TRUE;
+}
 
 static gboolean
 mpegts_base_get_tags_from_eit (MpegTSBase * base, GstMpegTsSection * section)