From 570f78df799bfeedfaf029e29da22db2dc49959a Mon Sep 17 00:00:00 2001 From: Stefan Ringel Date: Thu, 17 Apr 2014 14:54:28 +0200 Subject: [PATCH] mpegts: add service list descriptor https://bugzilla.gnome.org/show_bug.cgi?id=728364 --- docs/libs/gst-plugins-bad-libs-sections.txt | 3 ++ gst-libs/gst/mpegts/gst-dvb-descriptor.c | 47 +++++++++++++++++++++ gst-libs/gst/mpegts/gst-dvb-descriptor.h | 17 ++++++++ 3 files changed, 67 insertions(+) diff --git a/docs/libs/gst-plugins-bad-libs-sections.txt b/docs/libs/gst-plugins-bad-libs-sections.txt index d271b36998..c1f7216901 100644 --- a/docs/libs/gst-plugins-bad-libs-sections.txt +++ b/docs/libs/gst-plugins-bad-libs-sections.txt @@ -320,6 +320,9 @@ gst_mpegts_descriptor_parse_dvb_parental_rating gst_mpegts_descriptor_parse_dvb_stream_identifier gst_mpegts_descriptor_parse_dvb_ca_identifier + +GstMpegTsDVBServiceListItem +gst_mpegts_descriptor_parse_dvb_service_list GST_TYPE_MPEG_TSDVB_CODE_RATE gst_mpegts_dvb_code_rate_get_type diff --git a/gst-libs/gst/mpegts/gst-dvb-descriptor.c b/gst-libs/gst/mpegts/gst-dvb-descriptor.c index 279a9a9676..caa593d84e 100644 --- a/gst-libs/gst/mpegts/gst-dvb-descriptor.c +++ b/gst-libs/gst/mpegts/gst-dvb-descriptor.c @@ -112,6 +112,53 @@ gst_mpegts_descriptor_from_dvb_network_name (const gchar * name) return descriptor; } +/* GST_MTS_DESC_DVB_SERVICE_LIST (0x41) */ +static void +_gst_mpegts_dvb_service_list_item_free (GstMpegTsDVBServiceListItem * item) +{ + g_slice_free (GstMpegTsDVBServiceListItem, item); +} + +/** + * gst_mpegts_descriptor_parse_dvb_service_list: + * @descriptor: a %GST_MTS_DESC_DVB_SERVICE_LIST #GstMpegTsDescriptor + * @list: (out) (transfer full) (element-type GstMpegTsDVBServiceListItem): + * the list of services + * + * Parses out a list of services from the @descriptor: + * + * Returns: %TRUE if the parsing happened correctly, else %FALSE. + */ +gboolean +gst_mpegts_descriptor_parse_dvb_service_list (const GstMpegTsDescriptor * + descriptor, GPtrArray ** list) +{ + guint8 *data, i; + + g_return_val_if_fail (descriptor != NULL && list != NULL, FALSE); + /* a entry has 3 bytes, 2 for service id, 1 for service type */ + __common_desc_checks (descriptor, GST_MTS_DESC_DVB_SERVICE_LIST, 3, FALSE); + + data = (guint8 *) descriptor->data + 2; + + *list = g_ptr_array_new_with_free_func ((GDestroyNotify) + _gst_mpegts_dvb_service_list_item_free); + + for (i = 0; i < descriptor->length - 2; i += 3) { + GstMpegTsDVBServiceListItem *item = + g_slice_new0 (GstMpegTsDVBServiceListItem); + + g_ptr_array_add (*list, item); + item->service_id = GST_READ_UINT16_BE (data); + data += 2; + + item->type = *data; + data += 1; + } + + return TRUE; +} + /* GST_MTS_DESC_DVB_SATELLITE_DELIVERY_SYSTEM (0x43) */ /** * gst_mpegts_descriptor_parse_satellite_delivery_system: diff --git a/gst-libs/gst/mpegts/gst-dvb-descriptor.h b/gst-libs/gst/mpegts/gst-dvb-descriptor.h index c1c0268cff..3e4f496bf0 100644 --- a/gst-libs/gst/mpegts/gst-dvb-descriptor.h +++ b/gst-libs/gst/mpegts/gst-dvb-descriptor.h @@ -330,6 +330,23 @@ GstMpegTsDescriptor *gst_mpegts_descriptor_from_dvb_service (GstMpegTsDVBService const gchar * service_name, const gchar * service_provider); +/* GST_MTS_DESC_DVB_SERVICE_LIST (0x41) */ +typedef struct _GstMpegTsDVBServiceListItem GstMpegTsDVBServiceListItem; + +/** + * GstMpegTsDVBServiceListItem: + * @service_id: the id of a service + * @type: the type of a service + */ +struct _GstMpegTsDVBServiceListItem +{ + guint16 service_id; + GstMpegTsDVBServiceType type; +}; + +gboolean gst_mpegts_descriptor_parse_dvb_service_list (const GstMpegTsDescriptor * descriptor, + GPtrArray ** list); + /* GST_MTS_DESC_DVB_LINKAGE (0x4A) */ /** * GstMpegTsDVBLinkageType: