[svn r16] Moved myth test to tests dir.
1.1 --- a/gst-plugins-mythtv/src/mythtvsrc-test.c Tue Sep 26 16:02:15 2006 +0100
1.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
1.3 @@ -1,85 +0,0 @@
1.4 -#include <gst/gst.h>
1.5 -
1.6 -static gboolean
1.7 -bus_call (GstBus *bus,
1.8 - GstMessage *msg,
1.9 - gpointer data)
1.10 -{
1.11 - GMainLoop *loop = data;
1.12 -
1.13 - switch (GST_MESSAGE_TYPE (msg)) {
1.14 - case GST_MESSAGE_EOS:
1.15 - g_print ("End-of-stream\n");
1.16 - g_main_loop_quit (loop);
1.17 - break;
1.18 - case GST_MESSAGE_ERROR: {
1.19 - gchar *debug;
1.20 - GError *err;
1.21 -
1.22 - gst_message_parse_error (msg, &err, &debug);
1.23 - g_free (debug);
1.24 -
1.25 - g_print ("Error: %s\n", err->message);
1.26 - g_error_free (err);
1.27 -
1.28 - g_main_loop_quit (loop);
1.29 - break;
1.30 - }
1.31 - default:
1.32 - break;
1.33 - }
1.34 -
1.35 - return TRUE;
1.36 -}
1.37 -
1.38 -gint
1.39 -main (gint argc,
1.40 - gchar *argv[])
1.41 -{
1.42 - GstElement *pipeline, *filesrc, *decoder, *filter, *sink;
1.43 - GMainLoop *loop;
1.44 -
1.45 - /* initialization */
1.46 - gst_init (&argc, &argv);
1.47 - loop = g_main_loop_new (NULL, FALSE);
1.48 - if (argc != 2) {
1.49 - g_print ("Usage: %s <myth uri>\n", argv[0]);
1.50 - return 01;
1.51 - }
1.52 -
1.53 - /* create elements */
1.54 - pipeline = gst_pipeline_new ("mythtvsrc_pipeline");
1.55 - gst_bus_add_watch (gst_pipeline_get_bus (GST_PIPELINE (pipeline)),
1.56 - bus_call, loop);
1.57 -
1.58 - filesrc = gst_element_factory_make ("mythtvsrc", "mythtvsrc");
1.59 - decoder = gst_element_factory_make ("mad", "my_decoder");
1.60 - filter = gst_element_factory_make ("my_filter", "my_filter");
1.61 - sink = gst_element_factory_make ("osssink", "audiosink");
1.62 - if (!sink || !decoder) {
1.63 - g_print ("Decoder or output could not be found - check your install\n");
1.64 - return -1;
1.65 - } else if (!filter) {
1.66 - g_print ("Your self-written filter could not be found. Make sure it "
1.67 - "is installed correctly in $(libdir)/gstreamer-0.9/ and that "
1.68 - "you've ran gst-register-0.9 to register it. Check availability "
1.69 - "of the plugin afterwards using \"gst-inspect-0.9 my_filter\"");
1.70 - return -1;
1.71 - }
1.72 -
1.73 - g_object_set (G_OBJECT (filesrc), "location", argv[1], NULL);
1.74 -
1.75 - /* link everything together */
1.76 - gst_element_link_many (filesrc, decoder, filter, sink, NULL);
1.77 - gst_bin_add_many (GST_BIN (pipeline), filesrc, decoder, filter, sink, NULL);
1.78 -
1.79 - /* run */
1.80 - gst_element_set_state (pipeline, GST_STATE_PLAYING);
1.81 - g_main_loop_run (loop);
1.82 -
1.83 - /* clean up */
1.84 - gst_element_set_state (pipeline, GST_STATE_NULL);
1.85 - gst_object_unref (GST_OBJECT (pipeline));
1.86 -
1.87 - return 0;
1.88 -}
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2.2 +++ b/gst-plugins-mythtv/tests/mythtvsrc-test.c Tue Sep 26 16:13:13 2006 +0100
2.3 @@ -0,0 +1,85 @@
2.4 +#include <gst/gst.h>
2.5 +
2.6 +static gboolean
2.7 +bus_call (GstBus *bus,
2.8 + GstMessage *msg,
2.9 + gpointer data)
2.10 +{
2.11 + GMainLoop *loop = data;
2.12 +
2.13 + switch (GST_MESSAGE_TYPE (msg)) {
2.14 + case GST_MESSAGE_EOS:
2.15 + g_print ("End-of-stream\n");
2.16 + g_main_loop_quit (loop);
2.17 + break;
2.18 + case GST_MESSAGE_ERROR: {
2.19 + gchar *debug;
2.20 + GError *err;
2.21 +
2.22 + gst_message_parse_error (msg, &err, &debug);
2.23 + g_free (debug);
2.24 +
2.25 + g_print ("Error: %s\n", err->message);
2.26 + g_error_free (err);
2.27 +
2.28 + g_main_loop_quit (loop);
2.29 + break;
2.30 + }
2.31 + default:
2.32 + break;
2.33 + }
2.34 +
2.35 + return TRUE;
2.36 +}
2.37 +
2.38 +gint
2.39 +main (gint argc,
2.40 + gchar *argv[])
2.41 +{
2.42 + GstElement *pipeline, *filesrc, *decoder, *filter, *sink;
2.43 + GMainLoop *loop;
2.44 +
2.45 + /* initialization */
2.46 + gst_init (&argc, &argv);
2.47 + loop = g_main_loop_new (NULL, FALSE);
2.48 + if (argc != 2) {
2.49 + g_print ("Usage: %s <myth uri>\n", argv[0]);
2.50 + return 01;
2.51 + }
2.52 +
2.53 + /* create elements */
2.54 + pipeline = gst_pipeline_new ("mythtvsrc_pipeline");
2.55 + gst_bus_add_watch (gst_pipeline_get_bus (GST_PIPELINE (pipeline)),
2.56 + bus_call, loop);
2.57 +
2.58 + filesrc = gst_element_factory_make ("mythtvsrc", "mythtvsrc");
2.59 + decoder = gst_element_factory_make ("mad", "my_decoder");
2.60 + filter = gst_element_factory_make ("my_filter", "my_filter");
2.61 + sink = gst_element_factory_make ("osssink", "audiosink");
2.62 + if (!sink || !decoder) {
2.63 + g_print ("Decoder or output could not be found - check your install\n");
2.64 + return -1;
2.65 + } else if (!filter) {
2.66 + g_print ("Your self-written filter could not be found. Make sure it "
2.67 + "is installed correctly in $(libdir)/gstreamer-0.9/ and that "
2.68 + "you've ran gst-register-0.9 to register it. Check availability "
2.69 + "of the plugin afterwards using \"gst-inspect-0.9 my_filter\"");
2.70 + return -1;
2.71 + }
2.72 +
2.73 + g_object_set (G_OBJECT (filesrc), "location", argv[1], NULL);
2.74 +
2.75 + /* link everything together */
2.76 + gst_element_link_many (filesrc, decoder, filter, sink, NULL);
2.77 + gst_bin_add_many (GST_BIN (pipeline), filesrc, decoder, filter, sink, NULL);
2.78 +
2.79 + /* run */
2.80 + gst_element_set_state (pipeline, GST_STATE_PLAYING);
2.81 + g_main_loop_run (loop);
2.82 +
2.83 + /* clean up */
2.84 + gst_element_set_state (pipeline, GST_STATE_NULL);
2.85 + gst_object_unref (GST_OBJECT (pipeline));
2.86 +
2.87 + return 0;
2.88 +}