~ubuntu-branches/ubuntu/saucy/mumble/saucy

« back to all changes in this revision

Viewing changes to src/mumble/AudioInput.cpp

  • Committer: Package Import Robot
  • Author(s): Ron Lee
  • Date: 2012-06-04 03:56:35 UTC
  • mfrom: (1.4.9)
  • Revision ID: package-import@ubuntu.com-20120604035635-4m4pqnh80i1i30yw
Tags: 1.2.3-349-g315b5f5-1
* Adopt the package.  Closes: #674719
* Drop the dependency on the celt package.  Closes: #674650
* Add the upstream patch to enable opus support.
* Explicitly disable the bundled libs, don't rely on system lib detection
  doing that as a side-effect.

Show diffs side-by-side

added added

removed removed

Lines of Context:
100
100
 
101
101
        g.iAudioBandwidth = getNetworkBandwidth(iAudioQuality, iAudioFrames);
102
102
 
 
103
#ifdef USE_CELT
103
104
        umtType = MessageHandler::UDPVoiceCELTAlpha;
 
105
#else
 
106
        umtType = MessageHandler::UDPVoiceOpus;
 
107
#endif
104
108
 
 
109
#ifdef USE_CELT
105
110
        cCodec = NULL;
106
111
        ceEncoder = NULL;
 
112
#endif
107
113
 
108
114
        iSampleRate = SAMPLE_RATE;
109
115
        iFrameSize = SAMPLE_RATE / 100;
166
172
                opus_encoder_destroy(opusState);
167
173
#endif
168
174
 
 
175
#ifdef USE_CELT
169
176
        if (ceEncoder) {
170
177
                cCodec->celt_encoder_destroy(ceEncoder);
171
178
        }
 
179
#endif
172
180
 
173
181
        foreach(short *buf, qlEchoFrames)
174
182
                delete [] buf;
610
618
        }
611
619
 
612
620
        if (!useOpus) {
 
621
#ifdef USE_CELT
613
622
                CELTCodec *switchto = NULL;
614
623
                if ((!g.uiSession || (g.s.lmLoopMode == Settings::Local)) && (!g.qmCodecs.isEmpty())) {
615
624
                        // Use latest for local loopback
640
649
                }
641
650
 
642
651
                if (!cCodec)
 
652
#endif
643
653
                        return false;
644
654
        }
645
655
 
647
657
        if (useOpus) {
648
658
                umtType = MessageHandler::UDPVoiceOpus;
649
659
        } else {
 
660
#ifdef USE_CELT
650
661
                if (!g.uiSession) {
651
662
                        umtType = MessageHandler::UDPVoiceCELTAlpha;
652
663
                } else {
659
670
                                qWarning() << "Couldn't find message type for codec version" << v;
660
671
                        }
661
672
                }
 
673
#endif
662
674
        }
663
675
 
664
676
        if (umtType != previousType) {
688
700
 
689
701
int AudioInput::encodeCELTFrame(short *psSource, unsigned char *buffer) {
690
702
        int len = 0;
 
703
#ifdef USE_CELT
691
704
        if (!cCodec)
692
705
                return len;
693
706
 
699
712
        cCodec->celt_encoder_ctl(ceEncoder, CELT_SET_VBR_RATE(iAudioQuality));
700
713
        len = cCodec->encode(ceEncoder, psSource, buffer, qMin(iAudioQuality / (8 * 100), 127));
701
714
        iBitrate = len * 100 * 8;
702
 
 
 
715
#endif
703
716
        return len;
704
717
}
705
718
 
841
854
        if (!selectCodec())
842
855
                return;
843
856
 
 
857
#ifdef USE_CELT
844
858
        if (umtType == MessageHandler::UDPVoiceCELTAlpha || umtType == MessageHandler::UDPVoiceCELTBeta) {
845
859
                len = encodeCELTFrame(psSource, buffer);
846
860
                if (len == 0)
847
861
                        return;
848
862
                ++iBufferedFrames;
849
 
        } else if (umtType == MessageHandler::UDPVoiceOpus) {
 
863
        } else
 
864
#endif
 
865
        if (umtType == MessageHandler::UDPVoiceOpus) {
850
866
                encoded = false;
851
867
                opusBuffer.insert(opusBuffer.end(), psSource, psSource + iFrameSize);
852
868
                ++iBufferedFrames;