1 #include "gnunet_gst_def.h"
2 #include "gnunet_gst.h"
5 main (int argc, char *argv[])
7 struct GNUNET_gstData *gst;
10 GstElement *gnunetsrc, *gnunetsink, *source, *sink, *encoder, *decoder;
14 // audio_message = GNUNET_malloc (UINT16_MAX);
15 //audio_message->header.type = htons (GNUNET_MESSAGE_TYPE_CONVERSATION_AUDIO);
18 //GstPipeline *pipeline;
20 gst = (GNUNET_gstData*)malloc(sizeof(struct GNUNET_gstData));
22 //gst->audio_message.header.type = htons (GNUNET_MESSAGE_TYPE_CONVERSATION_AUDIO);
25 gg_load_configuration(gst);
27 gst->audiobackend = JACK;
28 gst->dropsilence = TRUE;
31 /* Initialize GStreamer */
32 gst_init (&argc, &argv);
34 gst->pipeline = GST_PIPELINE(gst_pipeline_new ("gnunet-media-helper"));
38 printf("this is the speaker \n");
41 int type = MICROPHONE;
42 printf("this is the microphone \n");
48 gnunetsrc = GST_ELEMENT(get_app(gst, SOURCE));
50 sink = GST_ELEMENT(get_audiobin(gst, SINK));
51 decoder = GST_ELEMENT(get_coder(gst, DECODER));
52 gst_bin_add_many( GST_BIN(gst->pipeline), gnunetsrc, decoder, sink, NULL);
53 gst_element_link_many( gnunetsrc, decoder, sink , NULL);
56 if ( type == MICROPHONE ) {
58 source = GST_ELEMENT(get_audiobin(gst, SOURCE));
60 encoder = GST_ELEMENT(get_coder(gst, ENCODER));
62 gnunetsink = GST_ELEMENT(get_app(gst, SINK));
64 gst_bin_add_many( GST_BIN(gst->pipeline), source, encoder, gnunetsink, NULL);
65 gst_element_link_many( source, encoder, gnunetsink , NULL);
70 gst_bin_add_many( GST_BIN(gst->pipeline), appsource, appsink, source, encoder, decoder, sink, NULL);
71 gst_element_link_many( source, encoder, decoder, sink , NULL);
73 pl_graph(gst->pipeline);
75 gst_element_set_state (GST_ELEMENT(gst->pipeline), GST_STATE_PLAYING);
77 //pl_graph(gst->pipeline);
79 /* Wait until error or EOS */
80 //bus = gst_element_get_bus (GST_ELEMENT(gst->pipeline));
81 //bus_watch_id = gst_bus_add_watch (bus, gnunet_gst_bus_call, pipeline);
83 gg_setup_gst_bus(gst);
84 // g_print ("Running...\n");
87 // start pushing buffers
88 if ( type == MICROPHONE )
93 loop = g_main_loop_new (NULL, FALSE);
95 g_main_loop_run (loop);
101 flow = on_appsink_new_sample (gst->appsink, gst);
105 if ( type == SPEAKER )
109 // printf("read.. \n");
113 g_print ("Returned, stopping playback\n");
115 gst_object_unref (bus);
116 gst_element_set_state (GST_ELEMENT(gst->pipeline), GST_STATE_NULL);
117 gst_object_unref (gst->pipeline);