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