From: <wt...@ke...> - 2008-04-09 21:41:12
|
CVS Root: /cvs/gstreamer Module: gst-plugins-base Changes by: wtay Date: Wed Apr 09 2008 21:40:31 UTC Log message: * gst/playback/gstqueue2.c: (update_buffering), (gst_queue_close_temp_location_file), (gst_queue_handle_src_query), (gst_queue_src_checkgetrange_function): Include extra buffering stats in the buffering message. Implement BUFFERING query. * gst/playback/gsturidecodebin.c: (do_async_start), (do_async_done), (type_found), (setup_streaming), (setup_source), (gst_uri_decode_bin_change_state): Only add decodebin2 when the type is found in streaming mode. Make uridecodebin async to PAUSED even when we don't have decodebin2 added yet. Modified files: . : ChangeLog gst/playback : gstqueue2.c gsturidecodebin.c Links: http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-base/ChangeLog.diff?r1=1.3858&r2=1.3859 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-base/gst/playback/gstqueue2.c.diff?r1=1.26&r2=1.27 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-base/gst/playback/gsturidecodebin.c.diff?r1=1.14&r2=1.15 ====Begin Diffs==== Index: ChangeLog =================================================================== RCS file: /cvs/gstreamer/gst-plugins-base/ChangeLog,v retrieving revision 1.3858 retrieving revision 1.3859 diff -u -d -r1.3858 -r1.3859 --- ChangeLog 9 Apr 2008 08:38:15 -0000 1.3858 +++ ChangeLog 9 Apr 2008 21:40:16 -0000 1.3859 @@ -1,3 +1,18 @@ +2008-04-09 Wim Taymans <wim...@co...> + + * gst/playback/gstqueue2.c: (update_buffering), + (gst_queue_close_temp_location_file), (gst_queue_handle_src_query), + (gst_queue_src_checkgetrange_function): + Include extra buffering stats in the buffering message. + Implement BUFFERING query. + * gst/playback/gsturidecodebin.c: (do_async_start), + (do_async_done), (type_found), (setup_streaming), (setup_source), + (gst_uri_decode_bin_change_state): + Only add decodebin2 when the type is found in streaming mode. + Make uridecodebin async to PAUSED even when we don't have decodebin2 + added yet. 2008-04-09 Sebastian Dröge <sl...@ci...> * ext/gio/gstgio.c: (gst_gio_get_supported_protocols): Index: gstqueue2.c RCS file: /cvs/gstreamer/gst-plugins-base/gst/playback/gstqueue2.c,v retrieving revision 1.26 retrieving revision 1.27 diff -u -d -r1.26 -r1.27 --- gstqueue2.c 2 Apr 2008 11:08:05 -0000 1.26 +++ gstqueue2.c 9 Apr 2008 21:40:17 -0000 1.27 @@ -689,6 +689,8 @@ } } if (post) { + GstMessage *message; /* scale to high percent so that it becomes the 100% mark */ percent = percent * 100 / queue->high_percent; /* clip */ @@ -696,8 +698,12 @@ percent = 100; GST_DEBUG_OBJECT (queue, "buffering %d percent", percent); - gst_element_post_message (GST_ELEMENT_CAST (queue), - gst_message_new_buffering (GST_OBJECT_CAST (queue), percent)); + message = gst_message_new_buffering (GST_OBJECT_CAST (queue), percent); + gst_message_set_buffering_stats (message, GST_BUFFERING_STREAM, + queue->byte_in_rate, queue->byte_out_rate, -1); + gst_element_post_message (GST_ELEMENT_CAST (queue), message); } else { GST_DEBUG_OBJECT (queue, "filled %d percent", percent); @@ -994,6 +1000,7 @@ /* nothing to do */ if (queue->temp_file == NULL) return; GST_DEBUG_OBJECT (queue, "closing temp file"); /* we don't remove the file so that the application can use it as a cache @@ -1630,6 +1637,58 @@ GST_DEBUG_OBJECT (queue, "peer query success"); break; + case GST_QUERY_BUFFERING: + { + GstFormat format; + GST_DEBUG_OBJECT (queue, "query buffering"); + if (!QUEUE_IS_USING_TEMP_FILE (queue)) { + /* no temp file, just forward to the peer */ + if (!gst_queue_peer_query (queue, queue->sinkpad, query)) + goto peer_failed; + GST_DEBUG_OBJECT (queue, "buffering forwarded to peer"); + } else { + gint64 start, stop; + gst_query_parse_buffering_range (query, &format, NULL, NULL, NULL); + switch (format) { + case GST_FORMAT_PERCENT: + { + gint64 duration; + GstFormat peer_fmt; + peer_fmt = GST_FORMAT_BYTES; + if (!gst_pad_query_peer_duration (queue->sinkpad, &peer_fmt, + &duration)) + goto peer_failed; + GST_DEBUG_OBJECT (queue, "duration %" G_GINT64_FORMAT ", writing %" + G_GINT64_FORMAT, duration, queue->writing_pos); + start = 0; + /* get our available data relative to the duration */ + if (duration != -1) + stop = GST_FORMAT_PERCENT_MAX * queue->writing_pos / duration; + else + stop = -1; + break; + } + case GST_FORMAT_BYTES: + stop = queue->writing_pos; + default: + start = -1; + stop = -1; + } + gst_query_set_buffering_range (query, format, start, stop, -1); + } + break; + } default: /* peer handled other queries */ if (!gst_queue_peer_query (queue, queue->sinkpad, query)) @@ -1684,8 +1743,10 @@ gboolean ret; queue = GST_QUEUE (gst_pad_get_parent (pad)); /* we can operate in pull mode when we are using a tempfile */ ret = QUEUE_IS_USING_TEMP_FILE (queue); gst_object_unref (GST_OBJECT (queue)); return ret; Index: gsturidecodebin.c RCS file: /cvs/gstreamer/gst-plugins-base/gst/playback/gsturidecodebin.c,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -r1.14 -r1.15 --- gsturidecodebin.c 3 Apr 2008 12:16:04 -0000 1.14 +++ gsturidecodebin.c 9 Apr 2008 21:40:17 -0000 1.15 @@ -81,6 +81,8 @@ guint src_np_sig_id; /* new-pad signal id */ guint src_nmp_sig_id; /* no-more-pads signal id */ gint pending; + gboolean async_pending; /* async-start has been emited */ }; struct _GstURIDecodeBinClass @@ -502,6 +504,30 @@ } +static void +do_async_start (GstURIDecodeBin * dbin) +{ + GstMessage *message; + dbin->async_pending = TRUE; + message = gst_message_new_async_start (GST_OBJECT_CAST (dbin), FALSE); + parent_class->handle_message (GST_BIN_CAST (dbin), message); +} +do_async_done (GstURIDecodeBin * dbin) + if (dbin->async_pending) { + message = gst_message_new_async_done (GST_OBJECT_CAST (dbin)); + parent_class->handle_message (GST_BIN_CAST (dbin), message); + dbin->async_pending = FALSE; + } #define DEFAULT_QUEUE_SIZE (3 * GST_SECOND) #define DEFAULT_QUEUE_MIN_THRESHOLD ((DEFAULT_QUEUE_SIZE * 30) / 100) #define DEFAULT_QUEUE_THRESHOLD ((DEFAULT_QUEUE_SIZE * 95) / 100) @@ -1060,7 +1086,7 @@ GST_DEBUG_OBJECT (decoder, "typefind found caps %" GST_PTR_FORMAT, caps); - dec_elem = g_object_get_data (G_OBJECT (typefind), "decodebin2"); + dec_elem = make_decoder (decoder); if (!dec_elem) goto no_decodebin; @@ -1081,8 +1107,10 @@ if (!gst_element_link (queue, dec_elem)) goto could_not_link; - gst_element_set_state (queue, GST_STATE_PLAYING); gst_element_set_state (dec_elem, GST_STATE_PLAYING); + gst_element_set_state (queue, GST_STATE_PLAYING); + do_async_done (decoder); return; @@ -1110,7 +1138,7 @@ * source. After we find the type, we decide to plug a queue2 and continue to * plug a decodebin2 starting from the found caps */ static gboolean -setup_streaming (GstURIDecodeBin * decoder, GstElement * dec_elem) +setup_streaming (GstURIDecodeBin * decoder) { GstElement *typefind; @@ -1132,7 +1160,7 @@ g_signal_connect (G_OBJECT (decoder->typefind), "have-type", G_CALLBACK (type_found), decoder); - g_object_set_data (G_OBJECT (typefind), "decodebin2", dec_elem); + do_async_start (decoder); return TRUE; @@ -1284,21 +1312,21 @@ g_object_set_data (G_OBJECT (decoder->source), "pending", "1"); decoder->pending++; - GstElement *dec_elem; - - dec_elem = make_decoder (decoder); - if (!dec_elem) - goto no_decoder; if (decoder->is_stream) { GST_DEBUG_OBJECT (decoder, "Setting up streaming"); /* do the stream things here */ - if (!setup_streaming (decoder, dec_elem)) + if (!setup_streaming (decoder)) goto streaming_failed; } else { + GstElement *dec_elem; /* no streaming source, we can link now */ GST_DEBUG_OBJECT (decoder, "Plugging decodebin to source"); + dec_elem = make_decoder (decoder); + if (!dec_elem) + goto no_decoder; if (!gst_element_link (decoder->source, dec_elem)) goto could_not_link; @@ -1732,6 +1760,7 @@ remove_decoders (decoder); remove_pads (decoder); remove_source (decoder); + do_async_done (decoder); |