~ubuntu-branches/debian/sid/sflphone/sid

« back to all changes in this revision

Viewing changes to daemon/src/audio/audiortp/audio_zrtp_session.cpp

  • Committer: Package Import Robot
  • Author(s): Mark Purcell
  • Date: 2013-06-02 18:04:11 UTC
  • mfrom: (1.1.9)
  • Revision ID: package-import@ubuntu.com-20130602180411-3rcpy8c1zdlo8y0s
Tags: 1.2.2-1
* New upstream release
* changeset_rb68857a4b485b7d43f92714cd5792595ff895f82.diff - fix QTest
* pjproject ./configure --disable-sound --disable-video

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 *  Copyright (C) 2004, 2005, 2006, 2008, 2009, 2010, 2011 Savoir-Faire Linux Inc.
 
2
 *  Copyright (C) 2004-2012 Savoir-Faire Linux Inc.
3
3
 *  Author: Alexandre Savard <alexandre.savard@savoirfairelinux.com>
4
4
 *  Author: Pierre-Luc Bacon <pierre-luc.bacon@savoirfairelinux.com>
5
5
 *
14
14
 *
15
15
 *  You should have received a copy of the GNU General Public License
16
16
 *  along with this program; if not, write to the Free Software
17
 
 *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
17
 *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA.
18
18
 *
19
19
 *  Additional permission under GNU GPL version 3 section 7:
20
20
 *
47
47
namespace sfl {
48
48
 
49
49
AudioZrtpSession::AudioZrtpSession(SIPCall &call, const std::string &zidFilename) :
50
 
    ost::TimerPort()
51
 
    , ost::SymmetricZRTPSession(ost::InetHostAddress(call.getLocalIp().c_str()), call.getLocalAudioPort())
52
 
    , AudioRtpSession(call, *this, *this)
 
50
    ost::SymmetricZRTPSession(ost::InetHostAddress(call.getLocalIp().c_str()), call.getLocalAudioPort())
 
51
    , AudioRtpSession(call, *this)
53
52
    , zidFilename_(zidFilename)
54
 
    , rtpThread_(*this)
55
53
{
56
54
    initializeZid();
57
55
    DEBUG("Setting new RTP session with destination %s:%d",
59
57
    audioRtpRecord_.callId_ = call_.getCallId();
60
58
}
61
59
 
62
 
AudioZrtpSession::~AudioZrtpSession()
63
 
{
64
 
    if (rtpThread_.running_) {
65
 
        rtpThread_.running_ = false;
66
 
        rtpThread_.join();
67
 
    }
68
 
}
69
 
 
70
 
 
71
60
void AudioZrtpSession::initializeZid()
72
61
{
73
62
    if (zidFilename_.empty())
122
111
    queue_.sendImmediate(timestamp_, getMicDataEncoded(), compSize);
123
112
}
124
113
 
125
 
AudioZrtpSession::AudioZrtpThread::AudioZrtpThread(AudioZrtpSession &session) : running_(true), zrtpSession_(session)
126
 
{}
127
 
 
128
 
void AudioZrtpSession::AudioZrtpThread::run()
129
 
{
130
 
    // Set recording sampling rate
131
 
    int threadSleep = 20;
132
 
 
133
 
    DEBUG("Entering Audio zrtp thread main loop %s", running_ ? "running" : "not running");
134
 
 
135
 
    TimerPort::setTimer(threadSleep);
136
 
 
137
 
    while (running_) {
138
 
        // Send session
139
 
        if (zrtpSession_.hasDTMFPending())
140
 
            zrtpSession_.sendDtmfEvent();
141
 
        else
142
 
            zrtpSession_.sendMicData();
143
 
 
144
 
        Thread::sleep(TimerPort::getTimer());
145
 
 
146
 
        TimerPort::incTimer(threadSleep);
147
 
    }
148
 
 
149
 
    DEBUG("Leaving audio rtp thread loop");
150
 
}
151
 
 
152
114
int AudioZrtpSession::getIncrementForDTMF() const
153
115
{
154
116
    return 160;
155
117
}
156
118
 
157
 
void AudioZrtpSession::setSessionMedia(AudioCodec &audioCodec)
158
 
{
159
 
    AudioRtpSession::setSessionMedia(audioCodec);
160
 
}
161
 
 
162
 
int AudioZrtpSession::startRtpThread(AudioCodec &audiocodec)
163
 
{
164
 
    if(isStarted_)
165
 
        return 0;
166
 
 
167
 
    AudioRtpSession::startRtpThread(audiocodec);
168
 
    return startZrtpThread();
 
119
void AudioZrtpSession::startReceiveThread()
 
120
{
 
121
    ost::SymmetricZRTPSession::start();
169
122
}
170
123
 
171
124
}