2
* Copyright (C) <2007> Leandro Melo de Sales <leandroal@gmail.com>
4
* This library is free software; you can redistribute it and/or
5
* modify it under the terms of the GNU Library General Public
6
* License as published by the Free Software Foundation; either
7
* version 2 of the License, or (at your option) any later version.
9
* This library is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
* Library General Public License for more details.
14
* You should have received a copy of the GNU Library General Public
15
* License along with this library; if not, write to the
16
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17
* Boston, MA 02111-1307, USA.
25
bus_call (GstBus * bus, GstMessage * msg, gpointer data)
28
GMainLoop *loop = (GMainLoop *) data;
30
switch (GST_MESSAGE_TYPE (msg)) {
32
g_print ("End-of-stream\n");
33
g_main_loop_quit (loop);
35
case GST_MESSAGE_ERROR:{
39
gst_message_parse_error (msg, &err, &debug);
42
g_print ("Error: %s\n", err->message);
45
g_main_loop_quit (loop);
57
main (int argc, char *argv[])
62
GstElement *pipeline, *filesrc, *dccpserversink;
64
/* initialize GStreamer */
65
gst_init (&argc, &argv);
66
loop = g_main_loop_new (NULL, FALSE);
68
/* check input arguments */
70
g_print ("%s\n", "see usage: port mp3Location");
75
pipeline = gst_pipeline_new ("audio-sender");
76
filesrc = gst_element_factory_make ("filesrc", "file-source");
77
dccpserversink = gst_element_factory_make ("dccpserversink", "server-sink");
80
if (!pipeline || !filesrc || !dccpserversink) {
81
g_print ("One element could not be created\n");
85
g_object_set (G_OBJECT (dccpserversink), "port", atoi (argv[1]), NULL);
86
/*g_object_set (G_OBJECT (dccpserversink), "ccid", 3, NULL); */
87
g_object_set (G_OBJECT (filesrc), "location", argv[2], NULL);
89
bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
90
gst_bus_add_watch (bus, bus_call, loop);
91
gst_object_unref (bus);
93
/* put all elements in a bin */
94
gst_bin_add_many (GST_BIN (pipeline), filesrc, dccpserversink, NULL);
96
gst_element_link_many (filesrc, dccpserversink, NULL);
99
/* Now set to playing and iterate. */
100
g_print ("Setting to PLAYING\n");
101
gst_element_set_state (pipeline, GST_STATE_PLAYING);
102
g_print ("Running\n");
103
g_main_loop_run (loop);
105
/* clean up nicely */
106
g_print ("Returned, stopping playback\n");
107
gst_element_set_state (pipeline, GST_STATE_NULL);
108
g_print ("Deleting pipeline\n");
109
gst_object_unref (GST_OBJECT (pipeline));