docs/design/draft-keyframe-force.txt: Fix typo.

Original commit message from CVS:
* docs/design/draft-keyframe-force.txt:
Fix typo.
* gst/playback/gstqueue2.c: (update_buffering),
(gst_queue_handle_src_query):
Set buffering mode in the messages.
Set buffering percent in the query.
* tests/examples/seek/seek.c: (update_fill), (msg_state_changed),
(do_stream_buffering), (do_download_buffering), (msg_buffering):
Do some more fancy things based on the buffering method in use.
This commit is contained in:
Wim Taymans 2008-04-11 01:25:01 +00:00
parent ab83d90639
commit f0738f6fd3
4 changed files with 99 additions and 18 deletions

View file

@ -1,3 +1,17 @@
2008-04-11 Wim Taymans <wim.taymans@collabora.co.uk>
* docs/design/draft-keyframe-force.txt:
Fix typo.
* gst/playback/gstqueue2.c: (update_buffering),
(gst_queue_handle_src_query):
Set buffering mode in the messages.
Set buffering percent in the query.
* tests/examples/seek/seek.c: (update_fill), (msg_state_changed),
(do_stream_buffering), (do_download_buffering), (msg_buffering):
Do some more fancy things based on the buffering method in use.
2008-04-09 Wim Taymans <wim.taymans@collabora.co.uk> 2008-04-09 Wim Taymans <wim.taymans@collabora.co.uk>
* tests/examples/seek/seek.c: (update_fill), (set_update_fill), * tests/examples/seek/seek.c: (update_fill), (set_update_fill),

View file

@ -4,7 +4,7 @@ Forcing keyframes
Consider the following use case: Consider the following use case:
We have a pipeline that performs video and audio capture from a live source, We have a pipeline that performs video and audio capture from a live source,
compesses and muxes the streams and writes the resulting data into a file. compresses and muxes the streams and writes the resulting data into a file.
Inside the uncompressed video data we have a specific pattern inserted at Inside the uncompressed video data we have a specific pattern inserted at
specific moments that should trigger a switch to a new file, meaning, we close specific moments that should trigger a switch to a new file, meaning, we close

View file

@ -690,6 +690,7 @@ update_buffering (GstQueue * queue)
} }
if (post) { if (post) {
GstMessage *message; GstMessage *message;
GstBufferingMode mode;
/* scale to high percent so that it becomes the 100% mark */ /* scale to high percent so that it becomes the 100% mark */
percent = percent * 100 / queue->high_percent; percent = percent * 100 / queue->high_percent;
@ -697,9 +698,14 @@ update_buffering (GstQueue * queue)
if (percent > 100) if (percent > 100)
percent = 100; percent = 100;
if (QUEUE_IS_USING_TEMP_FILE (queue))
mode = GST_BUFFERING_DOWNLOAD;
else
mode = GST_BUFFERING_STREAM;
GST_DEBUG_OBJECT (queue, "buffering %d percent", percent); GST_DEBUG_OBJECT (queue, "buffering %d percent", percent);
message = 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, gst_message_set_buffering_stats (message, mode,
queue->byte_in_rate, queue->byte_out_rate, -1); queue->byte_in_rate, queue->byte_out_rate, -1);
gst_element_post_message (GST_ELEMENT_CAST (queue), message); gst_element_post_message (GST_ELEMENT_CAST (queue), message);
@ -1685,6 +1691,7 @@ gst_queue_handle_src_query (GstPad * pad, GstQuery * query)
stop = -1; stop = -1;
break; break;
} }
gst_query_set_buffering_percent (query, queue->is_buffering, 100);
gst_query_set_buffering_range (query, format, start, stop, -1); gst_query_set_buffering_range (query, format, start, stop, -1);
} }
break; break;

View file

@ -20,9 +20,6 @@
* Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA. * Boston, MA 02111-1307, USA.
*/ */
/* FIXME: remove #if 0 code
*
*/
#include <stdlib.h> #include <stdlib.h>
#include <glib.h> #include <glib.h>
#include <gtk/gtk.h> #include <gtk/gtk.h>
@ -84,6 +81,8 @@ static gboolean verbose = FALSE;
static gboolean is_live = FALSE; static gboolean is_live = FALSE;
static gboolean buffering = FALSE; static gboolean buffering = FALSE;
static GstBufferingMode mode;
static gint64 buffering_left;
static GstState state = GST_STATE_NULL; static GstState state = GST_STATE_NULL;
static guint update_id = 0; static guint update_id = 0;
static guint seek_timeout_id = 0; static guint seek_timeout_id = 0;
@ -1100,6 +1099,23 @@ update_fill (gpointer data)
gint64 start, stop; gint64 start, stop;
GstFormat format; GstFormat format;
gdouble fill; gdouble fill;
gboolean busy;
gint percent;
gst_query_parse_buffering_percent (query, &busy, &percent);
if (buffering && !busy) {
/* if we were buffering but not anymore, start playing */
if (state == GST_STATE_PLAYING && !is_live) {
fprintf (stderr, "setting pipeline to PLAYING ...\n");
gst_element_set_state (pipeline, GST_STATE_PLAYING);
gtk_statusbar_pop (GTK_STATUSBAR (statusbar), status_id);
gtk_statusbar_push (GTK_STATUSBAR (statusbar), status_id,
"Playing");
}
state = GST_STATE_PAUSED;
buffering = FALSE;
}
gst_query_parse_buffering_range (query, &format, &start, &stop, NULL); gst_query_parse_buffering_range (query, &format, &start, &stop, NULL);
@ -1915,7 +1931,6 @@ msg_state_changed (GstBus * bus, GstMessage * message, GstPipeline * pipeline)
/* When state of the pipeline changes to paused or playing we start updating scale */ /* When state of the pipeline changes to paused or playing we start updating scale */
if (new == GST_STATE_PLAYING) { if (new == GST_STATE_PLAYING) {
set_update_scale (TRUE); set_update_scale (TRUE);
set_update_fill (TRUE);
} else { } else {
set_update_scale (FALSE); set_update_scale (FALSE);
} }
@ -1952,30 +1967,28 @@ msg_segment_done (GstBus * bus, GstMessage * message, GstPipeline * pipeline)
g_print ("segment seek failed\n"); g_print ("segment seek failed\n");
} }
/* in stream buffering mode we PAUSE the pipeline until we receive a 100%
* message */
static void static void
msg_buffering (GstBus * bus, GstMessage * message, GstPipeline * data) do_stream_buffering (gint percent)
{ {
gint percent;
gchar *bufstr; gchar *bufstr;
gst_message_parse_buffering (message, &percent);
gtk_statusbar_pop (GTK_STATUSBAR (statusbar), status_id); gtk_statusbar_pop (GTK_STATUSBAR (statusbar), status_id);
bufstr = g_strdup_printf ("Buffering...%d", percent); bufstr = g_strdup_printf ("Buffering...%d", percent);
gtk_statusbar_push (GTK_STATUSBAR (statusbar), status_id, bufstr); gtk_statusbar_push (GTK_STATUSBAR (statusbar), status_id, bufstr);
g_free (bufstr); g_free (bufstr);
/* no state management needed for live pipelines */
if (is_live)
return;
if (percent == 100) { if (percent == 100) {
/* a 100% message means buffering is done */ /* a 100% message means buffering is done */
buffering = FALSE; buffering = FALSE;
/* if the desired state is playing, go back */ /* if the desired state is playing, go back */
if (state == GST_STATE_PLAYING) { if (state == GST_STATE_PLAYING) {
fprintf (stderr, "Done buffering, setting pipeline to PLAYING ...\n"); /* no state management needed for live pipelines */
gst_element_set_state (pipeline, GST_STATE_PLAYING); if (!is_live) {
fprintf (stderr, "Done buffering, setting pipeline to PLAYING ...\n");
gst_element_set_state (pipeline, GST_STATE_PLAYING);
}
gtk_statusbar_pop (GTK_STATUSBAR (statusbar), status_id); gtk_statusbar_pop (GTK_STATUSBAR (statusbar), status_id);
gtk_statusbar_push (GTK_STATUSBAR (statusbar), status_id, "Playing"); gtk_statusbar_push (GTK_STATUSBAR (statusbar), status_id, "Playing");
} }
@ -1983,13 +1996,60 @@ msg_buffering (GstBus * bus, GstMessage * message, GstPipeline * data)
/* buffering busy */ /* buffering busy */
if (buffering == FALSE && state == GST_STATE_PLAYING) { if (buffering == FALSE && state == GST_STATE_PLAYING) {
/* we were not buffering but PLAYING, PAUSE the pipeline. */ /* we were not buffering but PLAYING, PAUSE the pipeline. */
fprintf (stderr, "Buffering, setting pipeline to PAUSED ...\n"); if (!is_live) {
gst_element_set_state (pipeline, GST_STATE_PAUSED); fprintf (stderr, "Buffering, setting pipeline to PAUSED ...\n");
gst_element_set_state (pipeline, GST_STATE_PAUSED);
}
} }
buffering = TRUE; buffering = TRUE;
} }
} }
static void
do_download_buffering (gint percent)
{
if (!buffering && percent < 100) {
gchar *bufstr;
buffering = TRUE;
bufstr = g_strdup_printf ("Downloading...");
gtk_statusbar_push (GTK_STATUSBAR (statusbar), status_id, bufstr);
g_free (bufstr);
/* once we get a buffering message, we'll do the fill update */
set_update_fill (TRUE);
if (state == GST_STATE_PLAYING && !is_live) {
fprintf (stderr, "Downloading, setting pipeline to PAUSED ...\n");
gst_element_set_state (pipeline, GST_STATE_PAUSED);
}
}
}
static void
msg_buffering (GstBus * bus, GstMessage * message, GstPipeline * data)
{
gint percent;
gst_message_parse_buffering (message, &percent);
/* get more stats */
gst_message_parse_buffering_stats (message, &mode, NULL, NULL,
&buffering_left);
switch (mode) {
case GST_BUFFERING_DOWNLOAD:
do_download_buffering (percent);
break;
case GST_BUFFERING_LIVE:
case GST_BUFFERING_TIMESHIFT:
case GST_BUFFERING_STREAM:
do_stream_buffering (percent);
break;
}
}
static void static void
connect_bus_signals (GstElement * pipeline) connect_bus_signals (GstElement * pipeline)
{ {