aboutsummaryrefslogtreecommitdiff
path: root/src/conversation/gnunet_gst.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/conversation/gnunet_gst.c')
-rw-r--r--src/conversation/gnunet_gst.c54
1 files changed, 26 insertions, 28 deletions
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;