From 8c53dfcfb6f7ebcc0438e7948d57d6d15090fd8b Mon Sep 17 00:00:00 2001 From: Edward Hervey Date: Tue, 1 Jul 2014 10:03:05 +0200 Subject: [PATCH] mpegts: Expose GstMpegtsDescriptor free function Nothing earth shattering, but avoids people having to use g_boxed_free() --- gst-libs/gst/mpegts/gst-dvb-section.c | 8 ++++---- gst-libs/gst/mpegts/gstmpegts-private.h | 1 - gst-libs/gst/mpegts/gstmpegtsdescriptor.c | 15 ++++++++++++--- gst-libs/gst/mpegts/gstmpegtsdescriptor.h | 2 ++ gst-libs/gst/mpegts/gstmpegtssection.c | 8 ++++---- tests/check/libs/mpegts.c | 8 ++++---- 6 files changed, 26 insertions(+), 16 deletions(-) diff --git a/gst-libs/gst/mpegts/gst-dvb-section.c b/gst-libs/gst/mpegts/gst-dvb-section.c index 72b2f90..03615b4 100644 --- a/gst-libs/gst/mpegts/gst-dvb-section.c +++ b/gst-libs/gst/mpegts/gst-dvb-section.c @@ -630,8 +630,8 @@ gst_mpegts_nit_new (void) nit = g_slice_new0 (GstMpegtsNIT); - nit->descriptors = - g_ptr_array_new_with_free_func ((GDestroyNotify) _free_descriptor); + nit->descriptors = g_ptr_array_new_with_free_func ((GDestroyNotify) + gst_mpegts_descriptor_free); nit->streams = g_ptr_array_new_with_free_func ((GDestroyNotify) _gst_mpegts_nit_stream_free); @@ -653,7 +653,7 @@ gst_mpegts_nit_stream_new (void) stream = g_slice_new0 (GstMpegtsNITStream); stream->descriptors = g_ptr_array_new_with_free_func ( - (GDestroyNotify) _free_descriptor); + (GDestroyNotify) gst_mpegts_descriptor_free); return stream; } @@ -979,7 +979,7 @@ gst_mpegts_sdt_service_new (void) service = g_slice_new0 (GstMpegtsSDTService); service->descriptors = g_ptr_array_new_with_free_func ((GDestroyNotify) - _free_descriptor); + gst_mpegts_descriptor_free); return service; } diff --git a/gst-libs/gst/mpegts/gstmpegts-private.h b/gst-libs/gst/mpegts/gstmpegts-private.h index 16a2cbd..5dcbe56 100644 --- a/gst-libs/gst/mpegts/gstmpegts-private.h +++ b/gst-libs/gst/mpegts/gstmpegts-private.h @@ -34,7 +34,6 @@ G_GNUC_INTERNAL guint32 _calc_crc32 (const guint8 *data, guint datalen); G_GNUC_INTERNAL gchar *get_encoding_and_convert (const gchar *text, guint length); G_GNUC_INTERNAL gchar *convert_lang_code (guint8 * data); G_GNUC_INTERNAL guint8 *dvb_text_from_utf8 (const gchar * text, gsize *out_size); -G_GNUC_INTERNAL void _free_descriptor (GstMpegtsDescriptor *descriptor); G_GNUC_INTERNAL GstMpegtsDescriptor *_new_descriptor (guint8 tag, guint8 length); G_GNUC_INTERNAL GstMpegtsDescriptor *_new_descriptor_with_extension (guint8 tag, guint8 tag_extension, guint8 length); diff --git a/gst-libs/gst/mpegts/gstmpegtsdescriptor.c b/gst-libs/gst/mpegts/gstmpegtsdescriptor.c index 6490b73..44a4ef9 100644 --- a/gst-libs/gst/mpegts/gstmpegtsdescriptor.c +++ b/gst-libs/gst/mpegts/gstmpegtsdescriptor.c @@ -715,15 +715,22 @@ _copy_descriptor (GstMpegtsDescriptor * desc) return copy; } +/** + * gst_mpegts_descriptor_free: + * @desc: The descriptor to free + * + * Frees @desc + */ void -_free_descriptor (GstMpegtsDescriptor * desc) +gst_mpegts_descriptor_free (GstMpegtsDescriptor * desc) { g_free ((gpointer) desc->data); g_slice_free (GstMpegtsDescriptor, desc); } G_DEFINE_BOXED_TYPE (GstMpegtsDescriptor, gst_mpegts_descriptor, - (GBoxedCopyFunc) _copy_descriptor, (GBoxedFreeFunc) _free_descriptor); + (GBoxedCopyFunc) _copy_descriptor, + (GBoxedFreeFunc) gst_mpegts_descriptor_free); /** * gst_mpegts_parse_descriptors: @@ -778,7 +785,9 @@ gst_mpegts_parse_descriptors (guint8 * buffer, gsize buf_len) return NULL; } - res = g_ptr_array_new_full (nb_desc + 1, (GDestroyNotify) _free_descriptor); + res = + g_ptr_array_new_full (nb_desc + 1, + (GDestroyNotify) gst_mpegts_descriptor_free); data = buffer; diff --git a/gst-libs/gst/mpegts/gstmpegtsdescriptor.h b/gst-libs/gst/mpegts/gstmpegtsdescriptor.h index 5c6b1e1..698d442 100644 --- a/gst-libs/gst/mpegts/gstmpegtsdescriptor.h +++ b/gst-libs/gst/mpegts/gstmpegtsdescriptor.h @@ -257,6 +257,8 @@ struct _GstMpegtsDescriptor guint8 *data; }; +void gst_mpegts_descriptor_free (GstMpegtsDescriptor *desc); + GPtrArray *gst_mpegts_parse_descriptors (guint8 * buffer, gsize buf_len); const GstMpegtsDescriptor * gst_mpegts_find_descriptor (GPtrArray *descriptors, diff --git a/gst-libs/gst/mpegts/gstmpegtssection.c b/gst-libs/gst/mpegts/gstmpegtssection.c index 362d329..1006576 100644 --- a/gst-libs/gst/mpegts/gstmpegtssection.c +++ b/gst-libs/gst/mpegts/gstmpegtssection.c @@ -763,8 +763,8 @@ gst_mpegts_pmt_new (void) pmt = g_slice_new0 (GstMpegtsPMT); - pmt->descriptors = - g_ptr_array_new_with_free_func ((GDestroyNotify) _free_descriptor); + pmt->descriptors = g_ptr_array_new_with_free_func ((GDestroyNotify) + gst_mpegts_descriptor_free); pmt->streams = g_ptr_array_new_with_free_func ((GDestroyNotify) _gst_mpegts_pmt_stream_free); @@ -785,8 +785,8 @@ gst_mpegts_pmt_stream_new (void) stream = g_slice_new0 (GstMpegtsPMTStream); - stream->descriptors = - g_ptr_array_new_with_free_func ((GDestroyNotify) _free_descriptor); + stream->descriptors = g_ptr_array_new_with_free_func ((GDestroyNotify) + gst_mpegts_descriptor_free); return stream; } diff --git a/tests/check/libs/mpegts.c b/tests/check/libs/mpegts.c index f22c6e3..d96211a 100644 --- a/tests/check/libs/mpegts.c +++ b/tests/check/libs/mpegts.c @@ -453,7 +453,7 @@ GST_START_TEST (test_mpegts_descriptors) fail ("0x%X != 0x%X in byte %d of registration descriptor", desc->data[i], registration_descriptor[i], i); } - g_boxed_free (GST_TYPE_MPEGTS_DESCRIPTOR, desc); + gst_mpegts_descriptor_free (desc); } GST_END_TEST; @@ -498,7 +498,7 @@ GST_START_TEST (test_mpegts_dvb_descriptors) fail_unless (ret == TRUE); fail_unless (strcmp (string, "Name") == 0); g_free (string); - g_boxed_free (GST_TYPE_MPEGTS_DESCRIPTOR, desc); + gst_mpegts_descriptor_free (desc); /* Descriptor should fail if string is more than 255 bytes */ memset (long_string, 0x41, 256); @@ -531,7 +531,7 @@ GST_START_TEST (test_mpegts_dvb_descriptors) fail_unless (strcmp (provider, "Provider") == 0); g_free (string); g_free (provider); - g_boxed_free (GST_TYPE_MPEGTS_DESCRIPTOR, desc); + gst_mpegts_descriptor_free (desc); /* Check creation of descriptor without data */ desc = gst_mpegts_descriptor_from_dvb_service @@ -543,7 +543,7 @@ GST_START_TEST (test_mpegts_dvb_descriptors) /* Check parsing of descriptor without data */ ret = gst_mpegts_descriptor_parse_dvb_service (desc, NULL, NULL, NULL); fail_unless (ret == TRUE); - g_boxed_free (GST_TYPE_MPEGTS_DESCRIPTOR, desc); + gst_mpegts_descriptor_free (desc); /* Descriptor should fail if string is more than 255 bytes */ memset (long_string, 0x41, 256); -- 2.7.4