summaryrefslogtreecommitdiffstats
path: root/sys/dshowdecwrapper/gstdshowvideodec.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/dshowdecwrapper/gstdshowvideodec.c')
-rw-r--r--sys/dshowdecwrapper/gstdshowvideodec.c36
1 files changed, 25 insertions, 11 deletions
diff --git a/sys/dshowdecwrapper/gstdshowvideodec.c b/sys/dshowdecwrapper/gstdshowvideodec.c
index 01cf6813..c31bb945 100644
--- a/sys/dshowdecwrapper/gstdshowvideodec.c
+++ b/sys/dshowdecwrapper/gstdshowvideodec.c
@@ -329,6 +329,8 @@ gst_dshowvideodec_init (GstDshowVideoDec * vdec,
vdec->decfilter = NULL;
vdec->sinkfilter = NULL;
+ vdec->last_ret = GST_FLOW_OK;
+
vdec->filtergraph = NULL;
vdec->mediafilter = NULL;
vdec->gstdshowsrcfilter = NULL;
@@ -659,20 +661,28 @@ gst_dshowvideodec_sink_event (GstPad * pad, GstEvent * event)
ret = gst_pad_event_default (pad, event);
break;
}
+
+ gst_object_unref (vdec);
+
return ret;
}
static GstFlowReturn
gst_dshowvideodec_chain (GstPad * pad, GstBuffer * buffer)
{
- GstFlowReturn ret = GST_FLOW_OK;
GstDshowVideoDec *vdec = (GstDshowVideoDec *) gst_pad_get_parent (pad);
gboolean discount = FALSE;
GstClockTime stop;
if (!vdec->gstdshowsrcfilter) {
/* we are not setup */
- ret = GST_FLOW_WRONG_STATE;
+ vdec->last_ret = GST_FLOW_WRONG_STATE;
+ goto beach;
+ }
+
+ if (GST_FLOW_IS_FATAL (vdec->last_ret)) {
+ GST_DEBUG_OBJECT (vdec, "last decoding iteration generated a fatal error "
+ "%s", gst_flow_get_name (vdec->last_ret));
goto beach;
}
@@ -707,7 +717,7 @@ beach:
gst_buffer_unref (buffer);
gst_object_unref (vdec);
- return ret;
+ return vdec->last_ret;
}
static gboolean
@@ -733,8 +743,9 @@ gst_dshowvideodec_push_buffer (byte * buffer, long size, byte * src_object,
return FALSE;
}
- /* buffer is in our segment allocate a new out buffer and clip its timestamps */
- gst_pad_alloc_buffer (vdec->srcpad, GST_BUFFER_OFFSET_NONE,
+ /* buffer is in our segment allocate a new out buffer and clip its
+ * timestamps */
+ vdec->last_ret = gst_pad_alloc_buffer (vdec->srcpad, GST_BUFFER_OFFSET_NONE,
size, GST_PAD_CAPS (vdec->srcpad), &buf);
if (!buf) {
GST_CAT_WARNING_OBJECT (dshowvideodec_debug, vdec,
@@ -743,7 +754,6 @@ gst_dshowvideodec_push_buffer (byte * buffer, long size, byte * src_object,
}
/* set buffer properties */
- GST_BUFFER_SIZE (buf) = size;
GST_BUFFER_TIMESTAMP (buf) = clip_start;
GST_BUFFER_DURATION (buf) = clip_stop - clip_start;
@@ -760,7 +770,7 @@ gst_dshowvideodec_push_buffer (byte * buffer, long size, byte * src_object,
buffer + (size - ((line + 1) * (stride))), stride);
}
} else {
- memcpy (GST_BUFFER_DATA (buf), buffer, size);
+ memcpy (GST_BUFFER_DATA (buf), buffer, MIN (size, GST_BUFFER_SIZE (buf)));
}
GST_CAT_LOG_OBJECT (dshowvideodec_debug, vdec,
@@ -771,7 +781,7 @@ gst_dshowvideodec_push_buffer (byte * buffer, long size, byte * src_object,
GST_TIME_ARGS (GST_BUFFER_DURATION (buf)));
/* push the buffer downstream */
- gst_pad_push (vdec->srcpad, buf);
+ vdec->last_ret = gst_pad_push (vdec->srcpad, buf);
return TRUE;
}
@@ -781,6 +791,7 @@ static GstCaps *
gst_dshowvideodec_src_getcaps (GstPad * pad)
{
GstDshowVideoDec *vdec = (GstDshowVideoDec *) gst_pad_get_parent (pad);
+ GstCaps *caps = NULL;
if (!vdec->srccaps)
vdec->srccaps = gst_caps_new_empty ();
@@ -795,7 +806,7 @@ gst_dshowvideodec_src_getcaps (GstPad * pad)
&output_pin)) {
GST_ELEMENT_ERROR (vdec, STREAM, FAILED,
("failed getting ouput pin from the decoder"), (NULL));
- return NULL;
+ goto beach;
}
hres = IPin_EnumMediaTypes (output_pin, &enum_mediatypes);
@@ -848,9 +859,12 @@ gst_dshowvideodec_src_getcaps (GstPad * pad)
}
if (vdec->srccaps)
- return gst_caps_ref (vdec->srccaps);
+ caps = gst_caps_ref (vdec->srccaps);
+
+beach:
+ gst_object_unref (vdec);
- return NULL;
+ return caps;
}
static gboolean