aboutsummaryrefslogtreecommitdiff
path: root/src/conversation
diff options
context:
space:
mode:
Diffstat (limited to 'src/conversation')
-rw-r--r--src/conversation/Makefile.am2
-rw-r--r--src/conversation/gnunet-helper-audio-playback-gst.c69
-rw-r--r--src/conversation/gnunet-helper-audio-record-gst.c9
-rw-r--r--src/conversation/gnunet_gst.c54
-rw-r--r--src/conversation/gnunet_gst_def.h2
-rw-r--r--src/conversation/gnunet_gst_test.c7
6 files changed, 72 insertions, 71 deletions
diff --git a/src/conversation/Makefile.am b/src/conversation/Makefile.am
index cc2938144..cbffc3283 100644
--- a/src/conversation/Makefile.am
+++ b/src/conversation/Makefile.am
@@ -138,7 +138,7 @@ gnunet_helper_audio_record_CFLAGS = \
138 $(GST_CFLAGS) 138 $(GST_CFLAGS)
139 139
140gnunet_helper_audio_playback_SOURCES = \ 140gnunet_helper_audio_playback_SOURCES = \
141 gnunet_gst_test.c gnunet_gst.c 141 gnunet-helper-audio-playback-gst.c
142gnunet_helper_audio_playback_LDADD = \ 142gnunet_helper_audio_playback_LDADD = \
143 $(top_builddir)/src/util/libgnunetutil.la \ 143 $(top_builddir)/src/util/libgnunetutil.la \
144 $(GST_LIBS) \ 144 $(GST_LIBS) \
diff --git a/src/conversation/gnunet-helper-audio-playback-gst.c b/src/conversation/gnunet-helper-audio-playback-gst.c
index 9307cd12e..264b14e76 100644
--- a/src/conversation/gnunet-helper-audio-playback-gst.c
+++ b/src/conversation/gnunet-helper-audio-playback-gst.c
@@ -56,7 +56,7 @@
56/** 56/**
57 * Tokenizer for the data we get from stdin 57 * Tokenizer for the data we get from stdin
58 */ 58 */
59struct GNUNET_SERVER_MessageStreamTokenizer *stdin_mst; 59struct GNUNET_MessageStreamTokenizer *stdin_mst;
60 60
61/** 61/**
62 * Main pipeline. 62 * Main pipeline.
@@ -82,20 +82,20 @@ static int abort_read;
82 82
83static void 83static void
84sink_child_added (GstChildProxy *child_proxy, 84sink_child_added (GstChildProxy *child_proxy,
85 GObject *object, 85 GObject *object,
86 gchar *name, 86 gchar *name,
87 gpointer user_data) 87 gpointer user_data)
88{ 88{
89 if (GST_IS_AUDIO_BASE_SRC (object)) 89 if (GST_IS_AUDIO_BASE_SRC (object))
90 g_object_set (object, 90 g_object_set (object,
91 "buffer-time", (gint64) BUFFER_TIME, 91 "buffer-time", (gint64) BUFFER_TIME,
92 "latency-time", (gint64) LATENCY_TIME, 92 "latency-time", (gint64) LATENCY_TIME,
93 NULL); 93 NULL);
94} 94}
95 95
96 96
97static void 97static void
98ogg_pad_added (GstElement *element, 98ogg_pad_added (GstElement *element,
99 GstPad *pad, 99 GstPad *pad,
100 gpointer data) 100 gpointer data)
101{ 101{
@@ -127,7 +127,7 @@ quit ()
127static gboolean 127static gboolean
128bus_call (GstBus *bus, GstMessage *msg, gpointer data) 128bus_call (GstBus *bus, GstMessage *msg, gpointer data)
129{ 129{
130 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 130 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
131 "Bus message\n"); 131 "Bus message\n");
132 switch (GST_MESSAGE_TYPE (msg)) 132 switch (GST_MESSAGE_TYPE (msg))
133 { 133 {
@@ -141,15 +141,15 @@ bus_call (GstBus *bus, GstMessage *msg, gpointer data)
141 { 141 {
142 gchar *debug; 142 gchar *debug;
143 GError *error; 143 GError *error;
144 144
145 gst_message_parse_error (msg, &error, &debug); 145 gst_message_parse_error (msg, &error, &debug);
146 g_free (debug); 146 g_free (debug);
147 147
148 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 148 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
149 "Error: %s\n", 149 "Error: %s\n",
150 error->message); 150 error->message);
151 g_error_free (error); 151 g_error_free (error);
152 152
153 quit (); 153 quit ();
154 break; 154 break;
155 } 155 }
@@ -196,7 +196,7 @@ feed_buffer_to_gst (const char *audio, size_t b_len)
196 switch (flow) 196 switch (flow)
197 { 197 {
198 case GST_FLOW_OK: 198 case GST_FLOW_OK:
199 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 199 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
200 "Fed %u bytes to the pipeline\n", 200 "Fed %u bytes to the pipeline\n",
201 (unsigned int) b_len); 201 (unsigned int) b_len);
202 break; 202 break;
@@ -207,7 +207,7 @@ feed_buffer_to_gst (const char *audio, size_t b_len)
207 break; 207 break;
208 case GST_FLOW_EOS: 208 case GST_FLOW_EOS:
209 /* end of stream */ 209 /* end of stream */
210 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 210 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
211 "EOS\n"); 211 "EOS\n");
212 break; 212 break;
213 default: 213 default:
@@ -224,7 +224,6 @@ feed_buffer_to_gst (const char *audio, size_t b_len)
224 */ 224 */
225static int 225static int
226stdin_receiver (void *cls, 226stdin_receiver (void *cls,
227 void *client,
228 const struct GNUNET_MessageHeader *msg) 227 const struct GNUNET_MessageHeader *msg)
229{ 228{
230 struct AudioMessage *audio; 229 struct AudioMessage *audio;
@@ -253,21 +252,21 @@ main (int argc, char **argv)
253 uint64_t toff; 252 uint64_t toff;
254 253
255 typedef void (*SignalHandlerPointer) (int); 254 typedef void (*SignalHandlerPointer) (int);
256 255
257 SignalHandlerPointer inthandler, termhandler; 256 SignalHandlerPointer inthandler, termhandler;
258#ifdef DEBUG_READ_PURE_OGG 257#ifdef DEBUG_READ_PURE_OGG
259 int read_pure_ogg = getenv ("GNUNET_READ_PURE_OGG") ? 1 : 0; 258 int read_pure_ogg = getenv ("GNUNET_READ_PURE_OGG") ? 1 : 0;
260#endif 259#endif
261 260
262 inthandler = signal (SIGINT, 261 inthandler = signal (SIGINT,
263 &signalhandler); 262 &signalhandler);
264 termhandler = signal (SIGTERM, 263 termhandler = signal (SIGTERM,
265 &signalhandler); 264 &signalhandler);
266 265
267#ifdef WINDOWS 266#ifdef WINDOWS
268 setmode (0, _O_BINARY); 267 setmode (0, _O_BINARY);
269#endif 268#endif
270 269
271 /* Initialisation */ 270 /* Initialisation */
272 gst_init (&argc, &argv); 271 gst_init (&argc, &argv);
273 272
@@ -275,13 +274,13 @@ main (int argc, char **argv)
275 GNUNET_log_setup ("gnunet-helper-audio-playback-gst", 274 GNUNET_log_setup ("gnunet-helper-audio-playback-gst",
276 "WARNING", 275 "WARNING",
277 NULL)); 276 NULL));
278 277
279 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 278 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
280 "Audio sink starts\n"); 279 "Audio sink starts\n");
281 280
282 stdin_mst = GNUNET_SERVER_mst_create (&stdin_receiver, 281 stdin_mst = GNUNET_MST_create (&stdin_receiver,
283 NULL); 282 NULL);
284 283
285 /* Create gstreamer elements */ 284 /* Create gstreamer elements */
286 pipeline = gst_pipeline_new ("audio-player"); 285 pipeline = gst_pipeline_new ("audio-player");
287 source = gst_element_factory_make ("appsrc", "audio-input"); 286 source = gst_element_factory_make ("appsrc", "audio-input");
@@ -298,13 +297,13 @@ main (int argc, char **argv)
298 return -1; 297 return -1;
299 } 298 }
300 299
301 g_signal_connect (sink, 300 g_signal_connect (sink,
302 "child-added", 301 "child-added",
303 G_CALLBACK (sink_child_added), 302 G_CALLBACK (sink_child_added),
304 NULL); 303 NULL);
305 g_signal_connect (demuxer, 304 g_signal_connect (demuxer,
306 "pad-added", 305 "pad-added",
307 G_CALLBACK (ogg_pad_added), 306 G_CALLBACK (ogg_pad_added),
308 decoder); 307 decoder);
309 308
310 /* Keep a reference to it, we operate on it */ 309 /* Keep a reference to it, we operate on it */
@@ -362,7 +361,7 @@ main (int argc, char **argv)
362 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 361 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
363 "Received %d bytes of audio data (total: %llu)\n", 362 "Received %d bytes of audio data (total: %llu)\n",
364 (int) ret, 363 (int) ret,
365 toff); 364 (unsigned long long) toff);
366 if (0 == ret) 365 if (0 == ret)
367 break; 366 break;
368#ifdef DEBUG_READ_PURE_OGG 367#ifdef DEBUG_READ_PURE_OGG
@@ -372,20 +371,22 @@ main (int argc, char **argv)
372 } 371 }
373 else 372 else
374#endif 373#endif
375 GNUNET_SERVER_mst_receive (stdin_mst, NULL, 374 GNUNET_MST_from_buffer (stdin_mst,
376 readbuf, ret, 375 readbuf,
377 GNUNET_NO, GNUNET_NO); 376 ret,
377 GNUNET_NO,
378 GNUNET_NO);
378 } 379 }
379 GNUNET_SERVER_mst_destroy (stdin_mst); 380 GNUNET_MST_destroy (stdin_mst);
380 381
381 signal (SIGINT, inthandler); 382 signal (SIGINT, inthandler);
382 signal (SIGINT, termhandler); 383 signal (SIGINT, termhandler);
383 384
384 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 385 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
385 "Returned, stopping playback\n"); 386 "Returned, stopping playback\n");
386 quit (); 387 quit ();
387 388
388 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 389 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
389 "Deleting pipeline\n"); 390 "Deleting pipeline\n");
390 gst_object_unref (GST_OBJECT (source)); 391 gst_object_unref (GST_OBJECT (source));
391 source = NULL; 392 source = NULL;
diff --git a/src/conversation/gnunet-helper-audio-record-gst.c b/src/conversation/gnunet-helper-audio-record-gst.c
index 7f1f3368b..b9aed4ea7 100644
--- a/src/conversation/gnunet-helper-audio-record-gst.c
+++ b/src/conversation/gnunet-helper-audio-record-gst.c
@@ -352,9 +352,12 @@ main (int argc, char **argv)
352 { 352 {
353 if (-1 == ret) 353 if (-1 == ret)
354 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 354 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
355 "Failed to write %u bytes at offset %u (total %u) in phase %d: %s\n", 355 "Failed to write %u bytes at offset %u (total %u) in phase %d: %s\n",
356 (unsigned int) to_send - offset, (unsigned int) offset, 356 (unsigned int) (to_send - offset),
357 (unsigned int) (to_send + offset), phase, strerror (errno)); 357 (unsigned int) offset,
358 (unsigned int) (to_send + offset),
359 phase,
360 strerror (errno));
358 abort_send = 1; 361 abort_send = 1;
359 break; 362 break;
360 } 363 }
diff --git a/src/conversation/gnunet_gst.c b/src/conversation/gnunet_gst.c
index 91c6ddccb..52cb2ccbc 100644
--- a/src/conversation/gnunet_gst.c
+++ b/src/conversation/gnunet_gst.c
@@ -29,6 +29,7 @@
29 */ 29 */
30static struct GNUNET_CONFIGURATION_Handle *cfg; 30static struct GNUNET_CONFIGURATION_Handle *cfg;
31 31
32
32void 33void
33dump_buffer(unsigned n, const unsigned char* buf) 34dump_buffer(unsigned n, const unsigned char* buf)
34{ 35{
@@ -61,15 +62,13 @@ BREAKOUT:
61/*** 62/***
62 * load gnunet configuration 63 * load gnunet configuration
63 */ 64 */
64 void 65void
65gg_load_configuration(GNUNET_gstData * d) 66gg_load_configuration(GNUNET_gstData * d)
66{ 67{
67 char *audiobackend_string; 68 char *audiobackend_string;
68 cfg = GNUNET_CONFIGURATION_create(); 69 cfg = GNUNET_CONFIGURATION_create();
69 GNUNET_CONFIGURATION_load(cfg, "mediahelper.conf"); 70 GNUNET_CONFIGURATION_load(cfg, "mediahelper.conf");
70 71
71 char *section = "MEDIAHELPER";
72
73 GNUNET_CONFIGURATION_get_value_string(cfg, "MEDIAHELPER", "JACK_PP_IN", &d->jack_pp_in); 72 GNUNET_CONFIGURATION_get_value_string(cfg, "MEDIAHELPER", "JACK_PP_IN", &d->jack_pp_in);
74 GNUNET_CONFIGURATION_get_value_string(cfg, "MEDIAHELPER", "JACK_PP_OUT", &d->jack_pp_out); 73 GNUNET_CONFIGURATION_get_value_string(cfg, "MEDIAHELPER", "JACK_PP_OUT", &d->jack_pp_out);
75 74
@@ -77,19 +76,19 @@ gg_load_configuration(GNUNET_gstData * d)
77 76
78 // printf("abstring: %s \n", audiobackend_string); 77 // printf("abstring: %s \n", audiobackend_string);
79 78
80 if ( audiobackend_string == "AUTO" ) 79 if (0 == strcasecmp (audiobackend_string, "AUTO"))
81 { 80 {
82 d->audiobackend = AUTO; 81 d->audiobackend = AUTO;
83 } else if ( audiobackend_string = "JACK" ) 82 } else if (0 == strcasecmp (audiobackend_string, "JACK"))
84 { 83 {
85 d->audiobackend = JACK; 84 d->audiobackend = JACK;
86 } else if ( audiobackend_string = "ALSA" ) 85 } else if (0 == strcasecmp (audiobackend_string, "ALSA"))
87 { 86 {
88 d->audiobackend = ALSA; 87 d->audiobackend = ALSA;
89 } else if ( audiobackend_string = "FAKE" ) 88 } else if (0 == strcasecmp (audiobackend_string, "FAKE"))
90 { 89 {
91 d->audiobackend = FAKE; 90 d->audiobackend = FAKE;
92 } else if ( audiobackend_string = "TEST" ) 91 } else if (0 == strcasecmp (audiobackend_string, "TEST"))
93 { 92 {
94 d->audiobackend = TEST; 93 d->audiobackend = TEST;
95 } else 94 } else
@@ -147,8 +146,6 @@ write_data (const char *ptr, size_t msg_size)
147extern GstFlowReturn 146extern GstFlowReturn
148on_appsink_new_sample (GstElement * element, GNUNET_gstData * d) 147on_appsink_new_sample (GstElement * element, GNUNET_gstData * d)
149{ 148{
150 static unsigned long long toff;
151
152 //size of message including gnunet header 149 //size of message including gnunet header
153 size_t msg_size; 150 size_t msg_size;
154 151
@@ -161,7 +158,6 @@ on_appsink_new_sample (GstElement * element, GNUNET_gstData * d)
161 GstCaps *s_caps; 158 GstCaps *s_caps;
162 char *caps_str; 159 char *caps_str;
163*/ 160*/
164 (d->audio_message)->header.size = htons ((uint16_t) msg_size);
165 161
166 if (gst_app_sink_is_eos(GST_APP_SINK(element))) 162 if (gst_app_sink_is_eos(GST_APP_SINK(element)))
167 return GST_FLOW_OK; 163 return GST_FLOW_OK;
@@ -197,13 +193,7 @@ on_appsink_new_sample (GstElement * element, GNUNET_gstData * d)
197 193
198 // copy the data into audio_message 194 // copy the data into audio_message
199 GNUNET_memcpy (((char *) &(d->audio_message)[1]), map.data, len); 195 GNUNET_memcpy (((char *) &(d->audio_message)[1]), map.data, len);
200/* 196 (d->audio_message)->header.size = htons ((uint16_t) msg_size);
201 toff += msg_size;
202 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
203 "Sending %u bytes of audio data (total: %llu)\n",
204 (unsigned int) msg_size,
205 toff);
206*/
207 if (d->pure_ogg) 197 if (d->pure_ogg)
208 // write the audio_message without the gnunet headers 198 // write the audio_message without the gnunet headers
209 write_data ((const char *) &(d->audio_message)[1], len); 199 write_data ((const char *) &(d->audio_message)[1], len);
@@ -589,14 +579,15 @@ autoaudiosource_child_added (GstChildProxy *child_proxy, GObject *object, gchar
589 g_object_set (object, "buffer-time", (gint64) BUFFER_TIME, "latency-time", (gint64) LATENCY_TIME, NULL); 579 g_object_set (object, "buffer-time", (gint64) BUFFER_TIME, "latency-time", (gint64) LATENCY_TIME, NULL);
590} 580}
591 581
582
592GstElement * 583GstElement *
593get_pipeline(GstElement *element) 584get_pipeline(GstElement *element)
594{ 585{
595 GstPipeline *p; 586 GstPipeline *p;
596 587
597 p = gst_object_get_parent(element); 588 p = GST_PIPELINE (gst_object_get_parent(GST_OBJECT (element)));
598 589
599 return p; 590 return GST_ELEMENT (p);
600} 591}
601 592
602 static void 593 static void
@@ -617,6 +608,7 @@ decoder_ogg_pad_added (GstElement *element,
617 gst_object_unref (sinkpad); 608 gst_object_unref (sinkpad);
618} 609}
619 610
611
620int 612int
621gnunet_read (GNUNET_gstData * d) 613gnunet_read (GNUNET_gstData * d)
622{ 614{
@@ -646,10 +638,13 @@ gnunet_read (GNUNET_gstData * d)
646 else 638 else
647 { 639 {
648 //#endif 640 //#endif
649 GNUNET_SERVER_mst_receive (d->stdin_mst, NULL, 641 GNUNET_MST_from_buffer (d->stdin_mst,
650 readbuf, ret, 642 readbuf,
651 GNUNET_NO, GNUNET_NO); 643 ret,
644 GNUNET_NO,
645 GNUNET_NO);
652 } 646 }
647 return 0;
653} 648}
654 649
655/** 650/**
@@ -657,13 +652,14 @@ gnunet_read (GNUNET_gstData * d)
657 */ 652 */
658static int 653static int
659stdin_receiver (void *cls, 654stdin_receiver (void *cls,
660 void *client,
661 const struct GNUNET_MessageHeader *msg) 655 const struct GNUNET_MessageHeader *msg)
662{ 656{
663 struct AudioMessage *audio; 657 struct AudioMessage *audio;
664 size_t b_len; 658 size_t b_len;
659
665 printf("stdin receiver \n "); 660 printf("stdin receiver \n ");
666 dump_buffer(sizeof(msg), msg); 661 dump_buffer (sizeof(msg),
662 (const unsigned char *) msg);
667 663
668 switch (ntohs (msg->type)) 664 switch (ntohs (msg->type))
669 { 665 {
@@ -711,7 +707,7 @@ get_app(GNUNET_gstData *d, int type)
711 //d->audio_message.header.type = htons (GNUNET_MESSAGE_TYPE_CONVERSATION_AUDIO); 707 //d->audio_message.header.type = htons (GNUNET_MESSAGE_TYPE_CONVERSATION_AUDIO);
712 708
713 709
714 d->stdin_mst = GNUNET_SERVER_mst_create (&stdin_receiver, d); 710 d->stdin_mst = GNUNET_MST_create (&stdin_receiver, d);
715 711
716 if ( d->stdin_mst == NULL) 712 if ( d->stdin_mst == NULL)
717 printf("stdin_mst = NULL"); 713 printf("stdin_mst = NULL");
@@ -768,7 +764,7 @@ get_coder(GNUNET_gstData *d , int type)
768{ 764{
769 GstBin *bin; 765 GstBin *bin;
770 GstPad *srcpad, *sinkpad, *srcghostpad, *sinkghostpad; 766 GstPad *srcpad, *sinkpad, *srcghostpad, *sinkghostpad;
771 GstCaps *caps, *rtpcaps; 767 GstCaps *rtpcaps;
772 GstElement *encoder, *muxer, *decoder, *demuxer, *jitterbuffer, *rtpcapsfilter; 768 GstElement *encoder, *muxer, *decoder, *demuxer, *jitterbuffer, *rtpcapsfilter;
773 769
774 if ( d->usertp == TRUE ) 770 if ( d->usertp == TRUE )
@@ -892,7 +888,9 @@ get_coder(GNUNET_gstData *d , int type)
892 888
893 return bin; 889 return bin;
894} 890}
895 extern GstBin * 891
892
893extern GstBin *
896get_audiobin(GNUNET_gstData *d , int type) 894get_audiobin(GNUNET_gstData *d , int type)
897{ 895{
898 GstBin *bin; 896 GstBin *bin;
diff --git a/src/conversation/gnunet_gst_def.h b/src/conversation/gnunet_gst_def.h
index 85add54b6..980ed2f48 100644
--- a/src/conversation/gnunet_gst_def.h
+++ b/src/conversation/gnunet_gst_def.h
@@ -94,7 +94,7 @@ struct GNUNET_gstData {
94 94
95 // things 95 // things
96 struct AudioMessage *audio_message; 96 struct AudioMessage *audio_message;
97 struct GNUNET_SERVER_MessageStreamTokenizer *stdin_mst; 97 struct GNUNET_MessageStreamTokenizer *stdin_mst;
98 GstElement *appsrc; 98 GstElement *appsrc;
99 GstElement *appsink; 99 GstElement *appsink;
100 //settings 100 //settings
diff --git a/src/conversation/gnunet_gst_test.c b/src/conversation/gnunet_gst_test.c
index 2ea007583..03f6a4d95 100644
--- a/src/conversation/gnunet_gst_test.c
+++ b/src/conversation/gnunet_gst_test.c
@@ -18,7 +18,7 @@
18 Boston, MA 02110-1301, USA. 18 Boston, MA 02110-1301, USA.
19*/ 19*/
20/** 20/**
21 * @file conversation/gnunet_gst.c 21 * @file conversation/gnunet_gst_test.c
22 * @brief FIXME 22 * @brief FIXME
23 * @author Hark 23 * @author Hark
24 */ 24 */
@@ -30,8 +30,7 @@ int
30main (int argc, char *argv[]) 30main (int argc, char *argv[])
31{ 31{
32 struct GNUNET_gstData *gst; 32 struct GNUNET_gstData *gst;
33 GstBus *bus; 33 // GstBus *bus;
34 GstMessage *msg;
35 GstElement *gnunetsrc, *gnunetsink, *source, *sink, *encoder, *decoder; 34 GstElement *gnunetsrc, *gnunetsink, *source, *sink, *encoder, *decoder;
36 35
37 36
@@ -137,7 +136,7 @@ main (int argc, char *argv[])
137 } 136 }
138 g_print ("Returned, stopping playback\n"); 137 g_print ("Returned, stopping playback\n");
139 138
140 gst_object_unref (bus); 139 // gst_object_unref (bus);
141 gst_element_set_state (GST_ELEMENT(gst->pipeline), GST_STATE_NULL); 140 gst_element_set_state (GST_ELEMENT(gst->pipeline), GST_STATE_NULL);
142 gst_object_unref (gst->pipeline); 141 gst_object_unref (gst->pipeline);
143 142