2 This file is part of GNUnet.
3 Copyright (C) 2016 GNUnet e.V.
5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your option) any later version.
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details.
15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
19 * @file conversation/gnunet_gst_test.c
24 #include "gnunet_gst_def.h"
25 #include "gnunet_gst.h"
28 main (int argc, char *argv[])
30 struct GNUNET_gstData *gst;
32 GstElement *gnunetsrc, *gnunetsink, *source, *sink, *encoder, *decoder;
36 // audio_message = GNUNET_malloc (UINT16_MAX);
37 //audio_message->header.type = htons (GNUNET_MESSAGE_TYPE_CONVERSATION_AUDIO);
40 //GstPipeline *pipeline;
42 gst = (GNUNET_gstData*)malloc(sizeof(struct GNUNET_gstData));
44 //gst->audio_message.header.type = htons (GNUNET_MESSAGE_TYPE_CONVERSATION_AUDIO);
47 gg_load_configuration(gst);
49 gst->audiobackend = JACK;
50 gst->dropsilence = TRUE;
53 /* Initialize GStreamer */
54 gst_init (&argc, &argv);
56 gst->pipeline = GST_PIPELINE(gst_pipeline_new ("gnunet-media-helper"));
60 printf("this is the speaker \n");
63 int type = MICROPHONE;
64 printf("this is the microphone \n");
70 gnunetsrc = GST_ELEMENT(get_app(gst, SOURCE));
72 sink = GST_ELEMENT(get_audiobin(gst, SINK));
73 decoder = GST_ELEMENT(get_coder(gst, DECODER));
74 gst_bin_add_many( GST_BIN(gst->pipeline), gnunetsrc, decoder, sink, NULL);
75 gst_element_link_many( gnunetsrc, decoder, sink , NULL);
78 if ( type == MICROPHONE ) {
80 source = GST_ELEMENT(get_audiobin(gst, SOURCE));
82 encoder = GST_ELEMENT(get_coder(gst, ENCODER));
84 gnunetsink = GST_ELEMENT(get_app(gst, SINK));
86 gst_bin_add_many( GST_BIN(gst->pipeline), source, encoder, gnunetsink, NULL);
87 gst_element_link_many( source, encoder, gnunetsink , NULL);
92 gst_bin_add_many( GST_BIN(gst->pipeline), appsource, appsink, source, encoder, decoder, sink, NULL);
93 gst_element_link_many( source, encoder, decoder, sink , NULL);
95 pl_graph(gst->pipeline);
97 gst_element_set_state (GST_ELEMENT(gst->pipeline), GST_STATE_PLAYING);
99 //pl_graph(gst->pipeline);
101 /* Wait until error or EOS */
102 //bus = gst_element_get_bus (GST_ELEMENT(gst->pipeline));
103 //bus_watch_id = gst_bus_add_watch (bus, gnunet_gst_bus_call, pipeline);
105 gg_setup_gst_bus(gst);
106 // g_print ("Running...\n");
109 // start pushing buffers
110 if ( type == MICROPHONE )
115 loop = g_main_loop_new (NULL, FALSE);
117 g_main_loop_run (loop);
123 flow = on_appsink_new_sample (gst->appsink, gst);
127 if ( type == SPEAKER )
131 // printf("read.. \n");
135 g_print ("Returned, stopping playback\n");
137 // gst_object_unref (bus);
138 gst_element_set_state (GST_ELEMENT(gst->pipeline), GST_STATE_NULL);
139 gst_object_unref (gst->pipeline);