summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Ringel <linuxtv@stefanringel.de>2014-04-10 16:02:09 +0200
committerSebastian Dröge <sebastian@centricular.com>2014-04-16 09:22:46 +0200
commite535967ee99fcdbd8936ab706f400b8023301d32 (patch)
tree078999ab36b1f9557e97549fe6c739b8ec3338d3
parentace60abef5e5a90b216e30f67142a957fa964b5e (diff)
downloadgstreamer-plugins-bad-e535967ee99fcdbd8936ab706f400b8023301d32.tar.gz
mpegts: add frequency list descriptor
https://bugzilla.gnome.org/show_bug.cgi?id=727560
-rw-r--r--docs/libs/gst-plugins-bad-libs-sections.txt2
-rw-r--r--gst-libs/gst/mpegts/gst-dvb-descriptor.c75
-rw-r--r--gst-libs/gst/mpegts/gst-dvb-descriptor.h3
3 files changed, 72 insertions, 8 deletions
diff --git a/docs/libs/gst-plugins-bad-libs-sections.txt b/docs/libs/gst-plugins-bad-libs-sections.txt
index 7a039ef3b..46ba28a86 100644
--- a/docs/libs/gst-plugins-bad-libs-sections.txt
+++ b/docs/libs/gst-plugins-bad-libs-sections.txt
@@ -302,6 +302,8 @@ GstMpegTsDVBLinkageDescriptor
gst_mpegts_descriptor_parse_dvb_linkage
<SUBSECTION private_data_specifier>
gst_mpegts_descriptor_parse_dvb_private_data_specifier
+<SUBSECTION frequency_list>
+gst_mpegts_descriptor_parse_dvb_frequency_list
<SUBSECTION data_broadcast>
GstMpegTsDataBroadcastDescriptor
gst_mpegts_descriptor_parse_dvb_data_broadcast
diff --git a/gst-libs/gst/mpegts/gst-dvb-descriptor.c b/gst-libs/gst/mpegts/gst-dvb-descriptor.c
index b84c564a5..3daec7838 100644
--- a/gst-libs/gst/mpegts/gst-dvb-descriptor.c
+++ b/gst-libs/gst/mpegts/gst-dvb-descriptor.c
@@ -47,6 +47,12 @@
* * GST_MTS_DESC_DVB_FREQUENCY_LIST
*/
+#define BCD_UN(a) ((a) & 0x0f)
+#define BCD_DEC(a) (((a) >> 4) & 0x0f)
+#define BCD(a) (BCD_UN(a) + 10 * BCD_DEC(a))
+#define BCD_16(a) (BCD(a[1]) + 100 * BCD(a[0]))
+#define BCD_28(a) (BCD_DEC(a[3]) + 10 * BCD(a[2]) + 1000 * BCD(a[1]) + 100000 * BCD(a[0]))
+#define BCD_32(a) (BCD(a[3]) + 100 * BCD(a[2]) + 10000 * BCD(a[1]) + 1000000 * BCD(a[0]))
/* GST_MTS_DESC_DVB_NETWORK_NAME (0x40) */
/**
@@ -130,13 +136,6 @@ gst_mpegts_descriptor_parse_satellite_delivery_system (const GstMpegTsDescriptor
data = (guint8 *) descriptor->data + 2;
-#define BCD_UN(a) ((a) & 0x0f)
-#define BCD_DEC(a) (((a) >> 4) & 0x0f)
-#define BCD(a) (BCD_UN(a) + 10 * BCD_DEC(a))
-#define BCD_16(a) (BCD(a[1]) + 100 * BCD(a[0]))
-#define BCD_28(a) (BCD_DEC(a[3]) + 10 * BCD(a[2]) + 1000 * BCD(a[1]) + 100000 * BCD(a[0]))
-#define BCD_32(a) (BCD(a[3]) + 100 * BCD(a[2]) + 10000 * BCD(a[1]) + 1000000 * BCD(a[0]))
-
/* BCD coded frequency in GHz (decimal point occurs after the 3rd character)
* So direct BCD gives us units of (GHz / 100 000) = 10 kHz*/
res->frequency = BCD_32 (data) * 10;
@@ -1283,6 +1282,68 @@ gst_mpegts_descriptor_parse_dvb_private_data_specifier (const
return TRUE;
}
+/* GST_MTS_DESC_DVB_FREQUENCY_LIST (0x62) */
+/**
+ * gst_mpegts_descriptor_parse_dvb_frequency_list:
+ * @descriptor: a %GST_MTS_DESC_DVB_FREQUENCY_LIST #GstMpegTsDescriptor
+ * @offset: (out): %FALSE in Hz, %TRUE in kHz
+ * @list: (out): a list of all frequencies in Hz/kHz depending from %offset
+ *
+ * Parses out a list of frequencies from the @descriptor.
+ *
+ * Returns: %TRUE if the parsing happened correctly, else %FALSE.
+ */
+gboolean
+gst_mpegts_descriptor_parse_dvb_frequency_list (const GstMpegTsDescriptor
+ * descriptor, gboolean * offset, GArray ** list)
+{
+ guint8 *data, type, len;
+ guint32 freq;
+
+ g_return_val_if_fail (descriptor != NULL && offset != NULL &&
+ list != NULL, FALSE);
+ /* 1 byte coding system, 4 bytes each frequency entry */
+ __common_desc_checks (descriptor, GST_MTS_DESC_DVB_FREQUENCY_LIST, 5, FALSE);
+
+ data = (guint8 *) descriptor->data + 2;
+
+ type = *data & 0x03;
+ data += 1;
+
+ if (type == 1) {
+ /* satellite */
+ *offset = TRUE;
+ } else {
+ /* cable, terrestrial */
+ *offset = FALSE;
+ }
+
+ *list = g_array_new (FALSE, FALSE, sizeof (guint32));
+
+ len = descriptor->length - 1;
+
+ for (guint8 i = 0; i < len - 3; i += 4) {
+ switch (type) {
+ case 1:
+ freq = BCD_32 (data) * 10;
+ break;
+ case 2:
+ freq = BCD_32 (data) * 100;
+ break;
+ case 3:
+ freq = GST_READ_UINT32_BE (data) * 10;
+ break;
+ default:
+ break;
+ }
+
+ g_array_append_val (*list, freq);
+ data += 4;
+ }
+
+ return TRUE;
+}
+
/* GST_MTS_DESC_DVB_DATA_BROADCAST (0x64) */
/**
* gst_mpegts_descriptor_parse_dvb_data_broadcast:
diff --git a/gst-libs/gst/mpegts/gst-dvb-descriptor.h b/gst-libs/gst/mpegts/gst-dvb-descriptor.h
index a556ddfa4..f65663518 100644
--- a/gst-libs/gst/mpegts/gst-dvb-descriptor.h
+++ b/gst-libs/gst/mpegts/gst-dvb-descriptor.h
@@ -632,7 +632,8 @@ gboolean gst_mpegts_descriptor_parse_dvb_private_data_specifier (const GstMpegTs
guint8 * length);
/* GST_MTS_DESC_DVB_FREQUENCY_LIST (0x62) */
-/* FIXME : Implement */
+gboolean gst_mpegts_descriptor_parse_dvb_frequency_list (const GstMpegTsDescriptor
+ * descriptor, gboolean * offset, GArray ** list);
/* GST_MTS_DESC_DVB_DATA_BROADCAST (0x64) */
typedef struct _GstMpegTsDataBroadcastDescriptor GstMpegTsDataBroadcastDescriptor;