aboutsummaryrefslogtreecommitdiff
path: root/src/conversation/gnunet-helper-audio-playback-gst.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2017-03-27 17:30:30 +0200
committerChristian Grothoff <christian@grothoff.org>2017-03-27 17:30:30 +0200
commit802f89d2979d3a92228543d42cee6bb8e3e786d1 (patch)
treef5a834b15a072dfb7d3500459f83fae0cfa17846 /src/conversation/gnunet-helper-audio-playback-gst.c
parent7978b76868ba81efaa4b65b47a54ee55cd092382 (diff)
downloadgnunet-802f89d2979d3a92228543d42cee6bb8e3e786d1.tar.gz
gnunet-802f89d2979d3a92228543d42cee6bb8e3e786d1.zip
fix #4974: migrate conversation GST helpers to new MST API
Diffstat (limited to 'src/conversation/gnunet-helper-audio-playback-gst.c')
-rw-r--r--src/conversation/gnunet-helper-audio-playback-gst.c69
1 files changed, 35 insertions, 34 deletions
diff --git a/src/conversation/gnunet-helper-audio-playback-gst.c b/src/conversation/gnunet-helper-audio-playback-gst.c
index 9307cd12e..264b14e76 100644
--- a/src/conversation/gnunet-helper-audio-playback-gst.c
+++ b/src/conversation/gnunet-helper-audio-playback-gst.c
@@ -56,7 +56,7 @@
56/** 56/**
57 * Tokenizer for the data we get from stdin 57 * Tokenizer for the data we get from stdin
58 */ 58 */
59struct GNUNET_SERVER_MessageStreamTokenizer *stdin_mst; 59struct GNUNET_MessageStreamTokenizer *stdin_mst;
60 60
61/** 61/**
62 * Main pipeline. 62 * Main pipeline.
@@ -82,20 +82,20 @@ static int abort_read;
82 82
83static void 83static void
84sink_child_added (GstChildProxy *child_proxy, 84sink_child_added (GstChildProxy *child_proxy,
85 GObject *object, 85 GObject *object,
86 gchar *name, 86 gchar *name,
87 gpointer user_data) 87 gpointer user_data)
88{ 88{
89 if (GST_IS_AUDIO_BASE_SRC (object)) 89 if (GST_IS_AUDIO_BASE_SRC (object))
90 g_object_set (object, 90 g_object_set (object,
91 "buffer-time", (gint64) BUFFER_TIME, 91 "buffer-time", (gint64) BUFFER_TIME,
92 "latency-time", (gint64) LATENCY_TIME, 92 "latency-time", (gint64) LATENCY_TIME,
93 NULL); 93 NULL);
94} 94}
95 95
96 96
97static void 97static void
98ogg_pad_added (GstElement *element, 98ogg_pad_added (GstElement *element,
99 GstPad *pad, 99 GstPad *pad,
100 gpointer data) 100 gpointer data)
101{ 101{
@@ -127,7 +127,7 @@ quit ()
127static gboolean 127static gboolean
128bus_call (GstBus *bus, GstMessage *msg, gpointer data) 128bus_call (GstBus *bus, GstMessage *msg, gpointer data)
129{ 129{
130 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 130 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
131 "Bus message\n"); 131 "Bus message\n");
132 switch (GST_MESSAGE_TYPE (msg)) 132 switch (GST_MESSAGE_TYPE (msg))
133 { 133 {
@@ -141,15 +141,15 @@ bus_call (GstBus *bus, GstMessage *msg, gpointer data)
141 { 141 {
142 gchar *debug; 142 gchar *debug;
143 GError *error; 143 GError *error;
144 144
145 gst_message_parse_error (msg, &error, &debug); 145 gst_message_parse_error (msg, &error, &debug);
146 g_free (debug); 146 g_free (debug);
147 147
148 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 148 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
149 "Error: %s\n", 149 "Error: %s\n",
150 error->message); 150 error->message);
151 g_error_free (error); 151 g_error_free (error);
152 152
153 quit (); 153 quit ();
154 break; 154 break;
155 } 155 }
@@ -196,7 +196,7 @@ feed_buffer_to_gst (const char *audio, size_t b_len)
196 switch (flow) 196 switch (flow)
197 { 197 {
198 case GST_FLOW_OK: 198 case GST_FLOW_OK:
199 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 199 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
200 "Fed %u bytes to the pipeline\n", 200 "Fed %u bytes to the pipeline\n",
201 (unsigned int) b_len); 201 (unsigned int) b_len);
202 break; 202 break;
@@ -207,7 +207,7 @@ feed_buffer_to_gst (const char *audio, size_t b_len)
207 break; 207 break;
208 case GST_FLOW_EOS: 208 case GST_FLOW_EOS:
209 /* end of stream */ 209 /* end of stream */
210 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 210 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
211 "EOS\n"); 211 "EOS\n");
212 break; 212 break;
213 default: 213 default:
@@ -224,7 +224,6 @@ feed_buffer_to_gst (const char *audio, size_t b_len)
224 */ 224 */
225static int 225static int
226stdin_receiver (void *cls, 226stdin_receiver (void *cls,
227 void *client,
228 const struct GNUNET_MessageHeader *msg) 227 const struct GNUNET_MessageHeader *msg)
229{ 228{
230 struct AudioMessage *audio; 229 struct AudioMessage *audio;
@@ -253,21 +252,21 @@ main (int argc, char **argv)
253 uint64_t toff; 252 uint64_t toff;
254 253
255 typedef void (*SignalHandlerPointer) (int); 254 typedef void (*SignalHandlerPointer) (int);
256 255
257 SignalHandlerPointer inthandler, termhandler; 256 SignalHandlerPointer inthandler, termhandler;
258#ifdef DEBUG_READ_PURE_OGG 257#ifdef DEBUG_READ_PURE_OGG
259 int read_pure_ogg = getenv ("GNUNET_READ_PURE_OGG") ? 1 : 0; 258 int read_pure_ogg = getenv ("GNUNET_READ_PURE_OGG") ? 1 : 0;
260#endif 259#endif
261 260
262 inthandler = signal (SIGINT, 261 inthandler = signal (SIGINT,
263 &signalhandler); 262 &signalhandler);
264 termhandler = signal (SIGTERM, 263 termhandler = signal (SIGTERM,
265 &signalhandler); 264 &signalhandler);
266 265
267#ifdef WINDOWS 266#ifdef WINDOWS
268 setmode (0, _O_BINARY); 267 setmode (0, _O_BINARY);
269#endif 268#endif
270 269
271 /* Initialisation */ 270 /* Initialisation */
272 gst_init (&argc, &argv); 271 gst_init (&argc, &argv);
273 272
@@ -275,13 +274,13 @@ main (int argc, char **argv)
275 GNUNET_log_setup ("gnunet-helper-audio-playback-gst", 274 GNUNET_log_setup ("gnunet-helper-audio-playback-gst",
276 "WARNING", 275 "WARNING",
277 NULL)); 276 NULL));
278 277
279 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 278 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
280 "Audio sink starts\n"); 279 "Audio sink starts\n");
281 280
282 stdin_mst = GNUNET_SERVER_mst_create (&stdin_receiver, 281 stdin_mst = GNUNET_MST_create (&stdin_receiver,
283 NULL); 282 NULL);
284 283
285 /* Create gstreamer elements */ 284 /* Create gstreamer elements */
286 pipeline = gst_pipeline_new ("audio-player"); 285 pipeline = gst_pipeline_new ("audio-player");
287 source = gst_element_factory_make ("appsrc", "audio-input"); 286 source = gst_element_factory_make ("appsrc", "audio-input");
@@ -298,13 +297,13 @@ main (int argc, char **argv)
298 return -1; 297 return -1;
299 } 298 }
300 299
301 g_signal_connect (sink, 300 g_signal_connect (sink,
302 "child-added", 301 "child-added",
303 G_CALLBACK (sink_child_added), 302 G_CALLBACK (sink_child_added),
304 NULL); 303 NULL);
305 g_signal_connect (demuxer, 304 g_signal_connect (demuxer,
306 "pad-added", 305 "pad-added",
307 G_CALLBACK (ogg_pad_added), 306 G_CALLBACK (ogg_pad_added),
308 decoder); 307 decoder);
309 308
310 /* Keep a reference to it, we operate on it */ 309 /* Keep a reference to it, we operate on it */
@@ -362,7 +361,7 @@ main (int argc, char **argv)
362 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 361 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
363 "Received %d bytes of audio data (total: %llu)\n", 362 "Received %d bytes of audio data (total: %llu)\n",
364 (int) ret, 363 (int) ret,
365 toff); 364 (unsigned long long) toff);
366 if (0 == ret) 365 if (0 == ret)
367 break; 366 break;
368#ifdef DEBUG_READ_PURE_OGG 367#ifdef DEBUG_READ_PURE_OGG
@@ -372,20 +371,22 @@ main (int argc, char **argv)
372 } 371 }
373 else 372 else
374#endif 373#endif
375 GNUNET_SERVER_mst_receive (stdin_mst, NULL, 374 GNUNET_MST_from_buffer (stdin_mst,
376 readbuf, ret, 375 readbuf,
377 GNUNET_NO, GNUNET_NO); 376 ret,
377 GNUNET_NO,
378 GNUNET_NO);
378 } 379 }
379 GNUNET_SERVER_mst_destroy (stdin_mst); 380 GNUNET_MST_destroy (stdin_mst);
380 381
381 signal (SIGINT, inthandler); 382 signal (SIGINT, inthandler);
382 signal (SIGINT, termhandler); 383 signal (SIGINT, termhandler);
383 384
384 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 385 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
385 "Returned, stopping playback\n"); 386 "Returned, stopping playback\n");
386 quit (); 387 quit ();
387 388
388 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 389 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
389 "Deleting pipeline\n"); 390 "Deleting pipeline\n");
390 gst_object_unref (GST_OBJECT (source)); 391 gst_object_unref (GST_OBJECT (source));
391 source = NULL; 392 source = NULL;