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>
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.
19
19
* Additional permission under GNU GPL version 3 section 7:
49
49
AudioZrtpSession::AudioZrtpSession(SIPCall &call, const std::string &zidFilename) :
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)
57
55
DEBUG("Setting new RTP session with destination %s:%d",
59
57
audioRtpRecord_.callId_ = call_.getCallId();
62
AudioZrtpSession::~AudioZrtpSession()
61
AudioZrtpSession::getSocketDescriptors() const
64
if (rtpThread_.running_) {
65
rtpThread_.running_ = false;
63
std::vector<long> result;
64
result.push_back(dso->getRecvSocket());
65
result.push_back(cso->getRecvSocket());
71
69
void AudioZrtpSession::initializeZid()
73
71
if (zidFilename_.empty())
74
72
throw ZrtpZidException("zid filename empty");
74
const std::string cache_home(XDG_CACHE_HOME);
76
75
std::string zidCompleteFilename;
78
std::string xdg_config = std::string(HOMEDIR) + DIR_SEPARATOR_STR + ".cache" + DIR_SEPARATOR_STR + PACKAGE + "/" + zidFilename_;
80
DEBUG("xdg_config %s", xdg_config.c_str());
82
if (XDG_CACHE_HOME != NULL) {
83
std::string xdg_env = std::string(XDG_CACHE_HOME) + zidFilename_;
84
DEBUG("xdg_env %s", xdg_env.c_str());
85
(xdg_env.length() > 0) ? zidCompleteFilename = xdg_env : zidCompleteFilename = xdg_config;
87
zidCompleteFilename = xdg_config;
77
if (not cache_home.empty()) {
78
zidCompleteFilename = cache_home + DIR_SEPARATOR_STR + zidFilename_;
80
zidCompleteFilename = fileutils::get_home_dir() + DIR_SEPARATOR_STR +
81
".cache" + DIR_SEPARATOR_STR + PACKAGE +
82
DIR_SEPARATOR_STR + zidFilename_;
90
85
if (initialize(zidCompleteFilename.c_str()) >= 0) {
91
86
setEnableZrtp(true);
122
117
queue_.sendImmediate(timestamp_, getMicDataEncoded(), compSize);
125
AudioZrtpSession::AudioZrtpThread::AudioZrtpThread(AudioZrtpSession &session) : running_(true), zrtpSession_(session)
128
void AudioZrtpSession::AudioZrtpThread::run()
130
// Set recording sampling rate
131
int threadSleep = 20;
133
DEBUG("Entering Audio zrtp thread main loop %s", running_ ? "running" : "not running");
135
TimerPort::setTimer(threadSleep);
139
if (zrtpSession_.hasDTMFPending())
140
zrtpSession_.sendDtmfEvent();
142
zrtpSession_.sendMicData();
144
Thread::sleep(TimerPort::getTimer());
146
TimerPort::incTimer(threadSleep);
149
DEBUG("Leaving audio rtp thread loop");
152
120
int AudioZrtpSession::getIncrementForDTMF() const
157
void AudioZrtpSession::setSessionMedia(AudioCodec &audioCodec)
159
AudioRtpSession::setSessionMedia(audioCodec);
162
int AudioZrtpSession::startRtpThread(AudioCodec &audiocodec)
167
AudioRtpSession::startRtpThread(audiocodec);
168
return startZrtpThread();
125
void AudioZrtpSession::startReceiveThread()
127
ost::SymmetricZRTPSession::start();