gstreamer/gst/playback/test.c
Wim Taymans d23e3dea3f gst/playback/: More playbin fixes. Added README. Do better element filtering.
Original commit message from CVS:
* gst/playback/Makefile.am:
* gst/playback/README:
* gst/playback/gstdecodebin.c: (gst_decode_bin_get_type),
(gst_decode_bin_class_init), (gst_decode_bin_factory_filter),
(compare_ranks), (print_feature), (gst_decode_bin_init),
(gst_decode_bin_dispose), (find_compatibles), (close_pad_link),
(try_to_link_1), (new_pad), (close_link), (type_found),
(gst_decode_bin_set_property), (gst_decode_bin_get_property),
(plugin_init):
* gst/playback/gstplaybasebin.c: (gst_play_base_bin_get_type),
(gst_play_base_bin_class_init), (gst_play_base_bin_init),
(gst_play_base_bin_dispose), (rebuild_pipeline), (queue_overrun),
(gen_preroll_element), (no_more_pads), (new_stream),
(setup_source), (gst_play_base_bin_set_property),
(gst_play_base_bin_get_property), (gst_play_base_bin_change_state),
(gst_play_base_bin_add_element),
(gst_play_base_bin_remove_element),
(gst_play_base_bin_mute_stream), (gst_play_base_bin_link_stream),
(gst_play_base_bin_unlink_stream),
(gst_play_base_bin_get_streaminfo):
* gst/playback/gstplaybasebin.h:
* gst/playback/gstplaybin.c: (gst_play_bin_get_type),
(gst_play_bin_class_init), (gst_play_bin_init),
(gst_play_bin_dispose), (gst_play_bin_set_property),
(gst_play_bin_get_property), (gen_video_element),
(gen_audio_element), (setup_sinks), (gst_play_bin_change_state),
(gst_play_bin_get_event_masks), (gst_play_bin_send_event),
(gst_play_bin_get_formats), (gst_play_bin_convert),
(gst_play_bin_get_query_types), (gst_play_bin_query),
(plugin_init):
* gst/playback/gststreaminfo.c: (gst_stream_type_get_type),
(gst_stream_info_get_type), (gst_stream_info_class_init),
(gst_stream_info_init), (gst_stream_info_new),
(gst_stream_info_dispose), (gst_stream_info_set_property),
(gst_stream_info_get_property):
* gst/playback/gststreaminfo.h:
* gst/playback/test.c: (gen_video_element), (gen_audio_element),
(main):
* gst/playback/test2.c: (main):
* gst/playback/test3.c: (update_scale), (main):
More playbin fixes. Added README. Do better element filtering.
Added base class to preroll media. Added test apps.
2004-07-07 16:53:55 +00:00

134 lines
3.6 KiB
C

/* 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 <gst/gst.h>
static GstElement *
gen_video_element ()
{
GstElement *element;
GstElement *conv;
GstElement *sink;
element = gst_thread_new ("vbin");
conv = gst_element_factory_make ("ffmpegcolorspace", "conv");
sink = gst_element_factory_make ("ximagesink", "sink");
gst_bin_add (GST_BIN (element), conv);
gst_bin_add (GST_BIN (element), sink);
gst_element_link_pads (conv, "src", sink, "sink");
gst_element_add_ghost_pad (element, gst_element_get_pad (conv, "sink"),
"sink");
return element;
}
static GstElement *
gen_audio_element ()
{
GstElement *element;
GstElement *conv;
GstElement *sink;
element = gst_thread_new ("abin");
conv = gst_element_factory_make ("audioconvert", "conv");
sink = gst_element_factory_make ("osssink", "sink");
gst_bin_add (GST_BIN (element), conv);
gst_bin_add (GST_BIN (element), sink);
gst_element_link_pads (conv, "src", sink, "sink");
gst_element_add_ghost_pad (element,
gst_element_get_pad (conv, "sink"), "sink");
return element;
}
gint
main (gint argc, gchar * argv[])
{
GstElement *player;
GstElementStateReturn res;
gint streams;
GList *streaminfo;
GList *s;
gst_init (&argc, &argv);
player = gst_element_factory_make ("playbin", "player");
g_assert (player);
g_object_set (G_OBJECT (player), "uri", argv[1], NULL);
res = gst_element_set_state (player, GST_STATE_PAUSED);
if (res != GST_STATE_SUCCESS) {
g_print ("could not pause\n");
return -1;
}
/* get info about the stream */
g_print ("stream info:\n");
g_object_get (G_OBJECT (player), "nstreams", &streams, NULL);
g_print (" number of streams: %d\n", streams);
g_object_get (G_OBJECT (player), "stream-info", &streaminfo, NULL);
for (s = streaminfo; s; s = g_list_next (s)) {
GObject *obj = G_OBJECT (s->data);
int type;
GstPad *srcpad, *sinkpad;
GstElement *sink;
gboolean res;
g_object_get (obj, "type", &type, NULL);
g_print (" type: %d\n", type);
g_object_get (obj, "pad", &srcpad, NULL);
g_print (" pad: %p\n", srcpad);
if (type == 1) {
sink = gen_audio_element ();
} else if (type == 2) {
sink = gen_video_element ();
} else {
g_warning ("unknown stream found");
continue;
}
gst_bin_add (GST_BIN (player), sink);
sinkpad = gst_element_get_pad (sink, "sink");
res = gst_pad_link (srcpad, sinkpad);
if (!res) {
gchar *capsstr;
capsstr = gst_caps_to_string (gst_pad_get_caps (srcpad));
g_warning ("could not link %s", capsstr);
g_free (capsstr);
}
//g_signal_emit_by_name (G_OBJECT (player), "link_stream", obj, sinkpad);
}
/* set effects sinks */
res = gst_element_set_state (player, GST_STATE_PLAYING);
if (res != GST_STATE_SUCCESS) {
g_print ("could not play\n");
return -1;
}
gst_main ();
return 0;
}