aboutsummaryrefslogtreecommitdiff
path: root/src/conversation
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2016-04-09 12:08:40 +0000
committerChristian Grothoff <christian@grothoff.org>2016-04-09 12:08:40 +0000
commita59b71b601cc302a77309dcb8c3db33993117097 (patch)
tree3127cc02e440a1615f0b98c7f9049481f5c0abb5 /src/conversation
parent298ab1efc669836811f5a0234e65cf0fb5313ace (diff)
downloadgnunet-a59b71b601cc302a77309dcb8c3db33993117097.tar.gz
gnunet-a59b71b601cc302a77309dcb8c3db33993117097.zip
add copyright headers, fix includes
Diffstat (limited to 'src/conversation')
-rw-r--r--src/conversation/gnunet_gst.c136
-rw-r--r--src/conversation/gnunet_gst.h26
-rw-r--r--src/conversation/gnunet_gst_def.h43
-rw-r--r--src/conversation/gnunet_gst_test.c45
4 files changed, 174 insertions, 76 deletions
diff --git a/src/conversation/gnunet_gst.c b/src/conversation/gnunet_gst.c
index 657bb8e8a..a9f6bb8d7 100644
--- a/src/conversation/gnunet_gst.c
+++ b/src/conversation/gnunet_gst.c
@@ -1,3 +1,27 @@
1/*
2 This file is part of GNUnet.
3 Copyright (C) 2016 GNUnet e.V.
4
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 3, or (at your
8 option) any later version.
9
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 General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
19*/
20/**
21 * @file conversation/gnunet_gst.c
22 * @brief FIXME
23 * @author Hark
24 */
1#include "gnunet_gst_def.h" 25#include "gnunet_gst_def.h"
2 26
3/** 27/**
@@ -5,7 +29,7 @@
5 */ 29 */
6static struct GNUNET_CONFIGURATION_Handle *cfg; 30static struct GNUNET_CONFIGURATION_Handle *cfg;
7 31
8 void 32void
9dump_buffer(unsigned n, const unsigned char* buf) 33dump_buffer(unsigned n, const unsigned char* buf)
10{ 34{
11 const unsigned char *p, *end; 35 const unsigned char *p, *end;
@@ -68,7 +92,7 @@ gg_load_configuration(GNUNET_gstData * d)
68 } else if ( audiobackend_string = "TEST" ) 92 } else if ( audiobackend_string = "TEST" )
69 { 93 {
70 d->audiobackend = TEST; 94 d->audiobackend = TEST;
71 } else 95 } else
72 { 96 {
73 d->audiobackend = AUTO; 97 d->audiobackend = AUTO;
74 } 98 }
@@ -109,7 +133,7 @@ write_data (const char *ptr, size_t msg_size)
109 { 133 {
110 ret = write (1, &ptr[off], msg_size - off); 134 ret = write (1, &ptr[off], msg_size - off);
111 if (0 >= ret) 135 if (0 >= ret)
112 { 136 {
113 if (-1 == ret) 137 if (-1 == ret)
114 GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "write"); 138 GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "write");
115// quit (2); 139// quit (2);
@@ -124,10 +148,10 @@ extern GstFlowReturn
124on_appsink_new_sample (GstElement * element, GNUNET_gstData * d) 148on_appsink_new_sample (GstElement * element, GNUNET_gstData * d)
125{ 149{
126 static unsigned long long toff; 150 static unsigned long long toff;
127 151
128 //size of message including gnunet header 152 //size of message including gnunet header
129 size_t msg_size; 153 size_t msg_size;
130 154
131 GstSample *s; 155 GstSample *s;
132 GstBuffer *b; 156 GstBuffer *b;
133 GstMapInfo map; 157 GstMapInfo map;
@@ -144,7 +168,7 @@ on_appsink_new_sample (GstElement * element, GNUNET_gstData * d)
144 168
145 //pull sample from appsink 169 //pull sample from appsink
146 s = gst_app_sink_pull_sample (GST_APP_SINK(element)); 170 s = gst_app_sink_pull_sample (GST_APP_SINK(element));
147 171
148 if (s == NULL) 172 if (s == NULL)
149 return GST_FLOW_OK; 173 return GST_FLOW_OK;
150 174
@@ -157,20 +181,20 @@ on_appsink_new_sample (GstElement * element, GNUNET_gstData * d)
157 181
158 182
159 183
160 gst_buffer_map (b, &map, GST_MAP_READ); 184 gst_buffer_map (b, &map, GST_MAP_READ);
161 185
162 size_t len; 186 size_t len;
163 len = map.size; 187 len = map.size;
164 if (len > UINT16_MAX - sizeof (struct AudioMessage)) 188 if (len > UINT16_MAX - sizeof (struct AudioMessage))
165 { 189 {
166 // this should never happen? 190 // this should never happen?
167 printf("GSTREAMER sample too big! \n"); 191 printf("GSTREAMER sample too big! \n");
168 exit(20); 192 exit(20);
169 len = UINT16_MAX - sizeof (struct AudioMessage); 193 len = UINT16_MAX - sizeof (struct AudioMessage);
170 } 194 }
171 195
172 msg_size = sizeof (struct AudioMessage) + len; 196 msg_size = sizeof (struct AudioMessage) + len;
173 197
174 // copy the data into audio_message 198 // copy the data into audio_message
175 memcpy (((char *) &(d->audio_message)[1]), map.data, len); 199 memcpy (((char *) &(d->audio_message)[1]), map.data, len);
176/* 200/*
@@ -205,7 +229,7 @@ pl_graph(GstElement * pipeline)
205 gst_debug_bin_to_dot_file_with_ts(GST_BIN(pipeline), GST_DEBUG_GRAPH_SHOW_ALL, "record_helper.dot"); 229 gst_debug_bin_to_dot_file_with_ts(GST_BIN(pipeline), GST_DEBUG_GRAPH_SHOW_ALL, "record_helper.dot");
206 230
207#endif 231#endif
208 232
209 233
210 // load_configuration(); 234 // load_configuration();
211} 235}
@@ -215,7 +239,7 @@ pl_graph(GstElement * pipeline)
215extern gboolean 239extern gboolean
216gnunet_gst_bus_call (GstBus *bus, GstMessage *msg, gpointer data) 240gnunet_gst_bus_call (GstBus *bus, GstMessage *msg, gpointer data)
217{ 241{
218 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 242 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
219 "Bus message\n"); 243 "Bus message\n");
220 switch (GST_MESSAGE_TYPE (msg)) 244 switch (GST_MESSAGE_TYPE (msg))
221 { 245 {
@@ -229,15 +253,15 @@ gnunet_gst_bus_call (GstBus *bus, GstMessage *msg, gpointer data)
229 { 253 {
230 gchar *debug; 254 gchar *debug;
231 GError *error; 255 GError *error;
232 256
233 gst_message_parse_error (msg, &error, &debug); 257 gst_message_parse_error (msg, &error, &debug);
234 g_free (debug); 258 g_free (debug);
235 259
236 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 260 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
237 "Error: %s\n", 261 "Error: %s\n",
238 error->message); 262 error->message);
239 g_error_free (error); 263 g_error_free (error);
240 264
241 exit (10); 265 exit (10);
242 break; 266 break;
243 } 267 }
@@ -253,7 +277,7 @@ gnunet_gst_bus_call (GstBus *bus, GstMessage *msg, gpointer data)
253state_changed_cb (GstBus * bus, GstMessage * msg, GNUNET_gstData * d) 277state_changed_cb (GstBus * bus, GstMessage * msg, GNUNET_gstData * d)
254{ 278{
255 GstState old_state, new_state, pending_state; 279 GstState old_state, new_state, pending_state;
256 280
257 gst_message_parse_state_changed (msg, &old_state, &new_state, 281 gst_message_parse_state_changed (msg, &old_state, &new_state,
258 &pending_state); 282 &pending_state);
259 switch (new_state) 283 switch (new_state)
@@ -349,7 +373,7 @@ feed_buffer_to_gnunet (GNUNET_gstData * d)
349 return OK; 373 return OK;
350 } 374 }
351 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "...pulled!\n"); 375 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "...pulled!\n");
352 376
353 const GstStructure *si; 377 const GstStructure *si;
354 char *si_str; 378 char *si_str;
355 GstCaps *s_caps; 379 GstCaps *s_caps;
@@ -378,7 +402,7 @@ feed_buffer_to_gnunet (GNUNET_gstData * d)
378 } 402 }
379 else 403 else
380 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Got sample with no caps\n"); 404 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Got sample with no caps\n");
381 405
382 b = gst_sample_get_buffer (s); 406 b = gst_sample_get_buffer (s);
383 if (NULL == b || !gst_buffer_map (b, &m, GST_MAP_READ)) 407 if (NULL == b || !gst_buffer_map (b, &m, GST_MAP_READ))
384 { 408 {
@@ -396,7 +420,7 @@ feed_buffer_to_gnunet (GNUNET_gstData * d)
396 msg_size = sizeof (struct AudioMessage) + len; 420 msg_size = sizeof (struct AudioMessage) + len;
397 audio_message.header.size = htons ((uint16_t) msg_size); 421 audio_message.header.size = htons ((uint16_t) msg_size);
398 422
399 423
400 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 424 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
401 "Sending %u bytes of audio data\n", (unsigned int) msg_size); 425 "Sending %u bytes of audio data\n", (unsigned int) msg_size);
402 for (phase = 0; phase < 2; phase++) 426 for (phase = 0; phase < 2; phase++)
@@ -436,10 +460,10 @@ feed_buffer_to_gnunet (GNUNET_gstData * d)
436 return FAIL; 460 return FAIL;
437 } 461 }
438 } 462 }
439 463
440 // if (abort_send) 464 // if (abort_send)
441 // break; 465 // break;
442 466
443 } 467 }
444 gst_buffer_unmap (b, &m); 468 gst_buffer_unmap (b, &m);
445 gst_sample_unref (s); 469 gst_sample_unref (s);
@@ -477,7 +501,7 @@ feed_buffer_to_gst (const char *audio, size_t b_len, GNUNET_gstData * d)
477 switch (flow) 501 switch (flow)
478 { 502 {
479 case GST_FLOW_OK: 503 case GST_FLOW_OK:
480 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 504 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
481 "Fed %u bytes to the pipeline\n", 505 "Fed %u bytes to the pipeline\n",
482 (unsigned int) b_len); 506 (unsigned int) b_len);
483 break; 507 break;
@@ -488,7 +512,7 @@ feed_buffer_to_gst (const char *audio, size_t b_len, GNUNET_gstData * d)
488 break; 512 break;
489 case GST_FLOW_EOS: 513 case GST_FLOW_EOS:
490 /* end of stream */ 514 /* end of stream */
491 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 515 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
492 "EOS\n"); 516 "EOS\n");
493 break; 517 break;
494 default: 518 default:
@@ -523,7 +547,7 @@ gst_element_factory_make_debug( gchar *factoryname, gchar *name)
523 547
524/* 548/*
525 static gboolean 549 static gboolean
526gst_element_link_many_debug(...) 550gst_element_link_many_debug(...)
527{ 551{
528 va_list arguments; 552 va_list arguments;
529 gst_element_link_many(argptr); 553 gst_element_link_many(argptr);
@@ -544,13 +568,13 @@ lf(char * msg)
544 */ 568 */
545static void 569static void
546autoaudiosink_child_added (GstChildProxy *child_proxy, 570autoaudiosink_child_added (GstChildProxy *child_proxy,
547 GObject *object, 571 GObject *object,
548 gchar *name, 572 gchar *name,
549 gpointer user_data) 573 gpointer user_data)
550{ 574{
551 if (GST_IS_AUDIO_BASE_SRC (object)) 575 if (GST_IS_AUDIO_BASE_SRC (object))
552 g_object_set (object, 576 g_object_set (object,
553 "buffer-time", (gint64) BUFFER_TIME, 577 "buffer-time", (gint64) BUFFER_TIME,
554 "latency-time", (gint64) LATENCY_TIME, 578 "latency-time", (gint64) LATENCY_TIME,
555 NULL); 579 NULL);
556} 580}
@@ -569,14 +593,14 @@ GstElement *
569get_pipeline(GstElement *element) 593get_pipeline(GstElement *element)
570{ 594{
571 GstPipeline *p; 595 GstPipeline *p;
572 596
573 p = gst_object_get_parent(element); 597 p = gst_object_get_parent(element);
574 598
575 return p; 599 return p;
576} 600}
577 601
578 static void 602 static void
579decoder_ogg_pad_added (GstElement *element, 603decoder_ogg_pad_added (GstElement *element,
580 GstPad *pad, 604 GstPad *pad,
581 gpointer data) 605 gpointer data)
582{ 606{
@@ -594,7 +618,7 @@ decoder_ogg_pad_added (GstElement *element,
594} 618}
595 619
596int 620int
597gnunet_read (GNUNET_gstData * d) 621gnunet_read (GNUNET_gstData * d)
598{ 622{
599 char readbuf[MAXLINE]; 623 char readbuf[MAXLINE];
600 int ret; 624 int ret;
@@ -614,13 +638,13 @@ gnunet_read (GNUNET_gstData * d)
614 if (0 == ret) 638 if (0 == ret)
615 return FAIL; 639 return FAIL;
616 //#ifdef DEBUG_READ_PURE_OGG 640 //#ifdef DEBUG_READ_PURE_OGG
617 641
618 if (d->pure_ogg) 642 if (d->pure_ogg)
619 { 643 {
620 feed_buffer_to_gst (readbuf, ret, d); 644 feed_buffer_to_gst (readbuf, ret, d);
621 } 645 }
622 else 646 else
623 { 647 {
624 //#endif 648 //#endif
625 GNUNET_SERVER_mst_receive (d->stdin_mst, NULL, 649 GNUNET_SERVER_mst_receive (d->stdin_mst, NULL,
626 readbuf, ret, 650 readbuf, ret,
@@ -651,7 +675,7 @@ stdin_receiver (void *cls,
651 feed_buffer_to_gst ((const char *) &audio[1], b_len, cls); 675 feed_buffer_to_gst ((const char *) &audio[1], b_len, cls);
652 break; 676 break;
653 default: 677 default:
654 printf("No audio message: %u \n ", ntohs(msg->type)); 678 printf("No audio message: %u \n ", ntohs(msg->type));
655 break; 679 break;
656 } 680 }
657 return GNUNET_OK; 681 return GNUNET_OK;
@@ -678,19 +702,19 @@ get_app(GNUNET_gstData *d, int type)
678 "Audio playback starts\n"); 702 "Audio playback starts\n");
679 printf(" creating appsrc \n "); 703 printf(" creating appsrc \n ");
680 //d->audio_message.header.type = htons (GNUNET_MESSAGE_TYPE_CONVERSATION_AUDIO); 704 //d->audio_message.header.type = htons (GNUNET_MESSAGE_TYPE_CONVERSATION_AUDIO);
681 705
682// d->audio_message = GNUNET_malloc (UINT16_MAX); 706// d->audio_message = GNUNET_malloc (UINT16_MAX);
683 // d->audio_message = (AudioMessage*)malloc(sizeof(struct AudioMessage)); 707 // d->audio_message = (AudioMessage*)malloc(sizeof(struct AudioMessage));
684// d->audio_message = GNUNET_malloc(sizeof(struct AudioMessage)); 708// d->audio_message = GNUNET_malloc(sizeof(struct AudioMessage));
685 709
686 710
687 //d->audio_message.header.type = htons (GNUNET_MESSAGE_TYPE_CONVERSATION_AUDIO); 711 //d->audio_message.header.type = htons (GNUNET_MESSAGE_TYPE_CONVERSATION_AUDIO);
688 712
689 713
690 d->stdin_mst = GNUNET_SERVER_mst_create (&stdin_receiver, d); 714 d->stdin_mst = GNUNET_SERVER_mst_create (&stdin_receiver, d);
691 715
692 if ( d->stdin_mst == NULL) 716 if ( d->stdin_mst == NULL)
693 printf("stdin_mst = NULL"); 717 printf("stdin_mst = NULL");
694 718
695 d->appsrc = gst_element_factory_make ("appsrc", "appsrc"); 719 d->appsrc = gst_element_factory_make ("appsrc", "appsrc");
696 720
@@ -714,11 +738,11 @@ get_app(GNUNET_gstData *d, int type)
714 "Audio source starts\n"); 738 "Audio source starts\n");
715 739
716 d->appsink = gst_element_factory_make ("appsink", "appsink"); 740 d->appsink = gst_element_factory_make ("appsink", "appsink");
717 741
718 // Move this out of here! 742 // Move this out of here!
719 d->audio_message = GNUNET_malloc (UINT16_MAX); 743 d->audio_message = GNUNET_malloc (UINT16_MAX);
720 (d->audio_message)->header.type = htons (GNUNET_MESSAGE_TYPE_CONVERSATION_AUDIO); 744 (d->audio_message)->header.type = htons (GNUNET_MESSAGE_TYPE_CONVERSATION_AUDIO);
721 g_object_set (G_OBJECT (d->appsink), "emit-signals", TRUE, "sync", TRUE, NULL); 745 g_object_set (G_OBJECT (d->appsink), "emit-signals", TRUE, "sync", TRUE, NULL);
722 746
723 g_signal_connect (d->appsink, "new-sample", 747 g_signal_connect (d->appsink, "new-sample",
724 G_CALLBACK (on_appsink_new_sample), &d); 748 G_CALLBACK (on_appsink_new_sample), &d);
@@ -759,7 +783,7 @@ get_coder(GNUNET_gstData *d , int type)
759 "payload", G_TYPE_INT, 96, 783 "payload", G_TYPE_INT, 96,
760 "sprop-stereo", G_TYPE_STRING, "0", 784 "sprop-stereo", G_TYPE_STRING, "0",
761 "encoding-params", G_TYPE_STRING, "2", 785 "encoding-params", G_TYPE_STRING, "2",
762 NULL); 786 NULL);
763*/ 787*/
764 rtpcaps = gst_caps_new_simple ("application/x-rtp", 788 rtpcaps = gst_caps_new_simple ("application/x-rtp",
765 "media", G_TYPE_STRING, "audio", 789 "media", G_TYPE_STRING, "audio",
@@ -768,7 +792,7 @@ get_coder(GNUNET_gstData *d , int type)
768 "payload", G_TYPE_INT, 96, 792 "payload", G_TYPE_INT, 96,
769 "sprop-stereo", G_TYPE_STRING, "0", 793 "sprop-stereo", G_TYPE_STRING, "0",
770 "encoding-params", G_TYPE_STRING, "2", 794 "encoding-params", G_TYPE_STRING, "2",
771 NULL); 795 NULL);
772 796
773 797
774 rtpcapsfilter = gst_element_factory_make ("capsfilter", "rtpcapsfilter"); 798 rtpcapsfilter = gst_element_factory_make ("capsfilter", "rtpcapsfilter");
@@ -782,7 +806,7 @@ get_coder(GNUNET_gstData *d , int type)
782 806
783 807
784 if ( type == ENCODER ) 808 if ( type == ENCODER )
785 { 809 {
786 bin = GST_BIN(gst_bin_new("Gnunet audioencoder")); 810 bin = GST_BIN(gst_bin_new("Gnunet audioencoder"));
787 811
788 encoder = gst_element_factory_make ("opusenc", "opus-encoder"); 812 encoder = gst_element_factory_make ("opusenc", "opus-encoder");
@@ -819,7 +843,7 @@ get_coder(GNUNET_gstData *d , int type)
819 srcghostpad = gst_ghost_pad_new ("src", srcpad); 843 srcghostpad = gst_ghost_pad_new ("src", srcpad);
820 844
821 } 845 }
822 if ( type == DECODER ) 846 if ( type == DECODER )
823 { 847 {
824 bin = GST_BIN(gst_bin_new("Gnunet audiodecoder")); 848 bin = GST_BIN(gst_bin_new("Gnunet audiodecoder"));
825 849
@@ -829,7 +853,7 @@ get_coder(GNUNET_gstData *d , int type)
829 853
830 demuxer = gst_element_factory_make ("rtpopusdepay", "ogg-demuxer"); 854 demuxer = gst_element_factory_make ("rtpopusdepay", "ogg-demuxer");
831 jitterbuffer = gst_element_factory_make ("rtpjitterbuffer", "rtpjitterbuffer"); 855 jitterbuffer = gst_element_factory_make ("rtpjitterbuffer", "rtpjitterbuffer");
832 } else { 856 } else {
833 demuxer = gst_element_factory_make ("oggdemux", "ogg-demuxer"); 857 demuxer = gst_element_factory_make ("oggdemux", "ogg-demuxer");
834 } 858 }
835 decoder = gst_element_factory_make ("opusdec", "opus-decoder"); 859 decoder = gst_element_factory_make ("opusdec", "opus-decoder");
@@ -844,9 +868,9 @@ get_coder(GNUNET_gstData *d , int type)
844 } else { 868 } else {
845 gst_bin_add_many( bin, demuxer, decoder, NULL); 869 gst_bin_add_many( bin, demuxer, decoder, NULL);
846 870
847 g_signal_connect (demuxer, 871 g_signal_connect (demuxer,
848 "pad-added", 872 "pad-added",
849 G_CALLBACK (decoder_ogg_pad_added), 873 G_CALLBACK (decoder_ogg_pad_added),
850 decoder); 874 decoder);
851 875
852 sinkpad = gst_element_get_static_pad(demuxer, "sink"); 876 sinkpad = gst_element_get_static_pad(demuxer, "sink");
@@ -866,7 +890,7 @@ get_coder(GNUNET_gstData *d , int type)
866 gst_element_add_pad (GST_ELEMENT(bin), srcghostpad); 890 gst_element_add_pad (GST_ELEMENT(bin), srcghostpad);
867 891
868 892
869 return bin; 893 return bin;
870} 894}
871 extern GstBin * 895 extern GstBin *
872get_audiobin(GNUNET_gstData *d , int type) 896get_audiobin(GNUNET_gstData *d , int type)
@@ -893,7 +917,7 @@ get_audiobin(GNUNET_gstData *d , int type)
893 { 917 {
894 sink = gst_element_factory_make ("autoaudiosink", "audiosink"); 918 sink = gst_element_factory_make ("autoaudiosink", "audiosink");
895 g_signal_connect (sink, "child-added", G_CALLBACK (autoaudiosink_child_added), NULL); 919 g_signal_connect (sink, "child-added", G_CALLBACK (autoaudiosink_child_added), NULL);
896 920
897 } 921 }
898 922
899 if ( d->audiobackend == ALSA ) 923 if ( d->audiobackend == ALSA )
@@ -904,7 +928,7 @@ get_audiobin(GNUNET_gstData *d , int type)
904 if ( d->audiobackend == JACK ) 928 if ( d->audiobackend == JACK )
905 { 929 {
906 sink = gst_element_factory_make ("jackaudiosink", "audiosink"); 930 sink = gst_element_factory_make ("jackaudiosink", "audiosink");
907 931
908 g_object_set (G_OBJECT (sink), "client-name", "gnunet", NULL); 932 g_object_set (G_OBJECT (sink), "client-name", "gnunet", NULL);
909 933
910 if (g_object_class_find_property 934 if (g_object_class_find_property
@@ -925,7 +949,7 @@ get_audiobin(GNUNET_gstData *d , int type)
925 } 949 }
926 950
927 g_object_set (sink, 951 g_object_set (sink,
928 "buffer-time", (gint64) BUFFER_TIME, 952 "buffer-time", (gint64) BUFFER_TIME,
929 "latency-time", (gint64) LATENCY_TIME, 953 "latency-time", (gint64) LATENCY_TIME,
930 NULL); 954 NULL);
931 955
@@ -983,7 +1007,7 @@ get_audiobin(GNUNET_gstData *d , int type)
983 1007
984 if ( d->dropsilence == TRUE ) 1008 if ( d->dropsilence == TRUE )
985 { 1009 {
986 gst_bin_add_many (bin , queue ,removesilence , NULL); 1010 gst_bin_add_many (bin , queue ,removesilence , NULL);
987 1011
988 if ( !gst_element_link_many ( queue, removesilence, conv, NULL) ) 1012 if ( !gst_element_link_many ( queue, removesilence, conv, NULL) )
989 lf ("queue, removesilence, conv "); 1013 lf ("queue, removesilence, conv ");
@@ -995,10 +1019,10 @@ get_audiobin(GNUNET_gstData *d , int type)
995 pad = gst_element_get_static_pad(conv, "sink"); 1019 pad = gst_element_get_static_pad(conv, "sink");
996 1020
997 } 1021 }
998 1022
999 ghostpad = gst_ghost_pad_new ("sink", pad); 1023 ghostpad = gst_ghost_pad_new ("sink", pad);
1000 1024
1001 } else { 1025 } else {
1002 // SOURCE 1026 // SOURCE
1003 1027
1004 bin = GST_BIN(gst_bin_new("Gnunet audiosource")); 1028 bin = GST_BIN(gst_bin_new("Gnunet audiosource"));
@@ -1028,7 +1052,7 @@ get_audiobin(GNUNET_gstData *d , int type)
1028 1052
1029 if (d->audiobackend == AUTO ) { 1053 if (d->audiobackend == AUTO ) {
1030 g_signal_connect (source, "child-added", G_CALLBACK (autoaudiosource_child_added), NULL); 1054 g_signal_connect (source, "child-added", G_CALLBACK (autoaudiosource_child_added), NULL);
1031 1055
1032 } else { 1056 } else {
1033 if (GST_IS_AUDIO_BASE_SRC (source)) 1057 if (GST_IS_AUDIO_BASE_SRC (source))
1034 g_object_set (source, "buffer-time", (gint64) BUFFER_TIME, "latency-time", (gint64) LATENCY_TIME, NULL); 1058 g_object_set (source, "buffer-time", (gint64) BUFFER_TIME, "latency-time", (gint64) LATENCY_TIME, NULL);
@@ -1039,7 +1063,7 @@ get_audiobin(GNUNET_gstData *d , int type)
1039 { 1063 {
1040 1064
1041 char *portpattern = "moc"; 1065 char *portpattern = "moc";
1042 1066
1043 g_object_set (G_OBJECT (source), "port-pattern", portpattern, 1067 g_object_set (G_OBJECT (source), "port-pattern", portpattern,
1044 NULL); 1068 NULL);
1045 } 1069 }
diff --git a/src/conversation/gnunet_gst.h b/src/conversation/gnunet_gst.h
index 5a7213f48..266a0d892 100644
--- a/src/conversation/gnunet_gst.h
+++ b/src/conversation/gnunet_gst.h
@@ -1,3 +1,28 @@
1/*
2 This file is part of GNUnet.
3 Copyright (C) 2016 GNUnet e.V.
4
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 3, or (at your
8 option) any later version.
9
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 General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
19*/
20/**
21 * @file conversation/gnunet_gst.c
22 * @brief FIXME
23 * @author Hark
24 */
25
1// which audiobackend we use 26// which audiobackend we use
2// 27//
3 28
@@ -34,4 +59,3 @@ gg_load_configuration (GNUNET_gstData * d);
34 59
35extern GstFlowReturn 60extern GstFlowReturn
36on_appsink_new_sample (GstElement *, GNUNET_gstData *); 61on_appsink_new_sample (GstElement *, GNUNET_gstData *);
37
diff --git a/src/conversation/gnunet_gst_def.h b/src/conversation/gnunet_gst_def.h
index 2e6903db4..9f519b564 100644
--- a/src/conversation/gnunet_gst_def.h
+++ b/src/conversation/gnunet_gst_def.h
@@ -1,21 +1,46 @@
1/*
2 This file is part of GNUnet.
3 Copyright (C) 2016 GNUnet e.V.
4
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 3, or (at your
8 option) any later version.
9
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 General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
19*/
20/**
21 * @file conversation/gnunet_gst_def.h
22 * @brief FIXME
23 * @author Hark
24 */
25
1#include <getopt.h> 26#include <getopt.h>
2#include <string.h> 27#include <string.h>
3#include <stdio.h> 28#include <stdio.h>
4#include <ctype.h> 29#include <ctype.h>
5#include <stdlib.h> 30#include <stdlib.h>
6#include <unistd.h> 31#include <unistd.h>
7#include <time.h> 32#include <time.h>
8#include <regex.h> 33#include <regex.h>
9 34
10 35
11#include "gnunet/platform.h" 36#include "platform.h"
12#include "gnunet/gnunet_util_lib.h" 37#include "gnunet_util_lib.h"
13#include "gnunet/gnunet_protocols.h" 38#include "gnunet_protocols.h"
14//#include "gnunet/conversation.h" doesn't get installed 39//#include "gnunet/conversation.h" doesn't get installed
15#include "conversation.h" 40#include "conversation.h"
16#include "gnunet/gnunet_constants.h" 41#include "gnunet_constants.h"
17#include "gnunet/gnunet_core_service.h" 42#include "gnunet_core_service.h"
18#include "gnunet/gnunet_common.h" 43#include "gnunet_common.h"
19 44
20/* 45/*
21#include <gst/gst.h> 46#include <gst/gst.h>
@@ -70,7 +95,7 @@ struct GNUNET_gstData {
70 GstElement *appsrc; 95 GstElement *appsrc;
71 GstElement *appsink; 96 GstElement *appsink;
72 //settings 97 //settings
73 int audiobackend; 98 int audiobackend;
74 int dropsilence; 99 int dropsilence;
75 int usertp; 100 int usertp;
76 int pure_ogg; 101 int pure_ogg;
diff --git a/src/conversation/gnunet_gst_test.c b/src/conversation/gnunet_gst_test.c
index 3e1454c5b..2ea007583 100644
--- a/src/conversation/gnunet_gst_test.c
+++ b/src/conversation/gnunet_gst_test.c
@@ -1,3 +1,28 @@
1/*
2 This file is part of GNUnet.
3 Copyright (C) 2016 GNUnet e.V.
4
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 3, or (at your
8 option) any later version.
9
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 General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
19*/
20/**
21 * @file conversation/gnunet_gst.c
22 * @brief FIXME
23 * @author Hark
24 */
25
1#include "gnunet_gst_def.h" 26#include "gnunet_gst_def.h"
2#include "gnunet_gst.h" 27#include "gnunet_gst.h"
3 28
@@ -15,7 +40,7 @@ main (int argc, char *argv[])
15 //audio_message->header.type = htons (GNUNET_MESSAGE_TYPE_CONVERSATION_AUDIO); 40 //audio_message->header.type = htons (GNUNET_MESSAGE_TYPE_CONVERSATION_AUDIO);
16 41
17 42
18 //GstPipeline *pipeline; 43 //GstPipeline *pipeline;
19 44
20 gst = (GNUNET_gstData*)malloc(sizeof(struct GNUNET_gstData)); 45 gst = (GNUNET_gstData*)malloc(sizeof(struct GNUNET_gstData));
21 46
@@ -30,7 +55,7 @@ main (int argc, char *argv[])
30 */ 55 */
31 /* Initialize GStreamer */ 56 /* Initialize GStreamer */
32 gst_init (&argc, &argv); 57 gst_init (&argc, &argv);
33 58
34 gst->pipeline = GST_PIPELINE(gst_pipeline_new ("gnunet-media-helper")); 59 gst->pipeline = GST_PIPELINE(gst_pipeline_new ("gnunet-media-helper"));
35 60
36#ifdef IS_SPEAKER 61#ifdef IS_SPEAKER
@@ -45,22 +70,22 @@ main (int argc, char *argv[])
45 if ( type == SPEAKER) 70 if ( type == SPEAKER)
46 { 71 {
47 72
48 gnunetsrc = GST_ELEMENT(get_app(gst, SOURCE)); 73 gnunetsrc = GST_ELEMENT(get_app(gst, SOURCE));
49 74
50 sink = GST_ELEMENT(get_audiobin(gst, SINK)); 75 sink = GST_ELEMENT(get_audiobin(gst, SINK));
51 decoder = GST_ELEMENT(get_coder(gst, DECODER)); 76 decoder = GST_ELEMENT(get_coder(gst, DECODER));
52 gst_bin_add_many( GST_BIN(gst->pipeline), gnunetsrc, decoder, sink, NULL); 77 gst_bin_add_many( GST_BIN(gst->pipeline), gnunetsrc, decoder, sink, NULL);
53 gst_element_link_many( gnunetsrc, decoder, sink , NULL); 78 gst_element_link_many( gnunetsrc, decoder, sink , NULL);
54 79
55 } 80 }
56 if ( type == MICROPHONE ) { 81 if ( type == MICROPHONE ) {
57 82
58 source = GST_ELEMENT(get_audiobin(gst, SOURCE)); 83 source = GST_ELEMENT(get_audiobin(gst, SOURCE));
59 84
60 encoder = GST_ELEMENT(get_coder(gst, ENCODER)); 85 encoder = GST_ELEMENT(get_coder(gst, ENCODER));
61 86
62 gnunetsink = GST_ELEMENT(get_app(gst, SINK)); 87 gnunetsink = GST_ELEMENT(get_app(gst, SINK));
63 88
64 gst_bin_add_many( GST_BIN(gst->pipeline), source, encoder, gnunetsink, NULL); 89 gst_bin_add_many( GST_BIN(gst->pipeline), source, encoder, gnunetsink, NULL);
65 gst_element_link_many( source, encoder, gnunetsink , NULL); 90 gst_element_link_many( source, encoder, gnunetsink , NULL);
66 91
@@ -70,11 +95,11 @@ main (int argc, char *argv[])
70 gst_bin_add_many( GST_BIN(gst->pipeline), appsource, appsink, source, encoder, decoder, sink, NULL); 95 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); 96 gst_element_link_many( source, encoder, decoder, sink , NULL);
72*/ 97*/
73 pl_graph(gst->pipeline); 98 pl_graph(gst->pipeline);
74 /* Start playing */ 99 /* Start playing */
75 gst_element_set_state (GST_ELEMENT(gst->pipeline), GST_STATE_PLAYING); 100 gst_element_set_state (GST_ELEMENT(gst->pipeline), GST_STATE_PLAYING);
76 101
77 //pl_graph(gst->pipeline); 102 //pl_graph(gst->pipeline);
78 103
79 /* Wait until error or EOS */ 104 /* Wait until error or EOS */
80 //bus = gst_element_get_bus (GST_ELEMENT(gst->pipeline)); 105 //bus = gst_element_get_bus (GST_ELEMENT(gst->pipeline));
@@ -101,7 +126,7 @@ main (int argc, char *argv[])
101 flow = on_appsink_new_sample (gst->appsink, gst); 126 flow = on_appsink_new_sample (gst->appsink, gst);
102 } 127 }
103*/ 128*/
104 } 129 }
105 if ( type == SPEAKER ) 130 if ( type == SPEAKER )
106 { 131 {
107 while ( 1 ) 132 while ( 1 )