gst/playback/: Make playbin async, it'll commit state to paused when all streams are detected.
Original commit message from CVS:
* gst/playback/Makefile.am:
* gst/playback/gstdecodebin.c: (gst_decode_bin_init),
(gst_decode_bin_dispose), (dynamic_create), (dynamic_free),
(free_dynamics), (pad_unblocked), (pad_blocked), (close_pad_link),
(try_to_link_1), (new_pad), (no_more_pads), (type_found),
(gst_decode_bin_change_state):
* gst/playback/gstplaybin.c: (gst_play_bin_class_init),
(gst_play_bin_send_event_to_sink):
* gst/playback/test5.c: (new_pad), (no_more_pads), (start_finding),
(dump_element_stats), (main):
* gst/playback/test6.c: (main):
Make playbin async, it'll commit state to paused when all streams
are detected.
Remove ugly hack.
Added test6.c to show async behaviour.
2005-10-18 17:13:56 +00:00
|
|
|
/* GStreamer
|
|
|
|
* Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <gst/gst.h>
|
|
|
|
|
2006-02-01 14:51:29 +00:00
|
|
|
static void
|
|
|
|
new_decoded_pad_cb (GstElement * decodebin, GstPad * new_pad, gboolean last,
|
|
|
|
GstElement * pipeline)
|
|
|
|
{
|
|
|
|
GstElement *fakesink;
|
|
|
|
GstPad *sinkpad;
|
|
|
|
|
|
|
|
fakesink = gst_element_factory_make ("fakesink", NULL);
|
|
|
|
gst_bin_add (GST_BIN (pipeline), fakesink);
|
|
|
|
|
|
|
|
sinkpad = gst_element_get_pad (fakesink, "sink");
|
|
|
|
if (GST_PAD_LINK_FAILED (gst_pad_link (new_pad, sinkpad))) {
|
|
|
|
g_warning ("Failed to link %s:%s to %s:%s", GST_DEBUG_PAD_NAME (new_pad),
|
|
|
|
GST_DEBUG_PAD_NAME (sinkpad));
|
|
|
|
gst_bin_remove (GST_BIN (pipeline), fakesink);
|
|
|
|
} else {
|
|
|
|
gst_element_set_state (fakesink, GST_STATE_PAUSED);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
show_error (const gchar * errmsg, GstBus * bus)
|
|
|
|
{
|
|
|
|
GstMessage *msg;
|
|
|
|
GError *err = NULL;
|
|
|
|
gchar *dbg = NULL;
|
|
|
|
|
|
|
|
msg = gst_bus_poll (bus, GST_MESSAGE_ERROR, 0);
|
|
|
|
if (msg) {
|
|
|
|
g_assert (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_ERROR);
|
|
|
|
|
|
|
|
gst_message_parse_error (msg, &err, &dbg);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_print ("ERROR: %s\n", errmsg);
|
|
|
|
g_print (" %s\n", (err) ? err->message : "");
|
|
|
|
if (dbg) {
|
|
|
|
g_print ("\ndebug: %s\n\n", dbg);
|
|
|
|
g_free (dbg);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (err)
|
|
|
|
g_error_free (err);
|
|
|
|
}
|
|
|
|
|
gst/playback/: Make playbin async, it'll commit state to paused when all streams are detected.
Original commit message from CVS:
* gst/playback/Makefile.am:
* gst/playback/gstdecodebin.c: (gst_decode_bin_init),
(gst_decode_bin_dispose), (dynamic_create), (dynamic_free),
(free_dynamics), (pad_unblocked), (pad_blocked), (close_pad_link),
(try_to_link_1), (new_pad), (no_more_pads), (type_found),
(gst_decode_bin_change_state):
* gst/playback/gstplaybin.c: (gst_play_bin_class_init),
(gst_play_bin_send_event_to_sink):
* gst/playback/test5.c: (new_pad), (no_more_pads), (start_finding),
(dump_element_stats), (main):
* gst/playback/test6.c: (main):
Make playbin async, it'll commit state to paused when all streams
are detected.
Remove ugly hack.
Added test6.c to show async behaviour.
2005-10-18 17:13:56 +00:00
|
|
|
gint
|
|
|
|
main (gint argc, gchar * argv[])
|
|
|
|
{
|
|
|
|
GstElement *pipeline, *filesrc, *decodebin;
|
|
|
|
GstStateChangeReturn res;
|
|
|
|
GstIterator *it;
|
2006-02-01 14:51:29 +00:00
|
|
|
GstBus *bus;
|
gst/playback/: Make playbin async, it'll commit state to paused when all streams are detected.
Original commit message from CVS:
* gst/playback/Makefile.am:
* gst/playback/gstdecodebin.c: (gst_decode_bin_init),
(gst_decode_bin_dispose), (dynamic_create), (dynamic_free),
(free_dynamics), (pad_unblocked), (pad_blocked), (close_pad_link),
(try_to_link_1), (new_pad), (no_more_pads), (type_found),
(gst_decode_bin_change_state):
* gst/playback/gstplaybin.c: (gst_play_bin_class_init),
(gst_play_bin_send_event_to_sink):
* gst/playback/test5.c: (new_pad), (no_more_pads), (start_finding),
(dump_element_stats), (main):
* gst/playback/test6.c: (main):
Make playbin async, it'll commit state to paused when all streams
are detected.
Remove ugly hack.
Added test6.c to show async behaviour.
2005-10-18 17:13:56 +00:00
|
|
|
gpointer data;
|
|
|
|
|
|
|
|
gst_init (&argc, &argv);
|
|
|
|
|
|
|
|
pipeline = gst_pipeline_new ("pipeline");
|
|
|
|
|
|
|
|
filesrc = gst_element_factory_make ("filesrc", "filesrc");
|
|
|
|
g_assert (filesrc);
|
|
|
|
|
|
|
|
decodebin = gst_element_factory_make ("decodebin", "decodebin");
|
|
|
|
g_assert (decodebin);
|
|
|
|
|
|
|
|
gst_bin_add_many (GST_BIN (pipeline), filesrc, decodebin, NULL);
|
|
|
|
gst_element_link (filesrc, decodebin);
|
|
|
|
|
|
|
|
if (argc < 2) {
|
2006-02-01 14:51:29 +00:00
|
|
|
g_print ("usage: %s <filenames>\n", argv[0]);
|
gst/playback/: Make playbin async, it'll commit state to paused when all streams are detected.
Original commit message from CVS:
* gst/playback/Makefile.am:
* gst/playback/gstdecodebin.c: (gst_decode_bin_init),
(gst_decode_bin_dispose), (dynamic_create), (dynamic_free),
(free_dynamics), (pad_unblocked), (pad_blocked), (close_pad_link),
(try_to_link_1), (new_pad), (no_more_pads), (type_found),
(gst_decode_bin_change_state):
* gst/playback/gstplaybin.c: (gst_play_bin_class_init),
(gst_play_bin_send_event_to_sink):
* gst/playback/test5.c: (new_pad), (no_more_pads), (start_finding),
(dump_element_stats), (main):
* gst/playback/test6.c: (main):
Make playbin async, it'll commit state to paused when all streams
are detected.
Remove ugly hack.
Added test6.c to show async behaviour.
2005-10-18 17:13:56 +00:00
|
|
|
exit (-1);
|
|
|
|
}
|
2006-02-01 14:51:29 +00:00
|
|
|
|
|
|
|
if (!g_str_has_prefix (argv[1], "file://")) {
|
|
|
|
g_object_set (G_OBJECT (filesrc), "location", argv[1], NULL);
|
|
|
|
} else {
|
|
|
|
g_object_set (G_OBJECT (filesrc), "location", argv[1] + 7, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* we've got to connect fakesinks to newly decoded pads to make sure
|
|
|
|
* buffers have actually been flowing over those pads and caps have
|
|
|
|
* been set on them. decodebin might insert internal queues and
|
|
|
|
* without fakesinks it's pot-luck what caps we get from the pad, because
|
|
|
|
* it depends on whether the queues have started pushing buffers yet or not.
|
|
|
|
* With fakesinks we make sure that the pipeline doesn't go to PAUSED state
|
|
|
|
* before each fakesink has a buffer queued. */
|
|
|
|
g_signal_connect (decodebin, "new-decoded-pad",
|
|
|
|
G_CALLBACK (new_decoded_pad_cb), pipeline);
|
|
|
|
|
|
|
|
bus = gst_element_get_bus (pipeline);
|
gst/playback/: Make playbin async, it'll commit state to paused when all streams are detected.
Original commit message from CVS:
* gst/playback/Makefile.am:
* gst/playback/gstdecodebin.c: (gst_decode_bin_init),
(gst_decode_bin_dispose), (dynamic_create), (dynamic_free),
(free_dynamics), (pad_unblocked), (pad_blocked), (close_pad_link),
(try_to_link_1), (new_pad), (no_more_pads), (type_found),
(gst_decode_bin_change_state):
* gst/playback/gstplaybin.c: (gst_play_bin_class_init),
(gst_play_bin_send_event_to_sink):
* gst/playback/test5.c: (new_pad), (no_more_pads), (start_finding),
(dump_element_stats), (main):
* gst/playback/test6.c: (main):
Make playbin async, it'll commit state to paused when all streams
are detected.
Remove ugly hack.
Added test6.c to show async behaviour.
2005-10-18 17:13:56 +00:00
|
|
|
|
|
|
|
g_print ("pause..\n");
|
|
|
|
res = gst_element_set_state (pipeline, GST_STATE_PAUSED);
|
|
|
|
if (res == GST_STATE_CHANGE_FAILURE) {
|
2006-02-01 14:51:29 +00:00
|
|
|
show_error ("Could not go to PAUSED state", bus);
|
gst/playback/: Make playbin async, it'll commit state to paused when all streams are detected.
Original commit message from CVS:
* gst/playback/Makefile.am:
* gst/playback/gstdecodebin.c: (gst_decode_bin_init),
(gst_decode_bin_dispose), (dynamic_create), (dynamic_free),
(free_dynamics), (pad_unblocked), (pad_blocked), (close_pad_link),
(try_to_link_1), (new_pad), (no_more_pads), (type_found),
(gst_decode_bin_change_state):
* gst/playback/gstplaybin.c: (gst_play_bin_class_init),
(gst_play_bin_send_event_to_sink):
* gst/playback/test5.c: (new_pad), (no_more_pads), (start_finding),
(dump_element_stats), (main):
* gst/playback/test6.c: (main):
Make playbin async, it'll commit state to paused when all streams
are detected.
Remove ugly hack.
Added test6.c to show async behaviour.
2005-10-18 17:13:56 +00:00
|
|
|
exit (-1);
|
|
|
|
}
|
|
|
|
g_print ("waiting..\n");
|
|
|
|
res = gst_element_get_state (pipeline, NULL, NULL, GST_CLOCK_TIME_NONE);
|
|
|
|
if (res != GST_STATE_CHANGE_SUCCESS) {
|
2006-02-01 14:51:29 +00:00
|
|
|
show_error ("Failed to complete state change to PAUSED", bus);
|
gst/playback/: Make playbin async, it'll commit state to paused when all streams are detected.
Original commit message from CVS:
* gst/playback/Makefile.am:
* gst/playback/gstdecodebin.c: (gst_decode_bin_init),
(gst_decode_bin_dispose), (dynamic_create), (dynamic_free),
(free_dynamics), (pad_unblocked), (pad_blocked), (close_pad_link),
(try_to_link_1), (new_pad), (no_more_pads), (type_found),
(gst_decode_bin_change_state):
* gst/playback/gstplaybin.c: (gst_play_bin_class_init),
(gst_play_bin_send_event_to_sink):
* gst/playback/test5.c: (new_pad), (no_more_pads), (start_finding),
(dump_element_stats), (main):
* gst/playback/test6.c: (main):
Make playbin async, it'll commit state to paused when all streams
are detected.
Remove ugly hack.
Added test6.c to show async behaviour.
2005-10-18 17:13:56 +00:00
|
|
|
exit (-1);
|
|
|
|
}
|
|
|
|
g_print ("stats..\n");
|
|
|
|
|
|
|
|
it = gst_element_iterate_src_pads (decodebin);
|
|
|
|
while (gst_iterator_next (it, &data) == GST_ITERATOR_OK) {
|
|
|
|
GstPad *pad = GST_PAD (data);
|
|
|
|
GstCaps *caps;
|
|
|
|
gchar *str;
|
|
|
|
GstQuery *query;
|
|
|
|
|
|
|
|
g_print ("stream %s:\n", GST_OBJECT_NAME (pad));
|
|
|
|
|
|
|
|
caps = gst_pad_get_caps (pad);
|
|
|
|
str = gst_caps_to_string (caps);
|
|
|
|
g_print (" caps: %s\n", str);
|
|
|
|
g_free (str);
|
|
|
|
|
2005-10-20 17:42:57 +00:00
|
|
|
query = gst_query_new_duration (GST_FORMAT_TIME);
|
gst/playback/: Make playbin async, it'll commit state to paused when all streams are detected.
Original commit message from CVS:
* gst/playback/Makefile.am:
* gst/playback/gstdecodebin.c: (gst_decode_bin_init),
(gst_decode_bin_dispose), (dynamic_create), (dynamic_free),
(free_dynamics), (pad_unblocked), (pad_blocked), (close_pad_link),
(try_to_link_1), (new_pad), (no_more_pads), (type_found),
(gst_decode_bin_change_state):
* gst/playback/gstplaybin.c: (gst_play_bin_class_init),
(gst_play_bin_send_event_to_sink):
* gst/playback/test5.c: (new_pad), (no_more_pads), (start_finding),
(dump_element_stats), (main):
* gst/playback/test6.c: (main):
Make playbin async, it'll commit state to paused when all streams
are detected.
Remove ugly hack.
Added test6.c to show async behaviour.
2005-10-18 17:13:56 +00:00
|
|
|
if (gst_pad_query (pad, query)) {
|
|
|
|
gint64 duration;
|
|
|
|
|
Query API update.
Original commit message from CVS:
* examples/seeking/seek.c: (make_avi_msmpeg4v3_mp3_pipeline),
(query_positions_elems), (query_positions_pads), (update_scale),
(do_seek), (set_update_scale), (message_received), (main):
* ext/ogg/gstoggdemux.c: (gst_ogg_pad_src_query),
(gst_ogg_demux_perform_seek), (gst_ogg_demux_find_chains),
(gst_ogg_demux_loop):
* ext/ogg/gstogmparse.c: (gst_ogm_parse_sink_query):
* ext/theora/theoradec.c: (theora_dec_src_query),
(theora_dec_sink_event):
* ext/vorbis/vorbisdec.c: (vorbis_dec_src_query),
(vorbis_dec_sink_event), (vorbis_handle_data_packet):
* gst/adder/gstadder.c: (gst_adder_query):
* gst/audiotestsrc/gstaudiotestsrc.c: (gst_audiotestsrc_src_query):
* gst/playback/test3.c: (update_scale):
* gst/playback/test5.c: (new_pad), (no_more_pads), (start_finding),
(dump_element_stats), (main):
* gst/playback/test6.c: (main):
* gst/sine/gstsinesrc.c: (gst_sinesrc_src_query):
Query API update.
2005-10-19 15:55:33 +00:00
|
|
|
gst_query_parse_duration (query, NULL, &duration);
|
gst/playback/: Make playbin async, it'll commit state to paused when all streams are detected.
Original commit message from CVS:
* gst/playback/Makefile.am:
* gst/playback/gstdecodebin.c: (gst_decode_bin_init),
(gst_decode_bin_dispose), (dynamic_create), (dynamic_free),
(free_dynamics), (pad_unblocked), (pad_blocked), (close_pad_link),
(try_to_link_1), (new_pad), (no_more_pads), (type_found),
(gst_decode_bin_change_state):
* gst/playback/gstplaybin.c: (gst_play_bin_class_init),
(gst_play_bin_send_event_to_sink):
* gst/playback/test5.c: (new_pad), (no_more_pads), (start_finding),
(dump_element_stats), (main):
* gst/playback/test6.c: (main):
Make playbin async, it'll commit state to paused when all streams
are detected.
Remove ugly hack.
Added test6.c to show async behaviour.
2005-10-18 17:13:56 +00:00
|
|
|
|
|
|
|
g_print (" duration: %" GST_TIME_FORMAT "\n", GST_TIME_ARGS (duration));
|
|
|
|
}
|
|
|
|
gst_query_unref (query);
|
|
|
|
|
|
|
|
gst_object_unref (pad);
|
|
|
|
}
|
|
|
|
gst_iterator_free (it);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|