More API function tests...
[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
6   it under the terms of the GNU General Public License as published
7   by the Free Software Foundation; either version 3, or (at your
8   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   General Public License for more details.
14
15   You should have received a copy of the GNU General Public License
16   along with GNUnet; see the file COPYING.  If not, write to the
17   Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18   Boston, MA 02110-1301, USA.
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 #include <netinet/in.h>
69 #include <sys/socket.h>
70 #include <fcntl.h>
71 #include <arpa/inet.h>
72
73 #include <sys/types.h>
74 #include <sys/socket.h>
75 #include <netdb.h>
76
77
78 //glib stuff
79 //#include <glib.h>
80 #include <glib-2.0/glib/gprintf.h>
81 #include <glib-unix.h>
82
83 // static struct AudioMessage *audio_message;
84
85
86
87 typedef struct GNUNET_gstData GNUNET_gstData;
88 struct GNUNET_gstData {
89   //general
90   GstPipeline *pipeline;
91
92   // things
93   struct AudioMessage *audio_message;
94   struct GNUNET_SERVER_MessageStreamTokenizer *stdin_mst;
95   GstElement *appsrc;
96   GstElement *appsink;
97   //settings
98   int audiobackend;
99   int dropsilence;
100   int usertp;
101   int pure_ogg;
102   char *jack_pp_in;
103   char *jack_pp_out;
104 };
105
106
107
108
109 #define DEBUG_READ_PURE_OGG 1
110 #define DEBUG_RECORD_PURE_OGG 1
111
112
113 /**
114  * How much data to read in one go
115  */
116 #define MAXLINE 4096
117
118 /**
119  * Max number of microseconds to buffer in audiosink.
120  * Default is 1000
121  */
122 #define BUFFER_TIME 1000
123
124 /**
125  * Min number of microseconds to buffer in audiosink.
126  * Default is 1000
127  */
128 #define LATENCY_TIME 1000
129
130
131 /**
132  * Number of channels.
133  * Must be one of the following (from libopusenc documentation):
134  * 1, 2
135  */
136 #define OPUS_CHANNELS 1
137
138 /**
139  * Maximal size of a single opus packet.
140  */
141 #define MAX_PAYLOAD_SIZE (1024 / OPUS_CHANNELS)
142
143 /**
144  * Size of a single frame fed to the encoder, in ms.
145  * Must be one of the following (from libopus documentation):
146  * 2.5, 5, 10, 20, 40 or 60
147  */
148 #define OPUS_FRAME_SIZE 40
149
150 /**
151  * Expected packet loss to prepare for, in percents.
152  */
153 #define PACKET_LOSS_PERCENTAGE 1
154
155 /**
156  * Set to 1 to enable forward error correction.
157  * Set to 0 to disable.
158  */
159 #define INBAND_FEC_MODE 1
160
161 /**
162  * Max number of microseconds to buffer in audiosource.
163  * Default is 200000
164  */
165 #define BUFFER_TIME 1000 /* 1ms */
166
167 /**
168  * Min number of microseconds to buffer in audiosource.
169  * Default is 10000
170  */
171 #define LATENCY_TIME 1000 /* 1ms */
172
173 /**
174  * Maximum delay in multiplexing streams, in ns.
175  * Setting this to 0 forces page flushing, which
176  * decreases delay, but increases overhead.
177  */
178 #define OGG_MAX_DELAY 0
179
180 /**
181  * Maximum delay for sending out a page, in ns.
182  * Setting this to 0 forces page flushing, which
183  * decreases delay, but increases overhead.
184  */
185 #define OGG_MAX_PAGE_DELAY 0
186
187 #define SAMPLING_RATE 48000
188
189 enum {
190     AUTO,
191     JACK,
192     ALSA,
193     FAKE,
194     TEST
195 };
196
197 enum {
198     SOURCE,
199     SINK
200 };
201
202 enum {
203     ENCODER,
204     DECODER
205 };
206
207 enum {
208     FAIL,
209     OK
210 };
211
212 enum {
213     SPEAKER,
214     MICROPHONE
215 };