diff options
author | Mark Nauwelaerts <mark.nauwelaerts@collabora.co.uk> | 2011-02-10 18:11:46 +0100 |
---|---|---|
committer | Mark Nauwelaerts <mark.nauwelaerts@collabora.co.uk> | 2011-02-10 18:17:56 +0100 |
commit | 686189f3f0cb7c26836ea2a5b6f294faddcf9971 (patch) | |
tree | cb66720795629179c4955e42f69ddadfe9647db6 | |
parent | 3dc42d370437e4fc1362e861f9c44d685b262aa3 (diff) |
qtdemux: propagate error during expose_streams
... as it may occur during initial parsing of fragmented file.
-rw-r--r-- | gst/qtdemux/qtdemux.c | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/gst/qtdemux/qtdemux.c b/gst/qtdemux/qtdemux.c index 7be9986f0..96e320d77 100644 --- a/gst/qtdemux/qtdemux.c +++ b/gst/qtdemux/qtdemux.c | |||
@@ -425,7 +425,7 @@ static GstCaps *qtdemux_sub_caps (GstQTDemux * qtdemux, | |||
425 | gchar ** codec_name); | 425 | gchar ** codec_name); |
426 | static gboolean qtdemux_parse_samples (GstQTDemux * qtdemux, | 426 | static gboolean qtdemux_parse_samples (GstQTDemux * qtdemux, |
427 | QtDemuxStream * stream, guint32 n); | 427 | QtDemuxStream * stream, guint32 n); |
428 | static void qtdemux_expose_streams (GstQTDemux * qtdemux); | 428 | static GstFlowReturn qtdemux_expose_streams (GstQTDemux * qtdemux); |
429 | 429 | ||
430 | 430 | ||
431 | static void | 431 | static void |
@@ -2765,7 +2765,7 @@ gst_qtdemux_loop_state_header (GstQTDemux * qtdemux) | |||
2765 | beach: | 2765 | beach: |
2766 | if (ret == GST_FLOW_UNEXPECTED && qtdemux->got_moov) { | 2766 | if (ret == GST_FLOW_UNEXPECTED && qtdemux->got_moov) { |
2767 | /* digested all data, show what we have */ | 2767 | /* digested all data, show what we have */ |
2768 | qtdemux_expose_streams (qtdemux); | 2768 | ret = qtdemux_expose_streams (qtdemux); |
2769 | 2769 | ||
2770 | /* Only post, event on pads is done after newsegment */ | 2770 | /* Only post, event on pads is done after newsegment */ |
2771 | qtdemux_post_global_tags (qtdemux); | 2771 | qtdemux_post_global_tags (qtdemux); |
@@ -2773,7 +2773,7 @@ beach: | |||
2773 | qtdemux->state = QTDEMUX_STATE_MOVIE; | 2773 | qtdemux->state = QTDEMUX_STATE_MOVIE; |
2774 | GST_DEBUG_OBJECT (qtdemux, "switching state to STATE_MOVIE (%d)", | 2774 | GST_DEBUG_OBJECT (qtdemux, "switching state to STATE_MOVIE (%d)", |
2775 | qtdemux->state); | 2775 | qtdemux->state); |
2776 | return GST_FLOW_OK; | 2776 | return ret; |
2777 | } | 2777 | } |
2778 | return ret; | 2778 | return ret; |
2779 | } | 2779 | } |
@@ -5116,20 +5116,20 @@ locate_failed: | |||
5116 | 5116 | ||
5117 | /* should only do something in pull mode */ | 5117 | /* should only do something in pull mode */ |
5118 | /* call with OBJECT lock */ | 5118 | /* call with OBJECT lock */ |
5119 | static gboolean | 5119 | static GstFlowReturn |
5120 | qtdemux_add_fragmented_samples (GstQTDemux * qtdemux) | 5120 | qtdemux_add_fragmented_samples (GstQTDemux * qtdemux) |
5121 | { | 5121 | { |
5122 | guint64 length, offset; | 5122 | guint64 length, offset; |
5123 | GstBuffer *buf = NULL; | 5123 | GstBuffer *buf = NULL; |
5124 | GstFlowReturn ret = GST_FLOW_OK; | 5124 | GstFlowReturn ret = GST_FLOW_OK; |
5125 | gboolean res = TRUE; | 5125 | GstFlowReturn res = TRUE; |
5126 | 5126 | ||
5127 | offset = qtdemux->moof_offset; | 5127 | offset = qtdemux->moof_offset; |
5128 | GST_DEBUG_OBJECT (qtdemux, "next moof at offset %" G_GUINT64_FORMAT, offset); | 5128 | GST_DEBUG_OBJECT (qtdemux, "next moof at offset %" G_GUINT64_FORMAT, offset); |
5129 | 5129 | ||
5130 | if (!offset) { | 5130 | if (!offset) { |
5131 | GST_DEBUG_OBJECT (qtdemux, "no next moof"); | 5131 | GST_DEBUG_OBJECT (qtdemux, "no next moof"); |
5132 | return FALSE; | 5132 | return GST_FLOW_UNEXPECTED; |
5133 | } | 5133 | } |
5134 | 5134 | ||
5135 | /* best not do pull etc with lock held */ | 5135 | /* best not do pull etc with lock held */ |
@@ -5169,7 +5169,7 @@ parse_failed: | |||
5169 | { | 5169 | { |
5170 | GST_DEBUG_OBJECT (qtdemux, "failed to parse moof"); | 5170 | GST_DEBUG_OBJECT (qtdemux, "failed to parse moof"); |
5171 | offset = 0; | 5171 | offset = 0; |
5172 | res = FALSE; | 5172 | res = GST_FLOW_ERROR; |
5173 | goto exit; | 5173 | goto exit; |
5174 | } | 5174 | } |
5175 | flow_failed: | 5175 | flow_failed: |
@@ -5182,7 +5182,7 @@ flow_failed: | |||
5182 | GST_DEBUG_OBJECT (qtdemux, "upstream WRONG_STATE"); | 5182 | GST_DEBUG_OBJECT (qtdemux, "upstream WRONG_STATE"); |
5183 | /* resume at current position next time */ | 5183 | /* resume at current position next time */ |
5184 | } | 5184 | } |
5185 | res = FALSE; | 5185 | res = ret; |
5186 | goto exit; | 5186 | goto exit; |
5187 | } | 5187 | } |
5188 | } | 5188 | } |
@@ -5772,7 +5772,7 @@ done: | |||
5772 | GST_DEBUG_OBJECT (qtdemux, | 5772 | GST_DEBUG_OBJECT (qtdemux, |
5773 | "parsed all available samples; checking for more"); | 5773 | "parsed all available samples; checking for more"); |
5774 | while (n + 1 == stream->n_samples) | 5774 | while (n + 1 == stream->n_samples) |
5775 | if (!qtdemux_add_fragmented_samples (qtdemux)) | 5775 | if (qtdemux_add_fragmented_samples (qtdemux) != GST_FLOW_OK) |
5776 | break; | 5776 | break; |
5777 | } | 5777 | } |
5778 | GST_OBJECT_UNLOCK (qtdemux); | 5778 | GST_OBJECT_UNLOCK (qtdemux); |
@@ -7323,14 +7323,15 @@ too_many_streams: | |||
7323 | } | 7323 | } |
7324 | } | 7324 | } |
7325 | 7325 | ||
7326 | static void | 7326 | static GstFlowReturn |
7327 | qtdemux_expose_streams (GstQTDemux * qtdemux) | 7327 | qtdemux_expose_streams (GstQTDemux * qtdemux) |
7328 | { | 7328 | { |
7329 | gint i; | 7329 | gint i; |
7330 | GstFlowReturn ret = GST_FLOW_OK; | ||
7330 | 7331 | ||
7331 | GST_DEBUG_OBJECT (qtdemux, "exposing streams"); | 7332 | GST_DEBUG_OBJECT (qtdemux, "exposing streams"); |
7332 | 7333 | ||
7333 | for (i = 0; i < qtdemux->n_streams; i++) { | 7334 | for (i = 0; ret == GST_FLOW_OK && i < qtdemux->n_streams; i++) { |
7334 | QtDemuxStream *stream = qtdemux->streams[i]; | 7335 | QtDemuxStream *stream = qtdemux->streams[i]; |
7335 | guint32 sample_num = 0; | 7336 | guint32 sample_num = 0; |
7336 | guint samples = 20; | 7337 | guint samples = 20; |
@@ -7344,7 +7345,7 @@ qtdemux_expose_streams (GstQTDemux * qtdemux) | |||
7344 | /* need all moov samples first */ | 7345 | /* need all moov samples first */ |
7345 | GST_OBJECT_LOCK (qtdemux); | 7346 | GST_OBJECT_LOCK (qtdemux); |
7346 | while (stream->n_samples == 0) | 7347 | while (stream->n_samples == 0) |
7347 | if (!qtdemux_add_fragmented_samples (qtdemux)) | 7348 | if ((ret = qtdemux_add_fragmented_samples (qtdemux)) != GST_FLOW_OK) |
7348 | break; | 7349 | break; |
7349 | GST_OBJECT_UNLOCK (qtdemux); | 7350 | GST_OBJECT_UNLOCK (qtdemux); |
7350 | } else { | 7351 | } else { |
@@ -7352,6 +7353,10 @@ qtdemux_expose_streams (GstQTDemux * qtdemux) | |||
7352 | qtdemux->moof_offset = 0; | 7353 | qtdemux->moof_offset = 0; |
7353 | } | 7354 | } |
7354 | 7355 | ||
7356 | /* prepare braking */ | ||
7357 | if (ret != GST_FLOW_ERROR) | ||
7358 | ret = GST_FLOW_OK; | ||
7359 | |||
7355 | /* in pull mode, we should have parsed some sample info by now; | 7360 | /* in pull mode, we should have parsed some sample info by now; |
7356 | * and quite some code will not handle no samples. | 7361 | * and quite some code will not handle no samples. |
7357 | * in push mode, we'll just have to deal with it */ | 7362 | * in push mode, we'll just have to deal with it */ |
@@ -7411,6 +7416,8 @@ qtdemux_expose_streams (GstQTDemux * qtdemux) | |||
7411 | gst_element_post_message (GST_ELEMENT_CAST (qtdemux), m); | 7416 | gst_element_post_message (GST_ELEMENT_CAST (qtdemux), m); |
7412 | qtdemux->posted_redirect = TRUE; | 7417 | qtdemux->posted_redirect = TRUE; |
7413 | } | 7418 | } |
7419 | |||
7420 | return ret; | ||
7414 | } | 7421 | } |
7415 | 7422 | ||
7416 | /* check if major or compatible brand is 3GP */ | 7423 | /* check if major or compatible brand is 3GP */ |