gnunet_gst_def.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  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. #if HAVE_NETINET_IN_H
  57. #include <netinet/in.h>
  58. #endif
  59. #include <sys/socket.h>
  60. #include <arpa/inet.h>
  61. #include <netdb.h>
  62. #include <sys/types.h>
  63. #include <fcntl.h>
  64. // glib stuff
  65. // #include <glib.h>
  66. #include <glib-2.0/glib/gprintf.h>
  67. // #include <glib-unix.h>
  68. // static struct AudioMessage *audio_message;
  69. typedef struct GNUNET_gstData GNUNET_gstData;
  70. struct GNUNET_gstData
  71. {
  72. // general
  73. GstPipeline *pipeline;
  74. // things
  75. struct AudioMessage *audio_message;
  76. struct GNUNET_MessageStreamTokenizer *stdin_mst;
  77. GstElement *appsrc;
  78. GstElement *appsink;
  79. // settings
  80. int audiobackend;
  81. int dropsilence;
  82. int usertp;
  83. int pure_ogg;
  84. char *jack_pp_in;
  85. char *jack_pp_out;
  86. };
  87. #define DEBUG_READ_PURE_OGG 1
  88. #define DEBUG_RECORD_PURE_OGG 1
  89. /**
  90. * How much data to read in one go
  91. */
  92. #define MAXLINE 4096
  93. /**
  94. * Max number of microseconds to buffer in audiosink.
  95. * Default is 1000
  96. */
  97. #define BUFFER_TIME 1000
  98. /**
  99. * Min number of microseconds to buffer in audiosink.
  100. * Default is 1000
  101. */
  102. #define LATENCY_TIME 1000
  103. /**
  104. * Number of channels.
  105. * Must be one of the following (from libopusenc documentation):
  106. * 1, 2
  107. */
  108. #define OPUS_CHANNELS 1
  109. /**
  110. * Maximal size of a single opus packet.
  111. */
  112. #define MAX_PAYLOAD_SIZE (1024 / OPUS_CHANNELS)
  113. /**
  114. * Size of a single frame fed to the encoder, in ms.
  115. * Must be one of the following (from libopus documentation):
  116. * 2.5, 5, 10, 20, 40 or 60
  117. */
  118. #define OPUS_FRAME_SIZE 40
  119. /**
  120. * Expected packet loss to prepare for, in percents.
  121. */
  122. #define PACKET_LOSS_PERCENTAGE 1
  123. /**
  124. * Set to 1 to enable forward error correction.
  125. * Set to 0 to disable.
  126. */
  127. #define INBAND_FEC_MODE 1
  128. /**
  129. * Max number of microseconds to buffer in audiosource.
  130. * Default is 200000
  131. */
  132. #define BUFFER_TIME 1000 /* 1ms */
  133. /**
  134. * Min number of microseconds to buffer in audiosource.
  135. * Default is 10000
  136. */
  137. #define LATENCY_TIME 1000 /* 1ms */
  138. /**
  139. * Maximum delay in multiplexing streams, in ns.
  140. * Setting this to 0 forces page flushing, which
  141. * decreases delay, but increases overhead.
  142. */
  143. #define OGG_MAX_DELAY 0
  144. /**
  145. * Maximum delay for sending out a page, in ns.
  146. * Setting this to 0 forces page flushing, which
  147. * decreases delay, but increases overhead.
  148. */
  149. #define OGG_MAX_PAGE_DELAY 0
  150. #define SAMPLING_RATE 48000
  151. enum
  152. {
  153. AUTO,
  154. JACK,
  155. ALSA,
  156. FAKE,
  157. TEST
  158. };
  159. enum
  160. {
  161. SOURCE,
  162. SINK
  163. };
  164. enum
  165. {
  166. ENCODER,
  167. DECODER
  168. };
  169. enum
  170. {
  171. FAIL,
  172. OK
  173. };
  174. enum
  175. {
  176. SPEAKER,
  177. MICROPHONE
  178. };