mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-07-27 08:48:19 +00:00
oggmux: ensure serialnos are unique
We do that by checking a newly generated one is not already used in an existing stream, and doing it again if it is. https://bugzilla.gnome.org/show_bug.cgi?id=640211
This commit is contained in:
parent
54c19ba6de
commit
96a1a9dec6
|
@ -337,6 +337,34 @@ gst_ogg_mux_sink_event (GstPad * pad, GstEvent * event)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
gst_ogg_mux_is_serialno_present (GstOggMux * ogg_mux, guint32 serialno)
|
||||||
|
{
|
||||||
|
GSList *walk;
|
||||||
|
|
||||||
|
walk = ogg_mux->collect->data;
|
||||||
|
while (walk) {
|
||||||
|
GstOggPadData *pad = (GstOggPadData *) walk->data;
|
||||||
|
if (pad->map.serialno == serialno)
|
||||||
|
return TRUE;
|
||||||
|
walk = walk->next;
|
||||||
|
}
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static guint32
|
||||||
|
gst_ogg_mux_generate_serialno (GstOggMux * ogg_mux)
|
||||||
|
{
|
||||||
|
guint32 serialno;
|
||||||
|
|
||||||
|
do {
|
||||||
|
serialno = g_random_int_range (0, G_MAXINT32);
|
||||||
|
} while (gst_ogg_mux_is_serialno_present (ogg_mux, serialno));
|
||||||
|
|
||||||
|
return serialno;
|
||||||
|
}
|
||||||
|
|
||||||
static GstPad *
|
static GstPad *
|
||||||
gst_ogg_mux_request_new_pad (GstElement * element,
|
gst_ogg_mux_request_new_pad (GstElement * element,
|
||||||
GstPadTemplate * templ, const gchar * req_name)
|
GstPadTemplate * templ, const gchar * req_name)
|
||||||
|
@ -364,7 +392,7 @@ gst_ogg_mux_request_new_pad (GstElement * element,
|
||||||
|
|
||||||
if (req_name == NULL || strlen (req_name) < 6) {
|
if (req_name == NULL || strlen (req_name) < 6) {
|
||||||
/* no name given when requesting the pad, use random serial number */
|
/* no name given when requesting the pad, use random serial number */
|
||||||
serial = rand ();
|
serial = gst_ogg_mux_generate_serialno (ogg_mux);
|
||||||
} else {
|
} else {
|
||||||
/* parse serial number from requested padname */
|
/* parse serial number from requested padname */
|
||||||
serial = atoi (&req_name[5]);
|
serial = atoi (&req_name[5]);
|
||||||
|
|
Loading…
Reference in a new issue