summaryrefslogtreecommitdiff
path: root/legacy/emotion/src/modules/gstreamer
diff options
context:
space:
mode:
authorGustavo Sverzut Barbieri <barbieri@gmail.com>2008-09-26 00:02:43 +0000
committerGustavo Sverzut Barbieri <barbieri@gmail.com>2008-09-26 00:02:43 +0000
commit521daa2f9d61744e6365ac544eb3de035f225d0f (patch)
tree089684a3a9bfa9fa459903c6990717f60e7dec7d /legacy/emotion/src/modules/gstreamer
parentd29b7694cb99cfcbf9598976733824bea02fa0b8 (diff)
emotion-gstreamer: Add some refactor, more to come.
SVN revision: 36261
Diffstat (limited to 'legacy/emotion/src/modules/gstreamer')
-rw-r--r--legacy/emotion/src/modules/gstreamer/emotion_gstreamer_pipeline.c211
1 files changed, 129 insertions, 82 deletions
diff --git a/legacy/emotion/src/modules/gstreamer/emotion_gstreamer_pipeline.c b/legacy/emotion/src/modules/gstreamer/emotion_gstreamer_pipeline.c
index 1a921fc7eb..8719615519 100644
--- a/legacy/emotion/src/modules/gstreamer/emotion_gstreamer_pipeline.c
+++ b/legacy/emotion/src/modules/gstreamer/emotion_gstreamer_pipeline.c
@@ -297,6 +297,124 @@ emotion_visualization_element_name_get(Emotion_Vis visualisation)
297 } 297 }
298} 298}
299 299
300static GstElement *
301emotion_visualization_bin_create(Emotion_Gstreamer_Video *ev, int index)
302{
303 const char *vis_name;
304 char buf[64];
305 GstElement *vis, *visbin, *queue, *conv, *cspace, *sink;
306 GstPad *vispad;
307 GstCaps *caps;
308
309 if (ev->vis == EMOTION_VIS_NONE)
310 return NULL;
311
312 vis_name = emotion_visualization_element_name_get(ev->vis);
313 if (!vis_name)
314 return NULL;
315
316 g_snprintf(buf, sizeof(buf), "vis%d", index);
317 vis = gst_element_factory_make(vis_name, buf);
318 if (!vis)
319 return NULL;
320
321 g_snprintf(buf, sizeof(buf), "visbin%d", index);
322 visbin = gst_bin_new(buf);
323
324 queue = gst_element_factory_make("queue", NULL);
325 conv = gst_element_factory_make("audioconvert", NULL);
326 cspace = gst_element_factory_make("ffmpegcolorspace", NULL);
327 g_snprintf(buf, sizeof(buf), "vissink%d", index);
328 sink = gst_element_factory_make("fakesink", buf);
329
330 if ((!visbin) || (!queue) || (!conv) || (!cspace) || (!sink))
331 goto error;
332
333 gst_bin_add_many(GST_BIN(visbin), queue, conv, vis, cspace, sink, NULL);
334 gst_element_link_many(queue, conv, vis, cspace, NULL);
335 caps = gst_caps_new_simple("video/x-raw-rgb",
336 "bpp", G_TYPE_INT, 32,
337 "width", G_TYPE_INT, 320,
338 "height", G_TYPE_INT, 200,
339 NULL);
340 gst_element_link_filtered(cspace, sink, caps);
341
342 vispad = gst_element_get_pad(queue, "sink");
343 gst_element_add_pad(visbin, gst_ghost_pad_new("sink", vispad));
344 gst_object_unref(vispad);
345
346 return visbin;
347
348 error:
349 if (vis)
350 gst_object_unref(vis);
351 if (visbin)
352 gst_object_unref(visbin);
353 if (queue)
354 gst_object_unref(queue);
355 if (conv)
356 gst_object_unref(conv);
357 if (cspace)
358 gst_object_unref(cspace);
359 if (sink)
360 gst_object_unref(sink);
361
362 return NULL;
363}
364
365static GstElement *
366emotion_audio_bin_create(Emotion_Gstreamer_Video *ev, int index)
367{
368 GstElement *audiobin, *queue, *conv, *resample, *volume, *sink;
369 GstPad *audiopad;
370 double vol;
371
372 audiobin = gst_bin_new(NULL);
373 queue = gst_element_factory_make("queue", NULL);
374 conv = gst_element_factory_make("audioconvert", NULL);
375 resample = gst_element_factory_make("audioresample", NULL);
376 volume = gst_element_factory_make("volume", "volume");
377
378 if (index == 1)
379 sink = gst_element_factory_make("autoaudiosink", NULL);
380 else
381 /* XXX hack: use a proper mixer element here */
382 sink = gst_element_factory_make("fakesink", NULL);
383
384 if ((!audiobin) || (!queue) || (!conv) || (!resample) || (!volume) || (!sink))
385 goto error;
386
387 g_object_get(volume, "volume", &vol, NULL);
388 ev->volume = vol;
389
390 gst_bin_add_many(GST_BIN(audiobin),
391 queue, conv, resample, volume, sink, NULL);
392 gst_element_link_many(queue, conv, resample, volume, sink, NULL);
393
394 audiopad = gst_element_get_pad(queue, "sink");
395 gst_element_add_pad(audiobin, gst_ghost_pad_new("sink", audiopad));
396 gst_object_unref(audiopad);
397
398 return audiobin;
399
400 error:
401 if (audiobin)
402 gst_object_unref(audiobin);
403 if (queue)
404 gst_object_unref(queue);
405 if (conv)
406 gst_object_unref(conv);
407 if (resample)
408 gst_object_unref(resample);
409 if (volume)
410 gst_object_unref(volume);
411 if (sink)
412 gst_object_unref(sink);
413
414 return NULL;
415}
416
417
300GstElement * 418GstElement *
301emotion_audio_sink_create(Emotion_Gstreamer_Video *ev, int index) 419emotion_audio_sink_create(Emotion_Gstreamer_Video *ev, int index)
302{ 420{
@@ -308,94 +426,23 @@ emotion_audio_sink_create(Emotion_Gstreamer_Video *ev, int index)
308 GstPad *teepad; 426 GstPad *teepad;
309 GstPad *binpad; 427 GstPad *binpad;
310 428
311 /* audio sink */ 429 audiobin = emotion_audio_bin_create(ev, index);
312 bin = gst_bin_new(NULL); 430 if (!audiobin)
313 if (!bin) return NULL; 431 return NULL;
314 432
315 g_snprintf(buf, 128, "tee%d", index); 433 bin = gst_bin_new(NULL);
316 tee = gst_element_factory_make("tee", buf); 434 if (!bin)
317
318 /* audio part */
319 { 435 {
320 GstElement *queue; 436 gst_object_unref(audiobin);
321 GstElement *conv; 437 return NULL;
322 GstElement *resample;
323 GstElement *volume;
324 GstElement *sink;
325 GstPad *audiopad;
326 double vol;
327
328 audiobin = gst_bin_new(NULL);
329
330 queue = gst_element_factory_make("queue", NULL);
331 conv = gst_element_factory_make("audioconvert", NULL);
332 resample = gst_element_factory_make("audioresample", NULL);
333 volume = gst_element_factory_make("volume", "volume");
334 g_object_get(G_OBJECT(volume), "volume", &vol, NULL);
335 ev->volume = vol / 10.0;
336
337 if (index == 1)
338 sink = gst_element_factory_make("autoaudiosink", NULL);
339 else
340 sink = gst_element_factory_make("fakesink", NULL);
341
342 gst_bin_add_many(GST_BIN(audiobin),
343 queue, conv, resample, volume, sink, NULL);
344 gst_element_link_many(queue, conv, resample, volume, sink, NULL);
345
346 audiopad = gst_element_get_pad(queue, "sink");
347 gst_element_add_pad(audiobin, gst_ghost_pad_new("sink", audiopad));
348 gst_object_unref(audiopad);
349 } 438 }
350 439
351 /* visualisation part */ 440 g_snprintf(buf, 128, "tee%d", index);
352 { 441 tee = gst_element_factory_make("tee", buf);
353 const char *vis_name = emotion_visualization_element_name_get(ev->vis);
354
355 if (vis_name)
356 {
357 GstElement *vis;
358
359 g_snprintf(buf, 128, "vis%d", index);
360 vis = gst_element_factory_make(vis_name, buf);
361 if (vis)
362 {
363 GstElement *queue;
364 GstElement *conv;
365 GstElement *cspace;
366 GstElement *sink;
367 GstPad *vispad;
368 GstCaps *caps;
369 442
370 g_snprintf(buf, 128, "visbin%d", index); 443 visbin = emotion_visualization_bin_create(ev, index);
371 visbin = gst_bin_new(buf);
372
373 queue = gst_element_factory_make("queue", NULL);
374 conv = gst_element_factory_make("audioconvert", NULL);
375 cspace = gst_element_factory_make("ffmpegcolorspace", NULL);
376 g_snprintf(buf, 128, "vissink%d", index);
377 sink = gst_element_factory_make("fakesink", buf);
378
379 gst_bin_add_many(GST_BIN(visbin),
380 queue, conv, vis, cspace, sink, NULL);
381 gst_element_link_many(queue, conv, vis, cspace, NULL);
382 caps = gst_caps_new_simple("video/x-raw-rgb",
383 "bpp", G_TYPE_INT, 32,
384 "width", G_TYPE_INT, 320,
385 "height", G_TYPE_INT, 200,
386 NULL);
387 gst_element_link_filtered(cspace, sink, caps);
388
389 vispad = gst_element_get_pad(queue, "sink");
390 gst_element_add_pad(visbin, gst_ghost_pad_new("sink", vispad));
391 gst_object_unref(vispad);
392 }
393 }
394 }
395 444
396 gst_bin_add_many(GST_BIN(bin), tee, audiobin, NULL); 445 gst_bin_add_many(GST_BIN(bin), tee, audiobin, visbin, NULL);
397 if (visbin)
398 gst_bin_add(GST_BIN(bin), visbin);
399 446
400 binpad = gst_element_get_pad(audiobin, "sink"); 447 binpad = gst_element_get_pad(audiobin, "sink");
401 teepad = gst_element_get_request_pad(tee, "src%d"); 448 teepad = gst_element_get_request_pad(tee, "src%d");