From 5c6b0570911d23d86722fe247092fe4493fb05af Mon Sep 17 00:00:00 2001 From: Edward Hervey Date: Wed, 7 Dec 2005 11:34:37 +0000 Subject: [PATCH] Time to welcome ogm to 0.10 :) Original commit message from CVS: Time to welcome ogm to 0.10 :) * ext/ogg/gstoggdemux.c: (internal_element_pad_added_cb), (gst_ogg_pad_typefind): Oggdemux can now properly typefind elements with dynamic pads. * ext/ogg/gstogmparse.c: (gst_ogm_parse_chain): Properly set caps on src pad, and set caps on outgoing buffers. --- ChangeLog | 10 ++++++++++ ext/ogg/gstoggdemux.c | 28 ++++++++++++++++++++++++++-- ext/ogg/gstogmparse.c | 17 +++++++++-------- 3 files changed, 45 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index 69868af..2a410b7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2005-12-07 Edward Hervey + + Time to welcome ogm to 0.10 :) + + * ext/ogg/gstoggdemux.c: (internal_element_pad_added_cb), + (gst_ogg_pad_typefind): + Oggdemux can now properly typefind elements with dynamic pads. + * ext/ogg/gstogmparse.c: (gst_ogm_parse_chain): + Properly set caps on src pad, and set caps on outgoing buffers. + 2005-12-06 Thomas Vander Stichele * ext/alsa/gstalsamixer.h: diff --git a/ext/ogg/gstoggdemux.c b/ext/ogg/gstoggdemux.c index b165b6b..d6e25bb 100644 --- a/ext/ogg/gstoggdemux.c +++ b/ext/ogg/gstoggdemux.c @@ -121,6 +121,9 @@ struct _GstOggPad GstClockTime first_time; /* the timestamp of the second page */ ogg_stream_state stream; + + gboolean dynamic; /* True if the internal element had dynamic pads */ + guint padaddedid; /* The signal id for element::pad-added */ }; struct _GstOggPadClass @@ -595,6 +598,20 @@ gst_ogg_pad_internal_chain (GstPad * pad, GstBuffer * buffer) return GST_FLOW_OK; } +static void +internal_element_pad_added_cb (GstElement * element, GstPad * pad, + GstOggPad * oggpad) +{ + if (GST_PAD_DIRECTION (pad) == GST_PAD_SRC) { + if (!(gst_pad_link (pad, oggpad->elem_out) == GST_PAD_LINK_OK)) { + GST_ERROR ("Really couldn't find a valid pad"); + } + oggpad->dynamic = FALSE; + g_signal_handler_disconnect (element, oggpad->padaddedid); + oggpad->padaddedid = 0; + } +} + /* runs typefind on the packet, which is assumed to be the first * packet in the stream. * @@ -654,12 +671,19 @@ gst_ogg_pad_typefind (GstOggPad * pad, ogg_packet * packet) gst_object_unref (template); /* and this pad may not be named src.. */ + /* And it might also not exist at this time... */ { GstPad *p; p = gst_element_get_pad (element, "src"); - gst_pad_link (p, pad->elem_out); - gst_object_unref (p); + if (p) { + gst_pad_link (p, pad->elem_out); + gst_object_unref (p); + } else { + pad->dynamic = TRUE; + pad->padaddedid = g_signal_connect (G_OBJECT (element), + "pad-added", G_CALLBACK (internal_element_pad_added_cb), pad); + } } } } diff --git a/ext/ogg/gstogmparse.c b/ext/ogg/gstogmparse.c index 2c7d989..0329b00 100644 --- a/ext/ogg/gstogmparse.c +++ b/ext/ogg/gstogmparse.c @@ -623,14 +623,14 @@ gst_ogm_parse_chain (GstPad * pad, GstBuffer * buffer) g_assert_not_reached (); } - ogm->srcpad = gst_pad_new_from_template (ogm->srcpadtempl, "src"); - //gst_pad_use_explicit_caps (ogm->srcpad); - //if (!gst_pad_set_explicit_caps (ogm->srcpad, caps)) { - // GST_ELEMENT_ERROR (ogm, CORE, NEGOTIATION, (NULL), (NULL)); - //gst_object_unref (ogm->srcpad); - // ogm->srcpad = NULL; - // break; - //} + if (caps) { + ogm->srcpad = gst_pad_new ("src", GST_PAD_SRC); + gst_pad_set_caps (ogm->srcpad, caps); + } else { + GST_WARNING_OBJECT (ogm, + "No fixed caps were found, carrying on with template"); + ogm->srcpad = gst_pad_new_from_template (ogm->srcpadtempl, "src"); + } gst_element_add_pad (GST_ELEMENT (ogm), ogm->srcpad); break; } @@ -689,6 +689,7 @@ gst_ogm_parse_chain (GstPad * pad, GstBuffer * buffer) GST_ELEMENT_ERROR (ogm, RESOURCE, SYNC, (NULL), (NULL)); break; } + gst_buffer_set_caps (sbuf, GST_PAD_CAPS (ogm->srcpad)); gst_pad_push (ogm->srcpad, sbuf); } else { GST_ELEMENT_ERROR (ogm, STREAM, WRONG_TYPE, -- 2.7.4