summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdward Hervey <bilboed@bilboed.com>2014-07-10 11:24:12 +0200
committerEdward Hervey <edward@collabora.com>2014-07-11 08:32:06 +0200
commit9e73b487c4427495577fc3def77da39f84fa05b9 (patch)
tree59a5e36985872a201a6329b55373f3e8985f3381
parent5e4e572335bed642dfab36c4f325fde342a370e5 (diff)
downloadgstreamer-plugins-bad-9e73b487c4427495577fc3def77da39f84fa05b9.tar.gz
mpegts: Add parsing for CA descriptor (0x05)
https://bugzilla.gnome.org/show_bug.cgi?id=732986
-rw-r--r--gst-libs/gst/mpegts/gstmpegtsdescriptor.c41
-rw-r--r--gst-libs/gst/mpegts/gstmpegtsdescriptor.h7
2 files changed, 48 insertions, 0 deletions
diff --git a/gst-libs/gst/mpegts/gstmpegtsdescriptor.c b/gst-libs/gst/mpegts/gstmpegtsdescriptor.c
index 246aee45f..06c9f3381 100644
--- a/gst-libs/gst/mpegts/gstmpegtsdescriptor.c
+++ b/gst-libs/gst/mpegts/gstmpegtsdescriptor.c
@@ -872,6 +872,47 @@ gst_mpegts_descriptor_from_registration (const gchar * format_identifier,
return descriptor;
}
+/* GST_MTS_DESC_CA (0x09) */
+
+/**
+ * gst_mpegts_descriptor_parse_ca:
+ * @descriptor: a %GST_MTS_DESC_CA #GstMpegtsDescriptor
+ * @ca_system_id: (out): the type of CA system used
+ * @ca_pid: (out): The PID containing ECM or EMM data
+ * @private_data: (out) (allow-none): The private data
+ * @private_data_size: (out) (allow-none): The size of @private_data in bytes
+ *
+ * Extracts the Conditional Access information from @descriptor.
+ *
+ * Returns: %TRUE if parsing succeeded, else %FALSE.
+ */
+
+gboolean
+gst_mpegts_descriptor_parse_ca (GstMpegtsDescriptor * descriptor,
+ guint16 * ca_system_id, guint16 * ca_pid,
+ const guint8 ** private_data, gsize * private_data_size)
+{
+ guint8 *data;
+
+ g_return_val_if_fail (descriptor != NULL && ca_system_id != NULL
+ && ca_pid != NULL, FALSE);
+ /* The smallest CA is 4 bytes (though not having any private data
+ * sounds a bit ... weird) */
+ __common_desc_checks (descriptor, GST_MTS_DESC_CA, 4, FALSE);
+
+ data = (guint8 *) descriptor->data + 2;
+ *ca_system_id = GST_READ_UINT16_BE (data);
+ data += 2;
+ *ca_pid = GST_READ_UINT16_BE (data) & 0x1fff;
+ data += 2;
+ if (private_data && private_data_size) {
+ *private_data = data;
+ *private_data_size = descriptor->length - 4;
+ }
+
+ return TRUE;
+}
+
/* GST_MTS_DESC_ISO_639_LANGUAGE (0x0A) */
static GstMpegtsISO639LanguageDescriptor *
_gst_mpegts_iso_639_language_descriptor_copy (GstMpegtsISO639LanguageDescriptor
diff --git a/gst-libs/gst/mpegts/gstmpegtsdescriptor.h b/gst-libs/gst/mpegts/gstmpegtsdescriptor.h
index 73c7e0340..bbef97dd0 100644
--- a/gst-libs/gst/mpegts/gstmpegtsdescriptor.h
+++ b/gst-libs/gst/mpegts/gstmpegtsdescriptor.h
@@ -274,6 +274,13 @@ GstMpegtsDescriptor *gst_mpegts_descriptor_from_registration (
const gchar *format_identifier,
guint8 *additional_info, gsize additional_info_length);
+/* GST_MTS_DESC_CA (0x09) */
+gboolean gst_mpegts_descriptor_parse_ca (GstMpegtsDescriptor *descriptor,
+ guint16 *ca_system_id,
+ guint16 *ca_pid,
+ const guint8 **private_data,
+ gsize *private_data_size);
+
/* GST_MTS_DESC_ISO_639_LANGUAGE (0x0A) */
/**
* GstMpegtsISO639AudioType: