mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-25 11:11:08 +00:00
ec7afb6f84
Original commit message from CVS: * ext/alsa/gstalsamixertrack.c: (gst_alsa_mixer_track_get_type): * ext/alsa/gstalsasink.c: (set_hwparams): * ext/alsa/gstalsasrc.c: (set_hwparams): * ext/gio/gstgio.c: (gst_gio_uri_handler_get_uri): * ext/ogg/gstoggmux.h: * ext/ogg/gstogmparse.c: * gst-libs/gst/audio/audio.c: * gst-libs/gst/fft/kiss_fft_f64.c: (kiss_fft_f64_alloc): * gst-libs/gst/pbutils/missing-plugins.c: (gst_missing_uri_sink_message_new), (gst_missing_element_message_new), (gst_missing_decoder_message_new), (gst_missing_encoder_message_new): * gst-libs/gst/rtp/gstbasertppayload.c: * gst-libs/gst/rtp/gstrtcpbuffer.c: (gst_rtcp_packet_bye_get_reason): * gst/audioconvert/gstaudioconvert.c: * gst/audioresample/gstaudioresample.c: * gst/ffmpegcolorspace/imgconvert.c: * gst/playback/test.c: (gen_video_element), (gen_audio_element): * gst/typefind/gsttypefindfunctions.c: * gst/videoscale/vs_4tap.c: * gst/videoscale/vs_4tap.h: * sys/v4l/gstv4lelement.c: * sys/v4l/gstv4lsrc.c: (gst_v4lsrc_get_any_caps): * sys/v4l/v4l_calls.c: * sys/v4l/v4lsrc_calls.c: (gst_v4lsrc_capture_init), (gst_v4lsrc_try_capture): * sys/ximage/ximagesink.c: (gst_ximagesink_check_xshm_calls), (gst_ximagesink_ximage_new): * sys/xvimage/xvimagesink.c: (gst_xvimagesink_check_xshm_calls), (gst_xvimagesink_xvimage_new): * tests/check/elements/audioconvert.c: * tests/check/elements/audioresample.c: (fail_unless_perfect_stream): * tests/check/elements/audiotestsrc.c: (setup_audiotestsrc): * tests/check/elements/decodebin.c: * tests/check/elements/gdpdepay.c: (setup_gdpdepay), (setup_gdpdepay_streamheader): * tests/check/elements/gdppay.c: (setup_gdppay), (GST_START_TEST), (setup_gdppay_streamheader): * tests/check/elements/gnomevfssink.c: (setup_gnomevfssink): * tests/check/elements/multifdsink.c: (setup_multifdsink): * tests/check/elements/textoverlay.c: * tests/check/elements/videorate.c: (setup_videorate): * tests/check/elements/videotestsrc.c: (setup_videotestsrc): * tests/check/elements/volume.c: (setup_volume): * tests/check/elements/vorbisdec.c: (setup_vorbisdec): * tests/check/elements/vorbistag.c: * tests/check/generic/clock-selection.c: * tests/check/generic/states.c: (setup), (teardown): * tests/check/libs/cddabasesrc.c: * tests/check/libs/video.c: * tests/check/pipelines/gio.c: * tests/check/pipelines/oggmux.c: * tests/check/pipelines/simple-launch-lines.c: (simple_launch_lines_suite): * tests/check/pipelines/streamheader.c: * tests/check/pipelines/theoraenc.c: * tests/check/pipelines/vorbisdec.c: * tests/check/pipelines/vorbisenc.c: * tests/examples/seek/scrubby.c: * tests/examples/seek/seek.c: (query_positions_elems), (query_positions_pads): * tests/icles/stress-xoverlay.c: (myclock): Correct all relevant warnings found by the sparse semantic code analyzer. This include marking several symbols static, using NULL instead of 0 for pointers and using "foo (void)" instead of "foo ()" for declarations. * win32/common/libgstrtp.def: Add gst_rtp_buffer_set_extension_data to the symbol definition file.
193 lines
5 KiB
C
193 lines
5 KiB
C
/* GStreamer
|
|
* Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
|
|
* Copyright (C) <2007> Wim Taymans <wim.taymans@gmail.com>
|
|
*
|
|
* 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>
|
|
|
|
#include <stdlib.h>
|
|
|
|
static GMainLoop *loop;
|
|
|
|
static GstElement *
|
|
gen_video_element (void)
|
|
{
|
|
GstElement *element;
|
|
GstElement *conv;
|
|
GstElement *sink;
|
|
GstPad *pad;
|
|
|
|
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");
|
|
|
|
pad = gst_element_get_pad (conv, "sink");
|
|
gst_element_add_pad (element, gst_ghost_pad_new ("sink", pad));
|
|
gst_object_unref (pad);
|
|
|
|
return element;
|
|
}
|
|
|
|
static GstElement *
|
|
gen_audio_element (void)
|
|
{
|
|
GstElement *element;
|
|
GstElement *conv;
|
|
GstElement *sink;
|
|
GstPad *pad;
|
|
|
|
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");
|
|
|
|
pad = gst_element_get_pad (conv, "sink");
|
|
gst_element_add_pad (element, gst_ghost_pad_new ("sink", pad));
|
|
gst_object_unref (pad);
|
|
|
|
return element;
|
|
}
|
|
|
|
static void
|
|
cb_newpad (GstElement * decodebin, GstPad * pad, gboolean last, gpointer data)
|
|
{
|
|
GstCaps *caps;
|
|
GstStructure *str;
|
|
GstPad *sinkpad;
|
|
GstElement *sink;
|
|
GstElement *pipeline;
|
|
const gchar *name;
|
|
GstStateChangeReturn ret;
|
|
GstPadLinkReturn lret;
|
|
|
|
/* check media type */
|
|
caps = gst_pad_get_caps (pad);
|
|
str = gst_caps_get_structure (caps, 0);
|
|
|
|
name = gst_structure_get_name (str);
|
|
g_print ("name: %s\n", name);
|
|
|
|
if (g_strrstr (name, "audio")) {
|
|
sink = gen_audio_element ();
|
|
} else if (g_strrstr (name, "video")) {
|
|
sink = gen_video_element ();
|
|
} else {
|
|
sink = NULL;
|
|
}
|
|
gst_caps_unref (caps);
|
|
|
|
if (sink) {
|
|
pipeline = GST_ELEMENT_CAST (data);
|
|
|
|
/* add new sink to the pipeline */
|
|
gst_bin_add (GST_BIN_CAST (pipeline), sink);
|
|
|
|
/* set the new sink tp PAUSED as well */
|
|
ret = gst_element_set_state (sink, GST_STATE_PAUSED);
|
|
if (ret == GST_STATE_CHANGE_FAILURE)
|
|
goto state_error;
|
|
|
|
/* get the ghostpad of the sink bin */
|
|
sinkpad = gst_element_get_pad (sink, "sink");
|
|
|
|
/* link'n'play */
|
|
lret = gst_pad_link (pad, sinkpad);
|
|
if (lret != GST_PAD_LINK_OK)
|
|
goto link_failed;
|
|
|
|
gst_object_unref (sinkpad);
|
|
}
|
|
return;
|
|
|
|
/* ERRORS */
|
|
state_error:
|
|
{
|
|
gst_bin_remove (GST_BIN_CAST (pipeline), sink);
|
|
g_warning ("could not change state of new sink (%d)", ret);
|
|
return;
|
|
}
|
|
link_failed:
|
|
{
|
|
g_warning ("could not link pad and sink (%d)", lret);
|
|
return;
|
|
}
|
|
}
|
|
|
|
gint
|
|
main (gint argc, gchar * argv[])
|
|
{
|
|
GstElement *pipeline, *filesrc, *decodebin;
|
|
GstStateChangeReturn res;
|
|
|
|
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);
|
|
|
|
g_signal_connect (G_OBJECT (decodebin), "new-decoded-pad",
|
|
G_CALLBACK (cb_newpad), pipeline);
|
|
|
|
gst_bin_add_many (GST_BIN (pipeline), filesrc, decodebin, NULL);
|
|
gst_element_link (filesrc, decodebin);
|
|
|
|
if (argc < 2) {
|
|
g_print ("usage: %s <uri>\n", argv[0]);
|
|
exit (-1);
|
|
}
|
|
g_object_set (G_OBJECT (filesrc), "location", argv[1], NULL);
|
|
|
|
/* set to paused, decodebin will autoplug and signal new_pad callbacks */
|
|
res = gst_element_set_state (pipeline, GST_STATE_PAUSED);
|
|
if (res == GST_STATE_CHANGE_FAILURE) {
|
|
g_print ("could not pause\n");
|
|
return -1;
|
|
}
|
|
/* wait for paused to complete */
|
|
res = gst_element_get_state (pipeline, NULL, NULL, GST_CLOCK_TIME_NONE);
|
|
if (res == GST_STATE_CHANGE_FAILURE) {
|
|
g_print ("could not pause\n");
|
|
return -1;
|
|
}
|
|
|
|
/* play, now all the sinks are added to the pipeline and are prerolled and
|
|
* ready to play. */
|
|
res = gst_element_set_state (pipeline, GST_STATE_PLAYING);
|
|
if (res == GST_STATE_CHANGE_FAILURE) {
|
|
g_print ("could not play\n");
|
|
return -1;
|
|
}
|
|
|
|
/* go in the mainloop now */
|
|
loop = g_main_loop_new (NULL, TRUE);
|
|
g_main_loop_run (loop);
|
|
|
|
return 0;
|
|
}
|