~ubuntu-branches/ubuntu/saucy/gnash/saucy-proposed

« back to all changes in this revision

Viewing changes to libmedia/gst/AudioInputGst.cpp

  • Committer: Package Import Robot
  • Author(s): Micah Gersten
  • Date: 2012-03-04 03:19:06 UTC
  • mfrom: (1.1.18) (3.1.24 sid)
  • Revision ID: package-import@ubuntu.com-20120304031906-p6q5rnb0xhgpof7o
Tags: 0.8.10-3ubuntu1
* Merge from Debian testing (FFe: LP: #940876), remaining changes:
  - Use mozilla-flashplugin as the alternative for now
  - Change xulrunner-dev build dep to firefox-dev
* Drop the plugin API porting patch, this has been fixed upstream
  - drop debian/patches*
* Drop the following change as we want Adobe's player to take priority
  if it's installed
  - Set alternative priority to 50 so that it matches Adobe Flash's priority

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
// AudioInputGst.cpp: Audio input processing using Gstreamer.
2
2
// 
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
5
5
// 
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");
98
98
    
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__);
101
101
        return;
102
102
    } else {
103
103
        _audioVect.push_back(new GnashAudio);
114
114
 
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__);
118
118
        return;
119
119
    }
120
120
    probe = GST_PROPERTY_PROBE (element);
121
121
    if ( ! probe ) {
122
 
        log_error("%s: Could not get property probe from pulsesrc element",
 
122
        log_error(_("%s: Could not get property probe from pulsesrc element"),
123
123
            __FUNCTION__);
124
124
        return;
125
125
    }
187
187
 
188
188
    if (devselect < 0 ||
189
189
            (static_cast<size_t>(devselect) >= _audioVect.size())) {
190
 
        log_error("%s: passed an invalid devselect argument", __FUNCTION__);
 
190
        log_error(_("%s: passed an invalid devselect argument"), __FUNCTION__);
191
191
        exit(EXIT_FAILURE);
192
192
    }
193
193
 
217
217
        if (GST_IS_OBJECT(bus)){
218
218
            gst_object_unref (bus);
219
219
        } else {
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"),
221
221
                __FUNCTION__);
222
222
        }
223
223
        //if everything above worked properly, begin probing for values
236
236
            if (GST_IS_OBJECT(pad)) {
237
237
                gst_object_unref (pad);
238
238
            } else {
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"),
240
240
                    __FUNCTION__);
241
241
            }
242
242
            bool ok = checkSupportedFormats(caps);
243
243
            if (ok) {
244
 
                log_error("The input device you selected isn't supported (yet)");
 
244
                log_error(_("The input device you selected isn't supported (yet)"));
245
245
            } else {
246
246
                gst_caps_unref(caps);
247
247
            }
250
250
        if (GST_IS_OBJECT(pipeline)){
251
251
            gst_object_unref (pipeline);
252
252
        } else {
253
 
            log_error("%s: pipeline isn't an object for some reason",
 
253
            log_error(_("%s: pipeline isn't an object for some reason"),
254
254
                __FUNCTION__);
255
255
        }
256
256
    }
267
267
    if (devselect < 0 ||
268
268
            (static_cast<size_t>(devselect) >= _audioVect.size())) {
269
269
 
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);
272
272
    }
273
273
    GnashAudioPrivate *audio = new GnashAudioPrivate;
276
276
        audio->setDeviceName(_audioVect[devselect]->getProductName());
277
277
        _globalAudio = audio;
278
278
    } else {
279
 
        log_error("%s: was passed a NULL pointer", __FUNCTION__);
 
279
        log_error(_("%s: was passed a NULL pointer"), __FUNCTION__);
280
280
    }
281
281
    return audio;
282
282
}
321
321
    audio->_audioSourceBin = gst_parse_bin_from_description(command, TRUE,
322
322
                                &error);
323
323
    if (audio->_audioSourceBin == NULL) {
324
 
        log_error ("%s: Creation of the audioSourceBin failed",
 
324
        log_error(_("%s: Creation of the audioSourceBin failed"),
325
325
            __FUNCTION__);
326
 
        log_error ("the error was %s\n", error->message);
 
326
        log_error(_("the error was %s"), error->message);
327
327
        return false;
328
328
    }
329
329
    g_free(command);
334
334
    result = gst_bin_add(GST_BIN(audio->_audioMainBin),
335
335
            audio->_audioSourceBin);
336
336
    if (!result) {
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"),
338
338
            __FUNCTION__);
339
339
        return false;
340
340
    }
344
344
    result = gst_element_link(audio->_audioSourceBin, tee);
345
345
 
346
346
    if (!result) {
347
 
        log_error("%s: couldn't link up sourcebin and tee", __FUNCTION__);
 
347
        log_error(_("%s: couldn't link up sourcebin and tee"), __FUNCTION__);
348
348
        return false;
349
349
    } 
350
350
    _globalAudio = audio;
377
377
    audio->_audioSourceBin = gst_parse_bin_from_description(command, TRUE,
378
378
                                &error);
379
379
    if (audio->_audioSourceBin == NULL) {
380
 
        log_error ("%s: Creation of the audioSourceBin failed",
 
380
        log_error(_("%s: Creation of the audioSourceBin failed"),
381
381
            __FUNCTION__);
382
 
        log_error ("the error was %s", error->message);
 
382
        log_error(_("the error was %s"), error->message);
383
383
        return false;
384
384
    }
385
385
    g_free(command);
403
403
    
404
404
    ok = audioCreateSourceBin(audio);
405
405
    if (ok != true) {
406
 
        log_error("%s: audioCreateSourceBin failed!", __FUNCTION__);
 
406
        log_error(_("%s: audioCreateSourceBin failed!"), __FUNCTION__);
407
407
        return false;
408
408
    }
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__);
411
411
        return false;
412
412
    }
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__);
415
415
        return false;
416
416
    }
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__);
420
420
        return false;
421
421
    }
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__);
427
427
        return false;
428
428
    }
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__);
432
432
        return false;
433
433
    }
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__);
437
437
        return false;
438
438
    }
439
439
    
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__);
446
446
        return false;
447
447
    }
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__);
456
456
        return false;
457
457
    }
458
458
    gst_element_add_pad (audio->_audioMainBin,
461
461
 
462
462
 
463
463
    if (!ok) {
464
 
        log_error("%s: Unable to create main pipeline", __FUNCTION__);
 
464
        log_error(_("%s: Unable to create main pipeline"), __FUNCTION__);
465
465
        return false;
466
466
    } else {
467
467
        return true;
478
478
    audio->_audioPlaybackBin = gst_bin_new("playbackBin");
479
479
    
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__);
482
482
         return false;
483
483
    }
484
484
    
514
514
    if (padreturn == GST_PAD_LINK_OK) {
515
515
        return true;
516
516
    } else {
517
 
        log_error("something went wrong in the makeSourcePlaybackLink function");
 
517
        log_error(_("something went wrong in the makeSourcePlaybackLink function"));
518
518
        return false;
519
519
    }
520
520
}
537
537
    
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__);
541
541
        return false;
542
542
    } else {
543
543
        state = gst_element_set_state(audio->_audioPlaybackBin, GST_STATE_NULL);
545
545
            //return true;
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"),
549
549
                    __FUNCTION__);
550
550
                return false;
551
551
            } else {
552
552
                return true;
553
553
            }
554
554
        } else {
555
 
            log_error("%s: changing state of audioPlaybackBin failed", __FUNCTION__);
 
555
            log_error(_("%s: changing state of audioPlaybackBin failed"),
 
556
                      __FUNCTION__);
556
557
            return false;
557
558
        }
558
559
    }
575
576
        gst_message_parse_error (msg, &error, &debug);
576
577
        g_free (debug);
577
578
 
578
 
        log_error ("Error: %s\n", error->message);
 
579
        log_error(_("Error: %s"), error->message);
579
580
        g_error_free (error);
580
581
        break;
581
582
    }
595
596
    audio->_audioSaveBin = gst_bin_new ("audioSaveBin");
596
597
    
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__);
599
600
        return false;
600
601
    }
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__);
603
604
        return false;
604
605
    }
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__);
607
608
        return false;
608
609
    }
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__);
611
612
        return false;
612
613
    } else {
613
614
        g_object_set(filesink, "location", "audioOut.ogg", NULL);
626
627
            filesink, NULL);
627
628
 
628
629
    if (!ok) {
629
 
        log_error("%s: Something went wrong in linking", __FUNCTION__);
 
630
        log_error(_("%s: Something went wrong in linking"), __FUNCTION__);
630
631
        return false;
631
632
    }
632
633
 
654
655
    if (padreturn == GST_PAD_LINK_OK) {
655
656
        return true;
656
657
    } else {
657
 
        log_error("something went wrong in the makeAudioSourceSaveLink function");
 
658
        log_error(_("something went wrong in the makeAudioSourceSaveLink function"));
658
659
        return false;
659
660
    }
660
661
}
676
677
    
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__);
680
681
        return false;
681
682
    } else {
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"),
 
688
                          __FUNCTION__);
687
689
                return false;
688
690
            } else {
689
691
                return true;
690
692
            }
691
693
        } else {
692
 
            log_error("%s: audioSaveBin state change failed", __FUNCTION__);
 
694
            log_error(_("%s: audioSaveBin state change failed"), __FUNCTION__);
693
695
            return false;
694
696
        }
695
697
    }
750
752
 
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);
756
758
    } else {
757
759
        //set _name value for actionscript