fix RPS service: Provide closure for view insertion
[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 /**
19  * @file conversation/gnunet_gst_def.h
20  * @brief FIXME
21  * @author Hark
22  */
23
24 #include <getopt.h>
25 #include <string.h>
26 #include <stdio.h>
27 #include <ctype.h>
28 #include <stdlib.h>
29 #include <unistd.h>
30 #include <time.h>
31 #include <regex.h>
32
33
34 #include "platform.h"
35 #include "gnunet_util_lib.h"
36 #include "gnunet_protocols.h"
37 //#include "gnunet/conversation.h" doesn't get installed
38 #include "conversation.h"
39 #include "gnunet_constants.h"
40 #include "gnunet_core_service.h"
41 #include "gnunet_common.h"
42
43 /*
44 #include <gst/gst.h>
45 #include <gst/audio/gstaudiobasesrc.h>
46 #include <gst/app/gstappsrc.h>
47 */
48
49 /* huh
50 #include <glib-2.0/glib.h>
51
52 #include <gstreamer-1.0/gst/gst.h>
53 #include <gstreamer-1.0/gst/pbutils/pbutils.h>
54 #include <gstreamer-1.0/gst/video/videooverlay.h>
55 #include <gstreamer-1.0/gst/audio/gstaudiobasesrc.h>
56 #include <gstreamer-1.0/gst/app/gstappsrc.h>
57 */
58
59 #include <gst/gst.h>
60 #include <gst/audio/gstaudiobasesrc.h>
61 #include <gst/app/gstappsrc.h>
62 #include <glib.h>
63 #include <gst/app/gstappsink.h>
64
65 // sockets
66 #ifndef MINGW
67 #if HAVE_NETINET_IN_H
68 #include <netinet/in.h>
69 #endif
70 #include <sys/socket.h>
71 #include <arpa/inet.h>
72 #include <netdb.h>
73 #endif
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
88 typedef struct GNUNET_gstData GNUNET_gstData;
89 struct GNUNET_gstData {
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
109
110 #define DEBUG_READ_PURE_OGG 1
111 #define DEBUG_RECORD_PURE_OGG 1
112
113
114 /**
115  * How much data to read in one go
116  */
117 #define MAXLINE 4096
118
119 /**
120  * Max number of microseconds to buffer in audiosink.
121  * Default is 1000
122  */
123 #define BUFFER_TIME 1000
124
125 /**
126  * Min number of microseconds to buffer in audiosink.
127  * Default is 1000
128  */
129 #define LATENCY_TIME 1000
130
131
132 /**
133  * Number of channels.
134  * Must be one of the following (from libopusenc documentation):
135  * 1, 2
136  */
137 #define OPUS_CHANNELS 1
138
139 /**
140  * Maximal size of a single opus packet.
141  */
142 #define MAX_PAYLOAD_SIZE (1024 / OPUS_CHANNELS)
143
144 /**
145  * Size of a single frame fed to the encoder, in ms.
146  * Must be one of the following (from libopus documentation):
147  * 2.5, 5, 10, 20, 40 or 60
148  */
149 #define OPUS_FRAME_SIZE 40
150
151 /**
152  * Expected packet loss to prepare for, in percents.
153  */
154 #define PACKET_LOSS_PERCENTAGE 1
155
156 /**
157  * Set to 1 to enable forward error correction.
158  * Set to 0 to disable.
159  */
160 #define INBAND_FEC_MODE 1
161
162 /**
163  * Max number of microseconds to buffer in audiosource.
164  * Default is 200000
165  */
166 #define BUFFER_TIME 1000 /* 1ms */
167
168 /**
169  * Min number of microseconds to buffer in audiosource.
170  * Default is 10000
171  */
172 #define LATENCY_TIME 1000 /* 1ms */
173
174 /**
175  * Maximum delay in multiplexing streams, in ns.
176  * Setting this to 0 forces page flushing, which
177  * decreases delay, but increases overhead.
178  */
179 #define OGG_MAX_DELAY 0
180
181 /**
182  * Maximum delay for sending out a page, in ns.
183  * Setting this to 0 forces page flushing, which
184  * decreases delay, but increases overhead.
185  */
186 #define OGG_MAX_PAGE_DELAY 0
187
188 #define SAMPLING_RATE 48000
189
190 enum {
191     AUTO,
192     JACK,
193     ALSA,
194     FAKE,
195     TEST
196 };
197
198 enum {
199     SOURCE,
200     SINK
201 };
202
203 enum {
204     ENCODER,
205     DECODER
206 };
207
208 enum {
209     FAIL,
210     OK
211 };
212
213 enum {
214     SPEAKER,
215     MICROPHONE
216 };