1
1
// AudioInputGst.cpp: Audio input processing using Gstreamer.
3
// Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010,
4
// 2011 Free Software Foundation, Inc
3
// Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
4
// Free Software Foundation, Inc
6
6
// This program is free software; you can redistribute it and/or modify
7
7
// it under the terms of the GNU General Public License as published by
97
97
element = gst_element_factory_make ("audiotestsrc", "audtestsrc");
99
99
if (element == NULL) {
100
log_error("%s: Could not create audio test source", __FUNCTION__);
100
log_error(_("%s: Could not create audio test source"), __FUNCTION__);
103
103
_audioVect.push_back(new GnashAudio);
115
115
element = gst_element_factory_make ("pulsesrc", "pulsesrc");
116
116
if ( ! element ) {
117
log_error("%s: Could not create pulsesrc element", __FUNCTION__);
117
log_error(_("%s: Could not create pulsesrc element"), __FUNCTION__);
120
120
probe = GST_PROPERTY_PROBE (element);
122
log_error("%s: Could not get property probe from pulsesrc element",
122
log_error(_("%s: Could not get property probe from pulsesrc element"),
217
217
if (GST_IS_OBJECT(bus)){
218
218
gst_object_unref (bus);
220
log_error("%s: Pipeline bus isn't an object for some reason",
220
log_error(_("%s: Pipeline bus isn't an object for some reason"),
223
223
//if everything above worked properly, begin probing for values
236
236
if (GST_IS_OBJECT(pad)) {
237
237
gst_object_unref (pad);
239
log_error("%s: Template pad isn't an object for some reason",
239
log_error(_("%s: Template pad isn't an object for some reason"),
242
242
bool ok = checkSupportedFormats(caps);
244
log_error("The input device you selected isn't supported (yet)");
244
log_error(_("The input device you selected isn't supported (yet)"));
246
246
gst_caps_unref(caps);
250
250
if (GST_IS_OBJECT(pipeline)){
251
251
gst_object_unref (pipeline);
253
log_error("%s: pipeline isn't an object for some reason",
253
log_error(_("%s: pipeline isn't an object for some reason"),
267
267
if (devselect < 0 ||
268
268
(static_cast<size_t>(devselect) >= _audioVect.size())) {
270
log_error("%s: Passed a bad devselect value", __FUNCTION__);
270
log_error(_("%s: Passed a bad devselect value"), __FUNCTION__);
271
271
exit (EXIT_FAILURE);
273
273
GnashAudioPrivate *audio = new GnashAudioPrivate;
321
321
audio->_audioSourceBin = gst_parse_bin_from_description(command, TRUE,
323
323
if (audio->_audioSourceBin == NULL) {
324
log_error ("%s: Creation of the audioSourceBin failed",
324
log_error(_("%s: Creation of the audioSourceBin failed"),
326
log_error ("the error was %s\n", error->message);
326
log_error(_("the error was %s"), error->message);
334
334
result = gst_bin_add(GST_BIN(audio->_audioMainBin),
335
335
audio->_audioSourceBin);
337
log_error("%s: couldn't drop the sourcebin back into the main bin",
337
log_error(_("%s: couldn't drop the sourcebin back into the main bin"),
344
344
result = gst_element_link(audio->_audioSourceBin, tee);
347
log_error("%s: couldn't link up sourcebin and tee", __FUNCTION__);
347
log_error(_("%s: couldn't link up sourcebin and tee"), __FUNCTION__);
350
350
_globalAudio = audio;
377
377
audio->_audioSourceBin = gst_parse_bin_from_description(command, TRUE,
379
379
if (audio->_audioSourceBin == NULL) {
380
log_error ("%s: Creation of the audioSourceBin failed",
380
log_error(_("%s: Creation of the audioSourceBin failed"),
382
log_error ("the error was %s", error->message);
382
log_error(_("the error was %s"), error->message);
404
404
ok = audioCreateSourceBin(audio);
405
405
if (ok != true) {
406
log_error("%s: audioCreateSourceBin failed!", __FUNCTION__);
406
log_error(_("%s: audioCreateSourceBin failed!"), __FUNCTION__);
409
409
if ((tee = gst_element_factory_make ("tee", "tee")) == NULL) {
410
log_error("%s: problem creating tee element", __FUNCTION__);
410
log_error(_("%s: problem creating tee element"), __FUNCTION__);
413
413
if ((saveQueue = gst_element_factory_make("queue", "saveQueue")) == NULL) {
414
log_error("%s: problem creating save_queue element", __FUNCTION__);
414
log_error(_("%s: problem creating save_queue element"), __FUNCTION__);
417
417
if ((audioPlaybackQueue =
418
418
gst_element_factory_make("queue", "audioPlaybackQueue")) == NULL) {
419
log_error("%s: problem creating audioPlaybackQueue element", __FUNCTION__);
419
log_error(_("%s: problem creating audioPlaybackQueue element"), __FUNCTION__);
422
422
gst_bin_add_many (GST_BIN (audio->_audioMainBin), audio->_audioSourceBin,
423
423
tee, saveQueue, audioPlaybackQueue, NULL);
424
424
ok = gst_element_link(audio->_audioSourceBin, tee);
425
425
if (ok != true) {
426
log_error("%s: couldn't link audioSourceBin and tee", __FUNCTION__);
426
log_error(_("%s: couldn't link audioSourceBin and tee"), __FUNCTION__);
429
429
ok &= gst_element_link_many (tee, saveQueue, NULL);
430
430
if (ok != true) {
431
log_error("%s: couldn't link tee and saveQueue", __FUNCTION__);
431
log_error(_("%s: couldn't link tee and saveQueue"), __FUNCTION__);
434
434
ok &= gst_element_link_many (tee, audioPlaybackQueue, NULL);
435
435
if (ok != true) {
436
log_error("%s: couldn't link tee and audioPlaybackQueue", __FUNCTION__);
436
log_error(_("%s: couldn't link tee and audioPlaybackQueue"), __FUNCTION__);
442
442
//add ghostpad to saveQueue (allows connections between bins)
443
443
pad = gst_element_get_pad (saveQueue, "src");
444
444
if (pad == NULL) {
445
log_error("%s: couldn't get saveQueueSrcPad", __FUNCTION__);
445
log_error(_("%s: couldn't get saveQueueSrcPad"), __FUNCTION__);
448
448
gst_element_add_pad (audio->_audioMainBin,
452
452
//add ghostpad to video_display_queue
453
453
pad = gst_element_get_pad (audioPlaybackQueue, "src");
454
454
if (pad == NULL) {
455
log_error("%s: couldn't get audioPlaybackQueue", __FUNCTION__);
455
log_error(_("%s: couldn't get audioPlaybackQueue"), __FUNCTION__);
458
458
gst_element_add_pad (audio->_audioMainBin,
478
478
audio->_audioPlaybackBin = gst_bin_new("playbackBin");
480
480
if ((autosink = gst_element_factory_make ("autoaudiosink", "audiosink")) == NULL) {
481
log_error("%s: There was a problem making the audiosink!", __FUNCTION__);
481
log_error(_("%s: There was a problem making the audiosink!"), __FUNCTION__);
538
538
ok = gst_pad_unlink(audioPlaybackQueueSrc, audioPlaybackBinSink);
539
539
if (ok != true) {
540
log_error("%s: unlink failed", __FUNCTION__);
540
log_error(_("%s: unlink failed"), __FUNCTION__);
543
543
state = gst_element_set_state(audio->_audioPlaybackBin, GST_STATE_NULL);
546
546
ok = gst_bin_remove(GST_BIN(audio->_pipeline), audio->_audioPlaybackBin);
547
547
if (ok != true) {
548
log_error("%s: couldn't remove audioPlaybackBin from pipeline",
548
log_error(_("%s: couldn't remove audioPlaybackBin from pipeline"),
555
log_error("%s: changing state of audioPlaybackBin failed", __FUNCTION__);
555
log_error(_("%s: changing state of audioPlaybackBin failed"),
575
576
gst_message_parse_error (msg, &error, &debug);
578
log_error ("Error: %s\n", error->message);
579
log_error(_("Error: %s"), error->message);
579
580
g_error_free (error);
595
596
audio->_audioSaveBin = gst_bin_new ("audioSaveBin");
597
598
if ((audioConvert = gst_element_factory_make("audioconvert", "audio_convert")) == NULL) {
598
log_error("%s: Couldn't make audioconvert element", __FUNCTION__);
599
log_error(_("%s: Couldn't make audioconvert element"), __FUNCTION__);
601
602
if ((audioEnc = gst_element_factory_make("vorbisenc", "audio_enc")) == NULL){
602
log_error("%s: Couldn't make vorbisenc element", __FUNCTION__);
603
log_error(_("%s: Couldn't make vorbisenc element"), __FUNCTION__);
605
606
if ((audio->_mux = gst_element_factory_make("oggmux", "mux")) == NULL) {
606
log_error("%s: Couldn't make oggmux element", __FUNCTION__);
607
log_error(_("%s: Couldn't make oggmux element"), __FUNCTION__);
609
610
if ((filesink = gst_element_factory_make("filesink", "filesink")) == NULL) {
610
log_error("%s: Couldn't make filesink element", __FUNCTION__);
611
log_error(_("%s: Couldn't make filesink element"), __FUNCTION__);
613
614
g_object_set(filesink, "location", "audioOut.ogg", NULL);
677
678
ok = gst_pad_unlink(audioSaveQueueSrc, audioSaveBinSink);
678
679
if (ok != true) {
679
log_error("%s: unlink failed", __FUNCTION__);
680
log_error(_("%s: unlink failed"), __FUNCTION__);
682
683
state = gst_element_set_state(audio->_audioSaveBin, GST_STATE_NULL);
683
684
if (state != GST_STATE_CHANGE_FAILURE) {
684
685
ok = gst_bin_remove(GST_BIN(audio->_pipeline), audio->_audioSaveBin);
685
686
if (ok != true) {
686
log_error("%s: couldn't remove saveBin from pipeline", __FUNCTION__);
687
log_error(_("%s: couldn't remove saveBin from pipeline"),
692
log_error("%s: audioSaveBin state change failed", __FUNCTION__);
694
log_error(_("%s: audioSaveBin state change failed"), __FUNCTION__);
751
753
if (audioDevice < 0 ||
752
754
static_cast<size_t>(audioDevice) >= _audioVect.size()) {
753
log_error("You have an invalid microphone selected. Check "
754
"your gnashrc file");
755
log_error(_("You have an invalid microphone selected. Check "
756
"your gnashrc file"));
755
757
exit(EXIT_FAILURE);
757
759
//set _name value for actionscript