gnunet_gst_def.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. /*
  2. This file is part of GNUnet.
  3. Copyright (C) 2016 GNUnet e.V.
  4. GNUnet is free software: you can redistribute it and/or modify it
  5. under the terms of the GNU Affero General Public License as published
  6. by the Free Software Foundation, either version 3 of the License,
  7. or (at your option) any later version.
  8. GNUnet is distributed in the hope that it will be useful, but
  9. WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Affero General Public License for more details.
  12. You should have received a copy of the GNU Affero General Public License
  13. along with this program. If not, see <http://www.gnu.org/licenses/>.
  14. SPDX-License-Identifier: AGPL3.0-or-later
  15. */
  16. /**
  17. * @file conversation/gnunet_gst_def.h
  18. * @brief FIXME
  19. * @author Hark
  20. */
  21. #include <getopt.h>
  22. #include <string.h>
  23. #include <stdio.h>
  24. #include <ctype.h>
  25. #include <stdlib.h>
  26. #include <unistd.h>
  27. #include <time.h>
  28. #include <regex.h>
  29. #include "platform.h"
  30. #include "gnunet_util_lib.h"
  31. #include "gnunet_protocols.h"
  32. //#include "gnunet/conversation.h" doesn't get installed
  33. #include "conversation.h"
  34. #include "gnunet_constants.h"
  35. #include "gnunet_core_service.h"
  36. #include "gnunet_common.h"
  37. /*
  38. #include <gst/gst.h>
  39. #include <gst/audio/gstaudiobasesrc.h>
  40. #include <gst/app/gstappsrc.h>
  41. */
  42. /* huh
  43. #include <glib-2.0/glib.h>
  44. #include <gstreamer-1.0/gst/gst.h>
  45. #include <gstreamer-1.0/gst/pbutils/pbutils.h>
  46. #include <gstreamer-1.0/gst/video/videooverlay.h>
  47. #include <gstreamer-1.0/gst/audio/gstaudiobasesrc.h>
  48. #include <gstreamer-1.0/gst/app/gstappsrc.h>
  49. */
  50. #include <gst/gst.h>
  51. #include <gst/audio/gstaudiobasesrc.h>
  52. #include <gst/app/gstappsrc.h>
  53. #include <glib.h>
  54. #include <gst/app/gstappsink.h>
  55. // sockets
  56. #ifndef MINGW
  57. #if HAVE_NETINET_IN_H
  58. #include <netinet/in.h>
  59. #endif
  60. #include <sys/socket.h>
  61. #include <arpa/inet.h>
  62. #include <netdb.h>
  63. #endif
  64. #include <sys/types.h>
  65. #include <fcntl.h>
  66. //glib stuff
  67. //#include <glib.h>
  68. #include <glib-2.0/glib/gprintf.h>
  69. //#include <glib-unix.h>
  70. // static struct AudioMessage *audio_message;
  71. typedef struct GNUNET_gstData GNUNET_gstData;
  72. struct GNUNET_gstData {
  73. //general
  74. GstPipeline *pipeline;
  75. // things
  76. struct AudioMessage *audio_message;
  77. struct GNUNET_MessageStreamTokenizer *stdin_mst;
  78. GstElement *appsrc;
  79. GstElement *appsink;
  80. //settings
  81. int audiobackend;
  82. int dropsilence;
  83. int usertp;
  84. int pure_ogg;
  85. char *jack_pp_in;
  86. char *jack_pp_out;
  87. };
  88. #define DEBUG_READ_PURE_OGG 1
  89. #define DEBUG_RECORD_PURE_OGG 1
  90. /**
  91. * How much data to read in one go
  92. */
  93. #define MAXLINE 4096
  94. /**
  95. * Max number of microseconds to buffer in audiosink.
  96. * Default is 1000
  97. */
  98. #define BUFFER_TIME 1000
  99. /**
  100. * Min number of microseconds to buffer in audiosink.
  101. * Default is 1000
  102. */
  103. #define LATENCY_TIME 1000
  104. /**
  105. * Number of channels.
  106. * Must be one of the following (from libopusenc documentation):
  107. * 1, 2
  108. */
  109. #define OPUS_CHANNELS 1
  110. /**
  111. * Maximal size of a single opus packet.
  112. */
  113. #define MAX_PAYLOAD_SIZE (1024 / OPUS_CHANNELS)
  114. /**
  115. * Size of a single frame fed to the encoder, in ms.
  116. * Must be one of the following (from libopus documentation):
  117. * 2.5, 5, 10, 20, 40 or 60
  118. */
  119. #define OPUS_FRAME_SIZE 40
  120. /**
  121. * Expected packet loss to prepare for, in percents.
  122. */
  123. #define PACKET_LOSS_PERCENTAGE 1
  124. /**
  125. * Set to 1 to enable forward error correction.
  126. * Set to 0 to disable.
  127. */
  128. #define INBAND_FEC_MODE 1
  129. /**
  130. * Max number of microseconds to buffer in audiosource.
  131. * Default is 200000
  132. */
  133. #define BUFFER_TIME 1000 /* 1ms */
  134. /**
  135. * Min number of microseconds to buffer in audiosource.
  136. * Default is 10000
  137. */
  138. #define LATENCY_TIME 1000 /* 1ms */
  139. /**
  140. * Maximum delay in multiplexing streams, in ns.
  141. * Setting this to 0 forces page flushing, which
  142. * decreases delay, but increases overhead.
  143. */
  144. #define OGG_MAX_DELAY 0
  145. /**
  146. * Maximum delay for sending out a page, in ns.
  147. * Setting this to 0 forces page flushing, which
  148. * decreases delay, but increases overhead.
  149. */
  150. #define OGG_MAX_PAGE_DELAY 0
  151. #define SAMPLING_RATE 48000
  152. enum {
  153. AUTO,
  154. JACK,
  155. ALSA,
  156. FAKE,
  157. TEST
  158. };
  159. enum {
  160. SOURCE,
  161. SINK
  162. };
  163. enum {
  164. ENCODER,
  165. DECODER
  166. };
  167. enum {
  168. FAIL,
  169. OK
  170. };
  171. enum {
  172. SPEAKER,
  173. MICROPHONE
  174. };