From bb7f93bd4eee6e78378e2157c6448e28dda717e1 Mon Sep 17 00:00:00 2001 From: Julien Moutte Date: Fri, 13 Jun 2008 22:46:43 +0000 Subject: gst/flv/: Introduce demuxing support for AAC and Original commit message from CVS: 2008-06-14 Julien Moutte * gst/flv/gstflvdemux.c: (gst_flv_demux_cleanup), (gst_flv_demux_dispose): * gst/flv/gstflvdemux.h: * gst/flv/gstflvparse.c: (gst_flv_parse_audio_negotiate), (gst_flv_parse_tag_audio), (gst_flv_parse_video_negotiate), (gst_flv_parse_tag_video): Introduce demuxing support for AAC and H.264/AVC inside FLV. * sys/dshowdecwrapper/gstdshowaudiodec.c: (gst_dshowaudiodec_init), (gst_dshowaudiodec_chain), (gst_dshowaudiodec_push_buffer), (gst_dshowaudiodec_sink_event), (gst_dshowaudiodec_setup_graph): * sys/dshowdecwrapper/gstdshowaudiodec.h: * sys/dshowdecwrapper/gstdshowvideodec.c: (gst_dshowvideodec_init), (gst_dshowvideodec_sink_event), (gst_dshowvideodec_chain), (gst_dshowvideodec_push_buffer), (gst_dshowvideodec_src_getcaps): * sys/dshowdecwrapper/gstdshowvideodec.h: Lot of random fixes to improve stability (ref counting, safety checks...) --- sys/dshowdecwrapper/gstdshowaudiodec.c | 28 +++++++++++++++++--------- sys/dshowdecwrapper/gstdshowaudiodec.h | 2 ++ sys/dshowdecwrapper/gstdshowvideodec.c | 36 +++++++++++++++++++++++----------- sys/dshowdecwrapper/gstdshowvideodec.h | 2 ++ 4 files changed, 48 insertions(+), 20 deletions(-) (limited to 'sys') diff --git a/sys/dshowdecwrapper/gstdshowaudiodec.c b/sys/dshowdecwrapper/gstdshowaudiodec.c index 6bb298ce..b7be7ac6 100644 --- a/sys/dshowdecwrapper/gstdshowaudiodec.c +++ b/sys/dshowdecwrapper/gstdshowaudiodec.c @@ -308,6 +308,8 @@ gst_dshowaudiodec_init (GstDshowAudioDec * adec, adec->layer = 0; adec->codec_data = NULL; + adec->last_ret = GST_FLOW_OK; + CoInitializeEx (NULL, COINIT_MULTITHREADED); } @@ -420,7 +422,6 @@ end: static GstFlowReturn gst_dshowaudiodec_chain (GstPad * pad, GstBuffer * buffer) { - GstFlowReturn ret = GST_FLOW_OK; GstDshowAudioDec *adec = (GstDshowAudioDec *) gst_pad_get_parent (pad); gboolean discount = FALSE; @@ -436,13 +437,20 @@ gst_dshowaudiodec_chain (GstPad * pad, GstBuffer * buffer) /* setup dshow graph */ if (!gst_dshowaudiodec_setup_graph (adec)) { - return GST_FLOW_ERROR; + adec->last_ret = GST_FLOW_ERROR; + goto beach; } } if (!adec->gstdshowsrcfilter) { /* we are not setup */ - ret = GST_FLOW_WRONG_STATE; + adec->last_ret = GST_FLOW_WRONG_STATE; + goto beach; + } + + if (GST_FLOW_IS_FATAL (adec->last_ret)) { + GST_DEBUG_OBJECT (adec, "last decoding iteration generated a fatal error " + "%s", gst_flow_get_name (adec->last_ret)); goto beach; } @@ -470,7 +478,7 @@ gst_dshowaudiodec_chain (GstPad * pad, GstBuffer * buffer) beach: gst_buffer_unref (buffer); gst_object_unref (adec); - return ret; + return adec->last_ret; } static gboolean @@ -509,7 +517,7 @@ gst_dshowaudiodec_push_buffer (byte * buffer, long size, byte * src_object, /* buffer is in our segment allocate a new out buffer and clip it if needed */ /* allocate a new buffer for raw audio */ - gst_pad_alloc_buffer (adec->srcpad, GST_BUFFER_OFFSET_NONE, + adec->last_ret = gst_pad_alloc_buffer (adec->srcpad, GST_BUFFER_OFFSET_NONE, size, GST_PAD_CAPS (adec->srcpad), &out_buf); if (!out_buf) { GST_CAT_ERROR_OBJECT (dshowaudiodec_debug, adec, @@ -518,10 +526,10 @@ gst_dshowaudiodec_push_buffer (byte * buffer, long size, byte * src_object, } /* set buffer properties */ - GST_BUFFER_SIZE (out_buf) = size; GST_BUFFER_TIMESTAMP (out_buf) = buf_start; GST_BUFFER_DURATION (out_buf) = buf_stop - buf_start; - memcpy (GST_BUFFER_DATA (out_buf), buffer, size); + memcpy (GST_BUFFER_DATA (out_buf), buffer, + MIN (size, GST_BUFFER_SIZE (out_buf))); /* we have to remove some heading samples */ if (clip_start > buf_start) { @@ -560,7 +568,7 @@ gst_dshowaudiodec_push_buffer (byte * buffer, long size, byte * src_object, GST_BUFFER_DURATION (out_buf)), GST_TIME_ARGS (GST_BUFFER_DURATION (out_buf))); - gst_pad_push (adec->srcpad, out_buf); + adec->last_ret = gst_pad_push (adec->srcpad, out_buf); return TRUE; } @@ -608,6 +616,9 @@ gst_dshowaudiodec_sink_event (GstPad * pad, GstEvent * event) ret = gst_pad_event_default (pad, event); break; } + + gst_object_unref (adec); + return ret; } @@ -899,7 +910,6 @@ gst_dshowaudiodec_setup_graph (GstDshowAudioDec * adec) ret = TRUE; adec->setup = TRUE; end: - gst_object_unref (adec); if (input_format) g_free (input_format); if (gstdshowinterface) diff --git a/sys/dshowdecwrapper/gstdshowaudiodec.h b/sys/dshowdecwrapper/gstdshowaudiodec.h index d29ad7c1..d667aa46 100644 --- a/sys/dshowdecwrapper/gstdshowaudiodec.h +++ b/sys/dshowdecwrapper/gstdshowaudiodec.h @@ -68,6 +68,8 @@ struct _GstDshowAudioDec /* element pads */ GstPad *sinkpad; GstPad *srcpad; + + GstFlowReturn last_ret; /* filters interfaces*/ IBaseFilter *srcfilter; 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 diff --git a/sys/dshowdecwrapper/gstdshowvideodec.h b/sys/dshowdecwrapper/gstdshowvideodec.h index 12f3a28e..0989dabc 100644 --- a/sys/dshowdecwrapper/gstdshowvideodec.h +++ b/sys/dshowdecwrapper/gstdshowvideodec.h @@ -70,6 +70,8 @@ struct _GstDshowVideoDec /* caps of our src pad */ GstCaps *srccaps; + + GstFlowReturn last_ret; /* list of dshow mediatypes coresponding to the caps list */ GList *mediatypes; -- cgit v1.2.1