m3u8: Expose GstM3U8InitFile methods

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>
This commit is contained in:
Jan Schmidt 2022-11-01 01:41:35 +11:00 committed by Tim-Philipp Müller
parent 9e6056b306
commit 9b8c71d148
2 changed files with 28 additions and 3 deletions

View 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)
{

View 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);