mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-22 09:41:07 +00:00
Add audioconvert and audioscale elements and add an error handler
Original commit message from CVS: Add audioconvert and audioscale elements and add an error handler
This commit is contained in:
parent
52f501457d
commit
f4b49b70e1
3 changed files with 78 additions and 8 deletions
|
@ -1,3 +1,9 @@
|
||||||
|
2005-04-05 Tim-Philipp Müller <tim at centricular dot net>
|
||||||
|
|
||||||
|
* examples/helloworld/helloworld.c: (error_cb), (main):
|
||||||
|
Add audioconvert and audioscale elements and an
|
||||||
|
error handler.
|
||||||
|
|
||||||
2005-03-30 Ronald S. Bultje <rbultje@ronald.bitfreak.net>
|
2005-03-30 Ronald S. Bultje <rbultje@ronald.bitfreak.net>
|
||||||
|
|
||||||
* gst/gstelement.c: (gst_element_found_tags_for_pad):
|
* gst/gstelement.c: (gst_element_found_tags_for_pad):
|
||||||
|
|
|
@ -1,10 +1,22 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <gst/gst.h>
|
#include <gst/gst.h>
|
||||||
|
|
||||||
|
static void
|
||||||
|
error_cb (GstElement * bin, GstElement * error_element, GError * error,
|
||||||
|
const gchar * debug_msg, gpointer user_data)
|
||||||
|
{
|
||||||
|
gboolean *p_got_error = (gboolean *) user_data;
|
||||||
|
|
||||||
|
g_printerr ("An error occured: %s\n", error->message);
|
||||||
|
|
||||||
|
*p_got_error = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
main (int argc, char *argv[])
|
main (int argc, char *argv[])
|
||||||
{
|
{
|
||||||
GstElement *bin, *filesrc, *decoder, *osssink;
|
GstElement *bin, *filesrc, *decoder, *audioconvert, *audioscale, *osssink;
|
||||||
|
gboolean got_error;
|
||||||
|
|
||||||
gst_init (&argc, &argv);
|
gst_init (&argc, &argv);
|
||||||
|
|
||||||
|
@ -28,23 +40,43 @@ main (int argc, char *argv[])
|
||||||
g_print ("could not find plugin \"mad\"");
|
g_print ("could not find plugin \"mad\"");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* create standard converters to make sure the decoded
|
||||||
|
* samples are converted into a format our audio sink
|
||||||
|
* understands (if necessary) */
|
||||||
|
audioconvert = gst_element_factory_make ("audioconvert", "audioconvert");
|
||||||
|
audioscale = gst_element_factory_make ("audioscale", "audioscale");
|
||||||
|
g_assert (audioconvert && audioscale);
|
||||||
|
|
||||||
/* and an audio sink */
|
/* and an audio sink */
|
||||||
osssink = gst_element_factory_make ("osssink", "play_audio");
|
osssink = gst_element_factory_make ("osssink", "play_audio");
|
||||||
g_assert (osssink);
|
g_assert (osssink);
|
||||||
|
|
||||||
/* add objects to the main pipeline */
|
/* add objects to the main pipeline */
|
||||||
gst_bin_add_many (GST_BIN (bin), filesrc, decoder, osssink, NULL);
|
gst_bin_add_many (GST_BIN (bin), filesrc, decoder, audioconvert, audioscale,
|
||||||
|
osssink, NULL);
|
||||||
|
|
||||||
/* link the elements */
|
/* link the elements */
|
||||||
gst_element_link_many (filesrc, decoder, osssink, NULL);
|
if (!gst_element_link_many (filesrc, decoder, audioconvert, audioscale,
|
||||||
|
osssink, NULL))
|
||||||
|
g_error ("gst_element_link_many() failed!");
|
||||||
|
|
||||||
|
/* check for errors */
|
||||||
|
got_error = FALSE;
|
||||||
|
g_signal_connect (bin, "error", G_CALLBACK (error_cb), &got_error);
|
||||||
|
|
||||||
/* start playing */
|
/* start playing */
|
||||||
gst_element_set_state (bin, GST_STATE_PLAYING);
|
gst_element_set_state (bin, GST_STATE_PLAYING);
|
||||||
|
|
||||||
while (gst_bin_iterate (GST_BIN (bin)));
|
while (!got_error && gst_bin_iterate (GST_BIN (bin))) {
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
/* stop the bin */
|
/* stop the bin */
|
||||||
gst_element_set_state (bin, GST_STATE_NULL);
|
gst_element_set_state (bin, GST_STATE_NULL);
|
||||||
|
|
||||||
|
/* free */
|
||||||
|
g_object_unref (bin);
|
||||||
|
|
||||||
exit (0);
|
exit (0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,22 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <gst/gst.h>
|
#include <gst/gst.h>
|
||||||
|
|
||||||
|
static void
|
||||||
|
error_cb (GstElement * bin, GstElement * error_element, GError * error,
|
||||||
|
const gchar * debug_msg, gpointer user_data)
|
||||||
|
{
|
||||||
|
gboolean *p_got_error = (gboolean *) user_data;
|
||||||
|
|
||||||
|
g_printerr ("An error occured: %s\n", error->message);
|
||||||
|
|
||||||
|
*p_got_error = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
main (int argc, char *argv[])
|
main (int argc, char *argv[])
|
||||||
{
|
{
|
||||||
GstElement *bin, *filesrc, *decoder, *osssink;
|
GstElement *bin, *filesrc, *decoder, *audioconvert, *audioscale, *osssink;
|
||||||
|
gboolean got_error;
|
||||||
|
|
||||||
gst_init (&argc, &argv);
|
gst_init (&argc, &argv);
|
||||||
|
|
||||||
|
@ -28,23 +40,43 @@ main (int argc, char *argv[])
|
||||||
g_print ("could not find plugin \"mad\"");
|
g_print ("could not find plugin \"mad\"");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* create standard converters to make sure the decoded
|
||||||
|
* samples are converted into a format our audio sink
|
||||||
|
* understands (if necessary) */
|
||||||
|
audioconvert = gst_element_factory_make ("audioconvert", "audioconvert");
|
||||||
|
audioscale = gst_element_factory_make ("audioscale", "audioscale");
|
||||||
|
g_assert (audioconvert && audioscale);
|
||||||
|
|
||||||
/* and an audio sink */
|
/* and an audio sink */
|
||||||
osssink = gst_element_factory_make ("osssink", "play_audio");
|
osssink = gst_element_factory_make ("osssink", "play_audio");
|
||||||
g_assert (osssink);
|
g_assert (osssink);
|
||||||
|
|
||||||
/* add objects to the main pipeline */
|
/* add objects to the main pipeline */
|
||||||
gst_bin_add_many (GST_BIN (bin), filesrc, decoder, osssink, NULL);
|
gst_bin_add_many (GST_BIN (bin), filesrc, decoder, audioconvert, audioscale,
|
||||||
|
osssink, NULL);
|
||||||
|
|
||||||
/* link the elements */
|
/* link the elements */
|
||||||
gst_element_link_many (filesrc, decoder, osssink, NULL);
|
if (!gst_element_link_many (filesrc, decoder, audioconvert, audioscale,
|
||||||
|
osssink, NULL))
|
||||||
|
g_error ("gst_element_link_many() failed!");
|
||||||
|
|
||||||
|
/* check for errors */
|
||||||
|
got_error = FALSE;
|
||||||
|
g_signal_connect (bin, "error", G_CALLBACK (error_cb), &got_error);
|
||||||
|
|
||||||
/* start playing */
|
/* start playing */
|
||||||
gst_element_set_state (bin, GST_STATE_PLAYING);
|
gst_element_set_state (bin, GST_STATE_PLAYING);
|
||||||
|
|
||||||
while (gst_bin_iterate (GST_BIN (bin)));
|
while (!got_error && gst_bin_iterate (GST_BIN (bin))) {
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
/* stop the bin */
|
/* stop the bin */
|
||||||
gst_element_set_state (bin, GST_STATE_NULL);
|
gst_element_set_state (bin, GST_STATE_NULL);
|
||||||
|
|
||||||
|
/* free */
|
||||||
|
g_object_unref (bin);
|
||||||
|
|
||||||
exit (0);
|
exit (0);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue