mpegtsparse: fix sdt parsing.
authorZaheer Abbas Merali <zaheerabbas@merali.org>
Thu, 2 Jul 2009 14:58:00 +0000 (15:58 +0100)
committerZaheer Abbas Merali <zaheerabbas@merali.org>
Thu, 2 Jul 2009 14:58:00 +0000 (15:58 +0100)
fix parsing of everything for each service from eit schedule flag on and also
add a running-status parameter to the bus message structure.

gst/mpegdemux/mpegtspacketizer.c

index b986fa60a4c93d8f5ce1b199c5e727d2f897f9bf..c9fc325f758410dec40ca3b86e6e34391ecad733 100644 (file)
@@ -1264,17 +1264,16 @@ mpegts_packetizer_parse_sdt (MpegTSPacketizer * packetizer,
     service_id = GST_READ_UINT16_BE (data);
     data += 2;
 
-    /* reserved */
-    data += 1;
+    EIT_schedule = ((*data & 0x02) == 2);
+    EIT_present_following = (*data & 0x01) == 1;
 
+    data += 1;
     tmp = GST_READ_UINT16_BE (data);
-    data += 2;
 
-    EIT_schedule = (tmp >> 15);
-    EIT_present_following = (tmp >> 14) & 0x01;
-    running_status = (tmp >> 5) & 0x03;
-    scrambled = (tmp >> 4) & 0x01;
+    running_status = (*data >> 5) & 0x07;
+    scrambled = (*data >> 4) & 0x01;
     descriptors_loop_length = tmp & 0x0FFF;
+    data += 2;
 
     /* TODO send tag event down relevant pad for channel name and provider */
     service_name = g_strdup_printf ("service-%d", service_id);
@@ -1307,7 +1306,26 @@ mpegts_packetizer_parse_sdt (MpegTSPacketizer * packetizer,
             (gchar *) DESC_DVB_SERVICE_name_text (service_descriptor);
         if (servicename_length + serviceprovider_name_length + 2 <=
             DESC_LENGTH (service_descriptor)) {
-
+          gchar *running_status_tmp;
+          switch (running_status) {
+            case 0:
+              running_status_tmp = "undefined";
+              break;
+            case 1:
+              running_status_tmp = "not running";
+              break;
+            case 2:
+              running_status_tmp = "starts in a few seconds";
+              break;
+            case 3:
+              running_status_tmp = "pausing";
+              break;
+            case 4:
+              running_status_tmp = "running";
+              break;
+            default:
+              running_status_tmp = "reserved";
+          }
           servicename_tmp =
               get_encoding_and_convert (servicename, servicename_length);
           serviceprovider_name_tmp =
@@ -1317,7 +1335,8 @@ mpegts_packetizer_parse_sdt (MpegTSPacketizer * packetizer,
           gst_structure_set (service,
               "name", G_TYPE_STRING, servicename_tmp,
               "provider-name", G_TYPE_STRING, serviceprovider_name_tmp,
-              "scrambled", G_TYPE_BOOLEAN, scrambled, NULL);
+              "scrambled", G_TYPE_BOOLEAN, scrambled,
+              "running-status", G_TYPE_STRING, running_status_tmp, NULL);
 
           g_free (servicename_tmp);
           g_free (serviceprovider_name_tmp);