mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-08 10:31:05 +00:00
50e2f24b44
Original commit message from CVS: * gst/playback/README: * gst/playback/gstdecodebin.c: (gst_decode_bin_class_init), (compare_ranks), (print_feature), (gst_decode_bin_init), (dynamic_create), (dynamic_free), (find_compatibles), (mimetype_is_raw), (close_pad_link), (got_redirect), (try_to_link_1), (get_our_ghost_pad), (remove_element_chain), (new_pad), (no_more_pads), (unlinked), (close_link), (type_found), (gst_decode_bin_change_state): * gst/playback/gstplaybasebin.c: (gst_play_base_bin_class_init), (gst_play_base_bin_init), (group_destroy), (group_commit), (check_queue), (queue_overrun), (queue_threshold_reached), (queue_out_of_data), (gen_preroll_element), (unknown_type), (new_decoded_pad), (setup_subtitle), (gen_source_element), (got_redirect), (setup_source), (play_base_eos), (gst_play_base_bin_change_state), (gst_play_base_bin_add_element), (gst_play_base_bin_remove_element): * gst/playback/gstplaybasebin.h: * gst/playback/gstplaybin.c: (gst_play_bin_class_init), (gst_play_bin_init), (gst_play_bin_dispose), (gst_play_bin_set_property), (gen_video_element), (gen_text_element), (gen_audio_element), (remove_sinks), (gst_play_bin_send_event): * gst/playback/gststreaminfo.c: (gst_stream_info_dispose), (stream_info_change_state), (gst_stream_info_set_mute): * gst/playback/gststreamselector.c: (gst_stream_selector_init), (gst_stream_selector_get_caps), (gst_stream_selector_setcaps), (gst_stream_selector_request_new_pad), (gst_stream_selector_event), (gst_stream_selector_chain): * gst/playback/test.c: (gen_video_element), (gen_audio_element), (main): * sys/xvimage/xvimagesink.c: (gst_xvimagesink_getcaps), (gst_xvimagesink_setcaps), (gst_xvimagesink_get_times), (gst_xvimagesink_show_frame), (gst_xvimagesink_chain), (gst_xvimagesink_buffer_alloc), (gst_xvimagesink_class_init): Raw and crude port of decodebin. Make playbin compile.
136 lines
3.7 KiB
C
136 lines
3.7 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.
|
|
*/
|
|
#ifdef HAVE_CONFIG_H
|
|
#include "config.h"
|
|
#endif
|
|
#include <gst/gst.h>
|
|
|
|
static GstElement *
|
|
gen_video_element ()
|
|
{
|
|
GstElement *element;
|
|
GstElement *conv;
|
|
GstElement *sink;
|
|
|
|
element = gst_bin_new ("vbin");
|
|
conv = gst_element_factory_make ("ffmpegcolorspace", "conv");
|
|
sink = gst_element_factory_make (DEFAULT_VIDEOSINK, "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_bin_new ("abin");
|
|
conv = gst_element_factory_make ("audioconvert", "conv");
|
|
sink = gst_element_factory_make (DEFAULT_AUDIOSINK, "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;
|
|
}
|