~ubuntu-branches/ubuntu/trusty/sflphone/trusty

« back to all changes in this revision

Viewing changes to daemon/src/audio/audiortp/audio_rtp_record_handler.h

  • Committer: Package Import Robot
  • Author(s): Mark Purcell
  • Date: 2014-01-28 18:23:36 UTC
  • mfrom: (4.3.4 sid)
  • Revision ID: package-import@ubuntu.com-20140128182336-jrsv0k9u6cawc068
Tags: 1.3.0-1
* New upstream release 
  - Fixes "New Upstream Release" (Closes: #735846)
  - Fixes "Ringtone does not stop" (Closes: #727164)
  - Fixes "[sflphone-kde] crash on startup" (Closes: #718178)
  - Fixes "sflphone GUI crashes when call is hung up" (Closes: #736583)
* Build-Depends: ensure GnuTLS 2.6
  - libucommon-dev (>= 6.0.7-1.1), libccrtp-dev (>= 2.0.6-3)
  - Fixes "FTBFS Build-Depends libgnutls{26,28}-dev" (Closes: #722040)
* Fix "boost 1.49 is going away" unversioned Build-Depends: (Closes: #736746)
* Add Build-Depends: libsndfile-dev, nepomuk-core-dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 *  Copyright (C) 2004-2012 Savoir-Faire Linux Inc.
 
2
 *  Copyright (C) 2004-2013 Savoir-Faire Linux Inc.
3
3
 *  Author: Alexandre Savard <alexandre.savard@savoirfairelinux.com>
 
4
 *  Author: Adrien Beraud <adrien.beraud@wisdomvibes.com>
4
5
 *
5
6
 *  This program is free software; you can redistribute it and/or modify
6
7
 *  it under the terms of the GNU General Public License as published by
39
40
using std::ptrdiff_t;
40
41
 
41
42
#include <ccrtp/rtp.h>
42
 
#include <tr1/array>
 
43
#include <array>
43
44
#include <list>
44
 
#include <pthread.h>
 
45
#include <mutex>
 
46
#include <atomic>
45
47
 
46
48
#include "noncopyable.h"
47
49
#include "audio/codecs/audiocodec.h"
48
50
#include "audio/samplerateconverter.h"
49
 
#include "audio/noisesuppress.h"
50
 
#include "audio/gaincontrol.h"
 
51
#include "audio/dsp.h"
51
52
 
52
53
class SIPCall;
53
54
 
88
89
 
89
90
    private:
90
91
        std::vector<AudioCodec*> audioCodecs_;
91
 
        pthread_mutex_t audioCodecMutex_;
 
92
        std::mutex audioCodecMutex_;
92
93
        // these will have the same value unless we are sending
93
94
        // a different codec than we are receiving (asymmetric RTP)
94
95
        int encoderPayloadType_;
95
96
        int decoderPayloadType_;
96
97
        bool hasDynamicPayloadType_;
97
 
        std::tr1::array<SFLDataFormat, DEC_BUFFER_SIZE> decData_;
98
 
// FIXME: resampledData should be resized as needed
99
 
        std::tr1::array<SFLDataFormat, DEC_BUFFER_SIZE * 4> resampledData_;
100
 
        std::tr1::array<unsigned char, DEC_BUFFER_SIZE> encodedData_;
 
98
        AudioBuffer decData_;
 
99
        AudioBuffer resampledData_;
 
100
        std::array<unsigned char, DEC_BUFFER_SIZE> encodedData_;
101
101
        SamplerateConverter *converterEncode_;
102
102
        SamplerateConverter *converterDecode_;
103
103
        int codecFrameSize_;
 
104
        int codecChannels_;
104
105
        int converterSamplingRate_;
105
106
        double fadeFactor_;
106
107
 
107
108
#if HAVE_SPEEXDSP
108
 
        NoiseSuppress *noiseSuppressEncode_;
109
 
        NoiseSuppress *noiseSuppressDecode_;
110
 
        pthread_mutex_t audioProcessMutex_;
 
109
        DSP *dspEncode_;
 
110
        DSP *dspDecode_;
 
111
        std::mutex audioProcessMutex_;
111
112
#endif
112
113
 
113
114
        unsigned int dtmfPayloadType_;
117
118
        /**
118
119
        * Ramp In audio data to avoid audio click from peer
119
120
        */
120
 
        void fadeInDecodedData(size_t size);
 
121
        void fadeInDecodedData();//size_t size);
121
122
        NON_COPYABLE(AudioRtpRecord);
122
 
#ifdef CCPP_PREFIX
123
 
        ost::AtomicCounter dead_;
124
 
#else
125
 
        ucommon::atomic::counter dead_;
126
 
#endif
 
123
        std::atomic<bool> dead_;
127
124
        size_t currentCodecIndex_;
128
125
};
129
126
 
154
151
            return audioRtpRecord_.codecFrameSize_;
155
152
        }
156
153
 
157
 
        bool getHasDynamicPayload() const {
 
154
        int getCodecChannels() const {
 
155
            return audioRtpRecord_.codecChannels_;
 
156
        }
 
157
 
 
158
        bool hasDynamicPayload() const {
158
159
            return audioRtpRecord_.hasDynamicPayloadType_;
159
160
        }
160
161
 
169
170
        void initBuffers();
170
171
 
171
172
#if HAVE_SPEEXDSP
172
 
        void initNoiseSuppress();
 
173
        void initDSP();
173
174
#endif
174
175
 
175
176
        /**
200
201
 
201
202
    private:
202
203
        const std::string id_;
203
 
        GainControl gainController;
204
204
        int warningInterval_;
205
205
};
206
206
}