jifmux: Avoid adding 2 xmp packets

jifmux was only appending a new xmp packet to the stream,
it should replace if there is already one.
This commit is contained in:
Thiago Santos 2010-05-07 10:13:54 -03:00
parent 33b17318f2
commit 0d637e4f09

View file

@ -216,6 +216,15 @@ gst_jif_mux_sink_event (GstPad * pad, GstEvent * event)
return ret;
}
static void
gst_jif_mux_marker_free (GstJifMuxMarker * m)
{
if (m->owned)
g_free ((gpointer) m->data);
g_slice_free (GstJifMuxMarker, m);
}
static void
gst_jif_mux_reset (GstJifMux * self)
{
@ -224,11 +233,7 @@ gst_jif_mux_reset (GstJifMux * self)
for (node = self->priv->markers; node; node = g_list_next (node)) {
m = (GstJifMuxMarker *) node->data;
if (m->owned)
g_free ((gpointer) m->data);
g_slice_free (GstJifMuxMarker, m);
gst_jif_mux_marker_free (m);
}
g_list_free (self->priv->markers);
self->priv->markers = NULL;
@ -459,15 +464,22 @@ gst_jif_mux_mangle_markers (GstJifMux * self)
memcpy (&data[29], xmp, size);
m = gst_jif_mux_new_marker (APP1, size + 29, data, TRUE);
pos = file_hdr;
if (app1_exif)
pos = app1_exif;
else if (app0_jfif)
pos = app0_jfif;
pos = g_list_next (pos);
/* replace the old xmp marker and not add a new one */
if (app1_xmp) {
gst_jif_mux_marker_free ((GstJifMuxMarker *) app1_xmp->data);
app1_xmp->data = m;
} else {
self->priv->markers = g_list_insert_before (self->priv->markers, pos, m);
pos = file_hdr;
if (app1_exif)
pos = app1_exif;
else if (app0_jfif)
pos = app0_jfif;
pos = g_list_next (pos);
self->priv->markers = g_list_insert_before (self->priv->markers, pos, m);
}
gst_buffer_unref (xmp_data);
modified = TRUE;
}