gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r36998 - gnunet/src/conversation


From: gnunet
Subject: [GNUnet-SVN] r36998 - gnunet/src/conversation
Date: Sat, 9 Apr 2016 14:08:40 +0200

Author: grothoff
Date: 2016-04-09 14:08:40 +0200 (Sat, 09 Apr 2016)
New Revision: 36998

Modified:
   gnunet/src/conversation/gnunet_gst.c
   gnunet/src/conversation/gnunet_gst.h
   gnunet/src/conversation/gnunet_gst_def.h
   gnunet/src/conversation/gnunet_gst_test.c
Log:
add copyright headers, fix includes

Modified: gnunet/src/conversation/gnunet_gst.c
===================================================================
--- gnunet/src/conversation/gnunet_gst.c        2016-04-08 19:04:01 UTC (rev 
36997)
+++ gnunet/src/conversation/gnunet_gst.c        2016-04-09 12:08:40 UTC (rev 
36998)
@@ -1,3 +1,27 @@
+/*
+  This file is part of GNUnet.
+  Copyright (C) 2016 GNUnet e.V.
+
+  GNUnet is free software; you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as published
+  by the Free Software Foundation; either version 3, or (at your
+  option) any later version.
+
+  GNUnet is distributed in the hope that it will be useful, but
+  WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+  General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with GNUnet; see the file COPYING.  If not, write to the
+  Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+  Boston, MA 02110-1301, USA.
+*/
+/**
+ * @file conversation/gnunet_gst.c
+ * @brief FIXME
+ * @author Hark
+ */
 #include "gnunet_gst_def.h"
 
 /**
@@ -5,7 +29,7 @@
  */
 static struct GNUNET_CONFIGURATION_Handle *cfg;
 
-  void
+void
 dump_buffer(unsigned n, const unsigned char* buf)
 {
   const unsigned char *p, *end;
@@ -68,7 +92,7 @@
   } else if ( audiobackend_string = "TEST" )
   {
     d->audiobackend = TEST;
-  } else 
+  } else
   {
     d->audiobackend = AUTO;
   }
@@ -109,7 +133,7 @@
   {
     ret = write (1, &ptr[off], msg_size - off);
     if (0 >= ret)
-    { 
+    {
       if (-1 == ret)
         GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "write");
 //      quit (2);
@@ -124,10 +148,10 @@
 on_appsink_new_sample (GstElement * element, GNUNET_gstData * d)
 {
   static unsigned long long toff;
- 
+
   //size of message including gnunet header
   size_t msg_size;
- 
+
   GstSample *s;
   GstBuffer *b;
   GstMapInfo map;
@@ -144,7 +168,7 @@
 
   //pull sample from appsink
    s = gst_app_sink_pull_sample (GST_APP_SINK(element));
-   
+
    if (s == NULL)
      return GST_FLOW_OK;
 
@@ -157,20 +181,20 @@
 
 
 
-   gst_buffer_map (b, &map, GST_MAP_READ);   
+   gst_buffer_map (b, &map, GST_MAP_READ);
 
    size_t len;
     len = map.size;
    if (len > UINT16_MAX - sizeof (struct AudioMessage))
-   { 
+   {
      // this should never happen?
      printf("GSTREAMER sample too big! \n");
      exit(20);
      len = UINT16_MAX - sizeof (struct AudioMessage);
    }
-   
+
    msg_size = sizeof (struct AudioMessage) + len;
- 
+
   // copy the data into audio_message
   memcpy (((char *) &(d->audio_message)[1]), map.data, len);
 /*
@@ -205,8 +229,8 @@
   gst_debug_bin_to_dot_file_with_ts(GST_BIN(pipeline), 
GST_DEBUG_GRAPH_SHOW_ALL, "record_helper.dot");
 
 #endif
- 
 
+
   //  load_configuration();
 }
 
@@ -215,7 +239,7 @@
 extern gboolean
 gnunet_gst_bus_call (GstBus *bus, GstMessage *msg, gpointer data)
 {
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
              "Bus message\n");
   switch (GST_MESSAGE_TYPE (msg))
   {
@@ -229,15 +253,15 @@
     {
       gchar  *debug;
       GError *error;
-      
+
       gst_message_parse_error (msg, &error, &debug);
       g_free (debug);
-      
-      GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 
-                 "Error: %s\n", 
+
+      GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                 "Error: %s\n",
                  error->message);
       g_error_free (error);
-      
+
       exit (10);
       break;
     }
@@ -253,7 +277,7 @@
 state_changed_cb (GstBus * bus, GstMessage * msg, GNUNET_gstData * d)
 {
   GstState old_state, new_state, pending_state;
- 
+
   gst_message_parse_state_changed (msg, &old_state, &new_state,
       &pending_state);
   switch (new_state)
@@ -349,7 +373,7 @@
     return OK;
   }
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "...pulled!\n");
-  
+
     const GstStructure *si;
     char *si_str;
     GstCaps *s_caps;
@@ -378,7 +402,7 @@
     }
     else
       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Got sample with no caps\n");
-  
+
   b = gst_sample_get_buffer (s);
   if (NULL == b || !gst_buffer_map (b, &m, GST_MAP_READ))
   {
@@ -396,7 +420,7 @@
   msg_size = sizeof (struct AudioMessage) + len;
   audio_message.header.size = htons ((uint16_t) msg_size);
 
-  
+
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
       "Sending %u bytes of audio data\n", (unsigned int) msg_size);
   for (phase = 0; phase < 2; phase++)
@@ -436,10 +460,10 @@
         return FAIL;
       }
     }
-    
+
  //   if (abort_send)
    //   break;
-      
+
   }
   gst_buffer_unmap (b, &m);
   gst_sample_unref (s);
@@ -477,7 +501,7 @@
   switch (flow)
   {
   case GST_FLOW_OK:
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                "Fed %u bytes to the pipeline\n",
                (unsigned int) b_len);
     break;
@@ -488,7 +512,7 @@
     break;
   case GST_FLOW_EOS:
     /* end of stream */
-    GNUNET_log (GNUNET_ERROR_TYPE_INFO, 
+    GNUNET_log (GNUNET_ERROR_TYPE_INFO,
                "EOS\n");
     break;
   default:
@@ -523,7 +547,7 @@
 
 /*
  static gboolean
-gst_element_link_many_debug(...) 
+gst_element_link_many_debug(...)
 {
   va_list arguments;
   gst_element_link_many(argptr);
@@ -544,13 +568,13 @@
  */
 static void
 autoaudiosink_child_added (GstChildProxy *child_proxy,
-                 GObject *object, 
+                 GObject *object,
                  gchar *name,
                  gpointer user_data)
 {
   if (GST_IS_AUDIO_BASE_SRC (object))
     g_object_set (object,
-                 "buffer-time", (gint64) BUFFER_TIME, 
+                 "buffer-time", (gint64) BUFFER_TIME,
                  "latency-time", (gint64) LATENCY_TIME,
                  NULL);
 }
@@ -569,7 +593,7 @@
 get_pipeline(GstElement *element)
 {
   GstPipeline *p;
-  
+
   p = gst_object_get_parent(element);
 
   return p;
@@ -576,7 +600,7 @@
 }
 
   static void
-decoder_ogg_pad_added (GstElement *element, 
+decoder_ogg_pad_added (GstElement *element,
               GstPad *pad,
               gpointer data)
 {
@@ -594,7 +618,7 @@
 }
 
 int
-gnunet_read (GNUNET_gstData * d) 
+gnunet_read (GNUNET_gstData * d)
 {
   char readbuf[MAXLINE];
   int ret;
@@ -614,13 +638,13 @@
   if (0 == ret)
     return FAIL;
   //#ifdef DEBUG_READ_PURE_OGG
-  
+
      if (d->pure_ogg)
      {
      feed_buffer_to_gst (readbuf, ret, d);
      }
      else
-     { 
+     {
   //#endif
   GNUNET_SERVER_mst_receive (d->stdin_mst, NULL,
       readbuf, ret,
@@ -651,7 +675,7 @@
     feed_buffer_to_gst ((const char *) &audio[1], b_len, cls);
     break;
   default:
-    printf("No audio message: %u \n ", ntohs(msg->type));  
+    printf("No audio message: %u \n ", ntohs(msg->type));
     break;
   }
   return GNUNET_OK;
@@ -678,7 +702,7 @@
           "Audio playback starts\n");
     printf(" creating appsrc \n ");
     //d->audio_message.header.type = htons 
(GNUNET_MESSAGE_TYPE_CONVERSATION_AUDIO);
- 
+
 // d->audio_message = GNUNET_malloc (UINT16_MAX);
  //  d->audio_message = (AudioMessage*)malloc(sizeof(struct AudioMessage));
 //  d->audio_message = GNUNET_malloc(sizeof(struct AudioMessage));
@@ -685,12 +709,12 @@
 
 
  //d->audio_message.header.type = htons 
(GNUNET_MESSAGE_TYPE_CONVERSATION_AUDIO);
- 
 
+
     d->stdin_mst = GNUNET_SERVER_mst_create (&stdin_receiver, d);
-  
+
     if ( d->stdin_mst == NULL)
-     printf("stdin_mst = NULL"); 
+     printf("stdin_mst = NULL");
 
     d->appsrc     = gst_element_factory_make ("appsrc",       "appsrc");
 
@@ -714,11 +738,11 @@
           "Audio source starts\n");
 
     d->appsink     = gst_element_factory_make ("appsink",       "appsink");
-   
+
     // Move this out of here!
     d->audio_message = GNUNET_malloc (UINT16_MAX);
     (d->audio_message)->header.type = htons 
(GNUNET_MESSAGE_TYPE_CONVERSATION_AUDIO);
-    g_object_set (G_OBJECT (d->appsink), "emit-signals", TRUE, "sync", TRUE, 
NULL); 
+    g_object_set (G_OBJECT (d->appsink), "emit-signals", TRUE, "sync", TRUE, 
NULL);
 
     g_signal_connect (d->appsink, "new-sample",
           G_CALLBACK (on_appsink_new_sample), &d);
@@ -759,7 +783,7 @@
           "payload", G_TYPE_INT, 96,
           "sprop-stereo", G_TYPE_STRING, "0",
           "encoding-params", G_TYPE_STRING, "2",
-          NULL); 
+          NULL);
 */
       rtpcaps = gst_caps_new_simple ("application/x-rtp",
           "media", G_TYPE_STRING, "audio",
@@ -768,7 +792,7 @@
           "payload", G_TYPE_INT, 96,
           "sprop-stereo", G_TYPE_STRING, "0",
           "encoding-params", G_TYPE_STRING, "2",
-          NULL); 
+          NULL);
 
 
       rtpcapsfilter  = gst_element_factory_make ("capsfilter",    
"rtpcapsfilter");
@@ -782,7 +806,7 @@
 
 
   if ( type == ENCODER )
-  { 
+  {
     bin = GST_BIN(gst_bin_new("Gnunet audioencoder"));
 
     encoder  = gst_element_factory_make ("opusenc",       "opus-encoder");
@@ -819,7 +843,7 @@
     srcghostpad = gst_ghost_pad_new ("src", srcpad);
 
   }
-  if ( type == DECODER ) 
+  if ( type == DECODER )
   {
      bin = GST_BIN(gst_bin_new("Gnunet audiodecoder"));
 
@@ -829,7 +853,7 @@
 
       demuxer  = gst_element_factory_make ("rtpopusdepay",      "ogg-demuxer");
       jitterbuffer = gst_element_factory_make ("rtpjitterbuffer", 
"rtpjitterbuffer");
-    } else { 
+    } else {
       demuxer  = gst_element_factory_make ("oggdemux",      "ogg-demuxer");
     }
     decoder  = gst_element_factory_make ("opusdec",       "opus-decoder");
@@ -844,9 +868,9 @@
     } else {
       gst_bin_add_many( bin, demuxer, decoder, NULL);
 
-      g_signal_connect (demuxer, 
+      g_signal_connect (demuxer,
           "pad-added",
-          G_CALLBACK (decoder_ogg_pad_added), 
+          G_CALLBACK (decoder_ogg_pad_added),
           decoder);
 
       sinkpad = gst_element_get_static_pad(demuxer, "sink");
@@ -866,7 +890,7 @@
   gst_element_add_pad (GST_ELEMENT(bin), srcghostpad);
 
 
-  return bin; 
+  return bin;
 }
   extern GstBin *
 get_audiobin(GNUNET_gstData *d , int type)
@@ -893,7 +917,7 @@
     {
       sink     = gst_element_factory_make ("autoaudiosink", "audiosink");
       g_signal_connect (sink, "child-added", G_CALLBACK 
(autoaudiosink_child_added), NULL);
-    
+
     }
 
     if ( d->audiobackend == ALSA )
@@ -904,7 +928,7 @@
     if ( d->audiobackend == JACK )
     {
       sink     = gst_element_factory_make ("jackaudiosink", "audiosink");
-      
+
       g_object_set (G_OBJECT (sink), "client-name", "gnunet", NULL);
 
       if (g_object_class_find_property
@@ -925,7 +949,7 @@
     }
 
     g_object_set (sink,
-        "buffer-time", (gint64) BUFFER_TIME, 
+        "buffer-time", (gint64) BUFFER_TIME,
         "latency-time", (gint64) LATENCY_TIME,
         NULL);
 
@@ -983,7 +1007,7 @@
 
     if ( d->dropsilence == TRUE )
     {
-      gst_bin_add_many (bin , queue ,removesilence , NULL); 
+      gst_bin_add_many (bin , queue ,removesilence , NULL);
 
       if ( !gst_element_link_many ( queue, removesilence, conv,  NULL) )
         lf ("queue, removesilence, conv ");
@@ -995,10 +1019,10 @@
       pad = gst_element_get_static_pad(conv, "sink");
 
     }
-    
+
     ghostpad = gst_ghost_pad_new ("sink", pad);
 
-  } else { 
+  } else {
     // SOURCE
 
     bin = GST_BIN(gst_bin_new("Gnunet audiosource"));
@@ -1028,7 +1052,7 @@
 
     if (d->audiobackend == AUTO ) {
             g_signal_connect (source, "child-added", G_CALLBACK 
(autoaudiosource_child_added), NULL);
-    
+
     } else {
       if (GST_IS_AUDIO_BASE_SRC (source))
         g_object_set (source, "buffer-time", (gint64) BUFFER_TIME, 
"latency-time", (gint64) LATENCY_TIME, NULL);
@@ -1039,7 +1063,7 @@
         {
 
           char *portpattern = "moc";
-          
+
           g_object_set (G_OBJECT (source), "port-pattern", portpattern,
               NULL);
         }

Modified: gnunet/src/conversation/gnunet_gst.h
===================================================================
--- gnunet/src/conversation/gnunet_gst.h        2016-04-08 19:04:01 UTC (rev 
36997)
+++ gnunet/src/conversation/gnunet_gst.h        2016-04-09 12:08:40 UTC (rev 
36998)
@@ -1,3 +1,28 @@
+/*
+  This file is part of GNUnet.
+  Copyright (C) 2016 GNUnet e.V.
+
+  GNUnet is free software; you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as published
+  by the Free Software Foundation; either version 3, or (at your
+  option) any later version.
+
+  GNUnet is distributed in the hope that it will be useful, but
+  WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+  General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with GNUnet; see the file COPYING.  If not, write to the
+  Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+  Boston, MA 02110-1301, USA.
+*/
+/**
+ * @file conversation/gnunet_gst.c
+ * @brief FIXME
+ * @author Hark
+ */
+
 // which audiobackend we use
 //
 
@@ -34,4 +59,3 @@
 
 extern GstFlowReturn
 on_appsink_new_sample (GstElement *, GNUNET_gstData *);
-

Modified: gnunet/src/conversation/gnunet_gst_def.h
===================================================================
--- gnunet/src/conversation/gnunet_gst_def.h    2016-04-08 19:04:01 UTC (rev 
36997)
+++ gnunet/src/conversation/gnunet_gst_def.h    2016-04-09 12:08:40 UTC (rev 
36998)
@@ -1,21 +1,46 @@
+/*
+  This file is part of GNUnet.
+  Copyright (C) 2016 GNUnet e.V.
+
+  GNUnet is free software; you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as published
+  by the Free Software Foundation; either version 3, or (at your
+  option) any later version.
+
+  GNUnet is distributed in the hope that it will be useful, but
+  WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+  General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with GNUnet; see the file COPYING.  If not, write to the
+  Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+  Boston, MA 02110-1301, USA.
+*/
+/**
+ * @file conversation/gnunet_gst_def.h
+ * @brief FIXME
+ * @author Hark
+ */
+
 #include <getopt.h>
-#include <string.h> 
+#include <string.h>
 #include <stdio.h>
 #include <ctype.h>
 #include <stdlib.h>
 #include <unistd.h>
 #include <time.h>
-#include <regex.h> 
+#include <regex.h>
 
 
-#include "gnunet/platform.h"
-#include "gnunet/gnunet_util_lib.h"
-#include "gnunet/gnunet_protocols.h"
+#include "platform.h"
+#include "gnunet_util_lib.h"
+#include "gnunet_protocols.h"
 //#include "gnunet/conversation.h" doesn't get installed
 #include "conversation.h"
-#include "gnunet/gnunet_constants.h"
-#include "gnunet/gnunet_core_service.h"
-#include "gnunet/gnunet_common.h"
+#include "gnunet_constants.h"
+#include "gnunet_core_service.h"
+#include "gnunet_common.h"
 
 /*
 #include <gst/gst.h>
@@ -70,7 +95,7 @@
   GstElement *appsrc;
   GstElement *appsink;
   //settings
-  int audiobackend;  
+  int audiobackend;
   int dropsilence;
   int usertp;
   int pure_ogg;

Modified: gnunet/src/conversation/gnunet_gst_test.c
===================================================================
--- gnunet/src/conversation/gnunet_gst_test.c   2016-04-08 19:04:01 UTC (rev 
36997)
+++ gnunet/src/conversation/gnunet_gst_test.c   2016-04-09 12:08:40 UTC (rev 
36998)
@@ -1,3 +1,28 @@
+/*
+  This file is part of GNUnet.
+  Copyright (C) 2016 GNUnet e.V.
+
+  GNUnet is free software; you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as published
+  by the Free Software Foundation; either version 3, or (at your
+  option) any later version.
+
+  GNUnet is distributed in the hope that it will be useful, but
+  WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+  General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with GNUnet; see the file COPYING.  If not, write to the
+  Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+  Boston, MA 02110-1301, USA.
+*/
+/**
+ * @file conversation/gnunet_gst.c
+ * @brief FIXME
+ * @author Hark
+ */
+
 #include "gnunet_gst_def.h"
 #include "gnunet_gst.h"
 
@@ -15,7 +40,7 @@
   //audio_message->header.type = htons 
(GNUNET_MESSAGE_TYPE_CONVERSATION_AUDIO);
 
 
-  //GstPipeline *pipeline; 
+  //GstPipeline *pipeline;
 
   gst = (GNUNET_gstData*)malloc(sizeof(struct GNUNET_gstData));
 
@@ -30,7 +55,7 @@
   */
   /* Initialize GStreamer */
   gst_init (&argc, &argv);
-   
+
   gst->pipeline = GST_PIPELINE(gst_pipeline_new ("gnunet-media-helper"));
 
 #ifdef IS_SPEAKER
@@ -45,7 +70,7 @@
   if ( type == SPEAKER)
   {
 
-    gnunetsrc = GST_ELEMENT(get_app(gst, SOURCE));  
+    gnunetsrc = GST_ELEMENT(get_app(gst, SOURCE));
 
     sink = GST_ELEMENT(get_audiobin(gst, SINK));
     decoder = GST_ELEMENT(get_coder(gst, DECODER));
@@ -52,7 +77,7 @@
     gst_bin_add_many( GST_BIN(gst->pipeline), gnunetsrc, decoder, sink, NULL);
     gst_element_link_many( gnunetsrc, decoder, sink , NULL);
 
-  } 
+  }
   if ( type == MICROPHONE ) {
 
     source = GST_ELEMENT(get_audiobin(gst, SOURCE));
@@ -59,8 +84,8 @@
 
     encoder = GST_ELEMENT(get_coder(gst, ENCODER));
 
-    gnunetsink = GST_ELEMENT(get_app(gst, SINK));  
-  
+    gnunetsink = GST_ELEMENT(get_app(gst, SINK));
+
     gst_bin_add_many( GST_BIN(gst->pipeline), source, encoder, gnunetsink, 
NULL);
     gst_element_link_many( source, encoder, gnunetsink , NULL);
 
@@ -70,12 +95,12 @@
   gst_bin_add_many( GST_BIN(gst->pipeline), appsource, appsink, source, 
encoder, decoder, sink, NULL);
   gst_element_link_many( source, encoder, decoder, sink , NULL);
 */
-  pl_graph(gst->pipeline); 
+  pl_graph(gst->pipeline);
   /* Start playing */
   gst_element_set_state (GST_ELEMENT(gst->pipeline), GST_STATE_PLAYING);
-  
-  //pl_graph(gst->pipeline); 
 
+  //pl_graph(gst->pipeline);
+
   /* Wait until error or EOS */
   //bus = gst_element_get_bus (GST_ELEMENT(gst->pipeline));
   //bus_watch_id = gst_bus_add_watch (bus, gnunet_gst_bus_call, pipeline);
@@ -101,7 +126,7 @@
          flow = on_appsink_new_sample (gst->appsink, gst);
     }
 */
-    } 
+    }
  if ( type == SPEAKER )
  {
    while ( 1 )




reply via email to

[Prev in Thread] Current Thread [Next in Thread]