diff options
author | Dave Robillard <dave@drobilla.net> | 2009-07-22 14:36:14 -0400 |
---|---|---|
committer | Dave Robillard <dave@drobilla.net> | 2009-07-22 14:36:14 -0400 |
commit | adadf06b0a9e26005ba9363aa0049dc0b740c94d (patch) | |
tree | b61e688d7ed775acff14763d0453102f80cc6c09 /ext/mimic/gstmimdec.c | |
parent | 23ef5d4ac3487345c1c91db57c76554363e6c0f5 (diff) | |
parent | 5d9d4a7b518c42bda88c7f6c87ce7c3c01233562 (diff) | |
download | gst-plugins-bad-adadf06b0a9e26005ba9363aa0049dc0b740c94d.tar.gz gst-plugins-bad-adadf06b0a9e26005ba9363aa0049dc0b740c94d.tar.bz2 gst-plugins-bad-adadf06b0a9e26005ba9363aa0049dc0b740c94d.zip |
Merge branch 'fdo' into lv2
Diffstat (limited to 'ext/mimic/gstmimdec.c')
-rw-r--r-- | ext/mimic/gstmimdec.c | 117 |
1 files changed, 12 insertions, 105 deletions
diff --git a/ext/mimic/gstmimdec.c b/ext/mimic/gstmimdec.c index 1579bd41..6a0abce5 100644 --- a/ext/mimic/gstmimdec.c +++ b/ext/mimic/gstmimdec.c @@ -68,8 +68,6 @@ static GstFlowReturn gst_mimdec_chain (GstPad * pad, GstBuffer * in); static GstStateChangeReturn gst_mimdec_change_state (GstElement * element, GstStateChange transition); -static gboolean gst_mimdec_sink_event (GstPad * pad, GstEvent * event); - GST_BOILERPLATE (GstMimDec, gst_mimdec, GstElement, GST_TYPE_ELEMENT); @@ -118,7 +116,6 @@ gst_mimdec_init (GstMimDec * mimdec, GstMimDecClass * klass) "sink"); gst_element_add_pad (GST_ELEMENT (mimdec), mimdec->sinkpad); gst_pad_set_chain_function (mimdec->sinkpad, gst_mimdec_chain); - gst_pad_set_event_function (mimdec->sinkpad, gst_mimdec_sink_event); mimdec->srcpad = gst_pad_new_from_template (gst_static_pad_template_get (&src_factory), @@ -154,6 +151,7 @@ gst_mimdec_chain (GstPad * pad, GstBuffer * in) gint width, height; GstCaps *caps; GstFlowReturn res = GST_FLOW_OK; + GstClockTime in_time = GST_BUFFER_TIMESTAMP (in); GST_DEBUG ("in gst_mimdec_chain"); @@ -181,10 +179,16 @@ gst_mimdec_chain (GstPad * pad, GstBuffer * in) goto out; } - fourcc = GST_MAKE_FOURCC ('M', 'L', '2', '0'); - if (GUINT32_FROM_LE (*((guint32 *) (header + 12))) != fourcc) { - GST_WARNING_OBJECT (mimdec, "invalid frame: unknown FOURCC code %d", - fourcc); + if (header[1] == 1) { + /* This is a a paused frame, skip it */ + gst_adapter_flush (mimdec->adapter, 24); + continue; + } + + fourcc = GUINT32_FROM_LE (*((guint32 *) (header + 12))); + if (GST_MAKE_FOURCC ('M', 'L', '2', '0') != fourcc) { + GST_WARNING_OBJECT (mimdec, "invalid frame: unknown FOURCC code" + " %X (%" GST_FOURCC_FORMAT ")", fourcc, GST_FOURCC_ARGS (fourcc)); gst_adapter_flush (mimdec->adapter, 24); res = GST_FLOW_ERROR; goto out; @@ -201,12 +205,6 @@ gst_mimdec_chain (GstPad * pad, GstBuffer * in) mimdec->have_header = TRUE; } - /* Check if its paused frame, drop it */ - if (mimdec->payload_size == 0) { - mimdec->have_header = FALSE; - continue; - } - if (gst_adapter_available (mimdec->adapter) < mimdec->payload_size) { goto out; } @@ -215,9 +213,6 @@ gst_mimdec_chain (GstPad * pad, GstBuffer * in) (guchar *) gst_adapter_peek (mimdec->adapter, mimdec->payload_size); if (mimdec->dec == NULL) { - GstEvent *event = NULL; - gboolean result = TRUE; - /* Check if its a keyframe, otherwise skip it */ if (GUINT32_FROM_LE (*((guint32 *) (frame_body + 12))) != 0) { gst_adapter_flush (mimdec->adapter, mimdec->payload_size); @@ -259,20 +254,6 @@ gst_mimdec_chain (GstPad * pad, GstBuffer * in) res = GST_FLOW_ERROR; goto out; } - - if (mimdec->need_newsegment) - event = gst_event_new_new_segment (FALSE, 1.0, GST_FORMAT_TIME, - mimdec->current_ts * GST_MSECOND, -1, 0); - mimdec->need_newsegment = FALSE; - GST_OBJECT_UNLOCK (mimdec); - if (event) - result = gst_pad_push_event (mimdec->srcpad, event); - GST_OBJECT_LOCK (mimdec); - if (!result) { - GST_WARNING_OBJECT (mimdec, "gst_pad_push_event failed"); - res = GST_FLOW_ERROR; - goto out; - } } out_buf = gst_buffer_new_and_alloc (mimdec->buffer_size); @@ -289,7 +270,7 @@ gst_mimdec_chain (GstPad * pad, GstBuffer * in) goto out; } - GST_BUFFER_TIMESTAMP (out_buf) = mimdec->current_ts * GST_MSECOND; + GST_BUFFER_TIMESTAMP (out_buf) = in_time; mimic_get_property (mimdec->dec, "width", &width); mimic_get_property (mimdec->dec, "height", &height); @@ -341,83 +322,9 @@ gst_mimdec_change_state (GstElement * element, GstStateChange transition) GST_OBJECT_UNLOCK (element); } break; - case GST_STATE_CHANGE_READY_TO_PAUSED: - GST_OBJECT_LOCK (element); - mimdec->need_newsegment = TRUE; - GST_OBJECT_UNLOCK (element); - break; default: break; } return GST_ELEMENT_CLASS (parent_class)->change_state (element, transition); } - -static gboolean -gst_mimdec_sink_event (GstPad * pad, GstEvent * event) -{ - gboolean res = TRUE; - GstMimDec *mimdec = GST_MIMDEC (gst_pad_get_parent (pad)); - - /* - * Ignore upstream newsegment event, its EVIL, we should implement - * proper seeking instead - */ - switch (GST_EVENT_TYPE (event)) { - case GST_EVENT_NEWSEGMENT: - { - gboolean update; - GstFormat format; - gdouble rate, arate; - gint64 start, stop, time; - - gst_event_parse_new_segment_full (event, &update, &rate, &arate, - &format, &start, &stop, &time); - - /* we need TIME and a positive rate */ - if (format != GST_FORMAT_TIME) - goto newseg_wrong_format; - - if (rate <= 0.0) - goto newseg_wrong_rate; - - GST_OBJECT_LOCK (mimdec); - mimdec->need_newsegment = FALSE; - GST_OBJECT_UNLOCK (mimdec); - - res = gst_pad_push_event (mimdec->srcpad, event); - } - break; - case GST_EVENT_FLUSH_STOP: - GST_OBJECT_LOCK (mimdec); - mimdec->need_newsegment = TRUE; - GST_OBJECT_UNLOCK (mimdec); - - res = gst_pad_push_event (mimdec->srcpad, event); - break; - default: - res = gst_pad_push_event (mimdec->srcpad, event); - break; - } - -done: - - gst_object_unref (mimdec); - - return res; - -newseg_wrong_format: - { - GST_DEBUG_OBJECT (mimdec, "received non TIME newsegment"); - gst_event_unref (event); - goto done; - } -newseg_wrong_rate: - { - GST_DEBUG_OBJECT (mimdec, "negative rates not supported yet"); - gst_event_unref (event); - goto done; - } - - -} |