m3u8: Expose GstM3U8InitFile methods
authorJan Schmidt <jan@centricular.com>
Mon, 31 Oct 2022 14:41:35 +0000 (01:41 +1100)
committerTim-Philipp Müller <tim@centricular.com>
Tue, 1 Nov 2022 11:51:44 +0000 (11:51 +0000)
Exposure ref/unref methods for the GstM3U8InitFile type,
and add a gst_m3u8_init_file_equal() comparison method.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3307>

subprojects/gst-plugins-good/ext/adaptivedemux2/hls/m3u8.c
subprojects/gst-plugins-good/ext/adaptivedemux2/hls/m3u8.h

index 511ce43..d27d4ca 100644 (file)
@@ -38,7 +38,6 @@
 
 #define GST_CAT_DEFAULT hls2_debug
 
-static void gst_m3u8_init_file_unref (GstM3U8InitFile * self);
 static gchar *uri_join (const gchar * uri, const gchar * path);
 
 GstHLSMediaPlaylist *
@@ -124,7 +123,7 @@ gst_m3u8_init_file_new (gchar * uri)
   return file;
 }
 
-static GstM3U8InitFile *
+GstM3U8InitFile *
 gst_m3u8_init_file_ref (GstM3U8InitFile * ifile)
 {
   g_assert (ifile != NULL && ifile->ref_count > 0);
@@ -133,7 +132,7 @@ gst_m3u8_init_file_ref (GstM3U8InitFile * ifile)
   return ifile;
 }
 
-static void
+void
 gst_m3u8_init_file_unref (GstM3U8InitFile * self)
 {
   g_return_if_fail (self != NULL && self->ref_count > 0);
@@ -144,6 +143,28 @@ gst_m3u8_init_file_unref (GstM3U8InitFile * self)
   }
 }
 
+gboolean
+gst_m3u8_init_file_equal (const GstM3U8InitFile * ifile1,
+    const GstM3U8InitFile * ifile2)
+{
+  if (ifile1 == ifile2)
+    return TRUE;
+
+  if (ifile1 == NULL && ifile2 != NULL)
+    return FALSE;
+  if (ifile1 != NULL && ifile2 == NULL)
+    return FALSE;
+
+  if (!g_str_equal (ifile1->uri, ifile2->uri))
+    return FALSE;
+  if (ifile1->offset != ifile2->offset)
+    return FALSE;
+  if (ifile1->size != ifile2->size)
+    return FALSE;
+
+  return TRUE;
+}
+
 static gboolean
 int_from_string (gchar * ptr, gchar ** endptr, gint * val)
 {
index 63238fd..41d8642 100644 (file)
@@ -158,6 +158,10 @@ struct _GstM3U8InitFile
   guint ref_count;      /* ATOMIC */
 };
 
+GstM3U8InitFile *gst_m3u8_init_file_ref (GstM3U8InitFile * ifile);
+void gst_m3u8_init_file_unref (GstM3U8InitFile * ifile);
+gboolean gst_m3u8_init_file_equal (const GstM3U8InitFile * ifile1, const GstM3U8InitFile *ifile2);
+
 GstM3U8MediaSegment *
 gst_m3u8_media_segment_ref   (GstM3U8MediaSegment * mfile);