diff --git a/ChangeLog b/ChangeLog index a4dc02cfd1..303a7d4fcb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2008-08-07 Sebastian Dröge + + * ext/ogg/gstoggmux.c: (gst_ogg_mux_sink_event), + (gst_ogg_mux_request_new_pad): + * ext/ogg/gstoggmux.h: + Don't pretend to support NEWSEGMENT events, instead override the + GstCollectPads event function to return FALSE on NEWSEGMENT events + and do the normal work for other events. + + This prevents elements like flacenc to seek to the start and rewrite + some data which then results in a broken Ogg packet. + 2008-08-07 Tim-Philipp Müller Patch by: Frederic Crozat diff --git a/ext/ogg/gstoggmux.c b/ext/ogg/gstoggmux.c index 7ab13cf62a..1cacfc9c99 100644 --- a/ext/ogg/gstoggmux.c +++ b/ext/ogg/gstoggmux.c @@ -300,6 +300,35 @@ gst_ogg_mux_sinkconnect (GstPad * pad, GstPad * peer) return GST_PAD_LINK_OK; } +static gboolean +gst_ogg_mux_sink_event (GstPad * pad, GstEvent * event) +{ + GstOggMux *ogg_mux = GST_OGG_MUX (gst_pad_get_parent (pad)); + GstOggPad *ogg_pad = (GstOggPad *) gst_pad_get_element_private (pad); + gboolean ret; + + GST_DEBUG ("Got %s event on pad %s:%s", GST_EVENT_TYPE_NAME (event), + GST_DEBUG_PAD_NAME (pad)); + + switch (GST_EVENT_TYPE (event)) { + case GST_EVENT_NEWSEGMENT: + /* We don't support NEWSEGMENT events */ + gst_event_unref (event); + ret = FALSE; + break; + default: + ret = TRUE; + break; + } + + /* now GstCollectPads can take care of the rest, e.g. EOS */ + if (ret) + ret = ogg_pad->collect_event (pad, event); + + gst_object_unref (ogg_mux); + return ret; +} + static GstPad * gst_ogg_mux_request_new_pad (GstElement * element, GstPadTemplate * templ, const gchar * req_name) @@ -359,11 +388,16 @@ gst_ogg_mux_request_new_pad (GstElement * element, oggpad->first_delta = FALSE; oggpad->prev_delta = FALSE; oggpad->pagebuffers = g_queue_new (); + + oggpad->collect_event = (GstPadEventFunction) GST_PAD_EVENTFUNC (newpad); + gst_pad_set_event_function (newpad, + GST_DEBUG_FUNCPTR (gst_ogg_mux_sink_event)); } } /* setup some pad functions */ gst_pad_set_link_function (newpad, gst_ogg_mux_sinkconnect); + /* dd the pad to the element */ gst_element_add_pad (element, newpad); diff --git a/ext/ogg/gstoggmux.h b/ext/ogg/gstoggmux.h index dc7965f95d..4d1d233c9d 100644 --- a/ext/ogg/gstoggmux.h +++ b/ext/ogg/gstoggmux.h @@ -77,6 +77,8 @@ typedef struct gboolean new_page; /* starting a new page */ gboolean first_delta; /* was the first packet in the page a delta */ gboolean prev_delta; /* was the previous buffer a delta frame */ + + GstPadEventFunction collect_event; } GstOggPad;