Commit 3bdfb413 authored by Tristan Matthews's avatar Tristan Matthews

* #9641: avoid dynamic memory allocs/raw pointer usage in audio rtp stack

parent c6282441
......@@ -91,7 +91,7 @@ void AudioRtpFactory::initSession()
switch (keyExchangeProtocol_) {
case ZRTP:
rtpSession_ = new AudioZrtpSession(ca_, zidFilename);
rtpSession_ = new AudioZrtpSession(*ca_, zidFilename);
// TODO: be careful with that. The hello hash is computed asynchronously. Maybe it's
// not even available at that point.
if (helloHashEnabled_)
......@@ -99,14 +99,14 @@ void AudioRtpFactory::initSession()
break;
case SDES:
rtpSession_ = new AudioSrtpSession(ca_);
rtpSession_ = new AudioSrtpSession(*ca_);
break;
default:
throw UnsupportedRtpSessionType("Unsupported Rtp Session Exception Type!");
}
} else
rtpSession_ = new AudioSymmetricRtpSession(ca_);
rtpSession_ = new AudioSymmetricRtpSession(*ca_);
}
void AudioRtpFactory::start(AudioCodec* audiocodec)
......@@ -117,7 +117,7 @@ void AudioRtpFactory::start(AudioCodec* audiocodec)
if (keyExchangeProtocol_ == SDES and localContext_ and remoteContext_)
static_cast<AudioSrtpSession *>(rtpSession_)->restoreCryptoContext(localContext_, remoteContext_);
if (rtpSession_->startRtpThread(audiocodec) != 0)
if (rtpSession_->startRtpThread(*audiocodec) != 0)
throw AudioRtpFactoryException("AudioRtpFactory: Error: Failed to start AudioRtpSession thread");
}
......@@ -150,7 +150,7 @@ void AudioRtpFactory::updateSessionMedia(AudioCodec *audiocodec)
if (rtpSession_ == NULL)
throw AudioRtpFactoryException("AudioRtpFactory: Error: rtpSession_ was null when trying to update IP address");
rtpSession_->updateSessionMedia(audiocodec);
rtpSession_->updateSessionMedia(*audiocodec);
}
void AudioRtpFactory::updateDestinationIpAddress()
......
......@@ -67,13 +67,17 @@ AudioRtpRecord::~AudioRtpRecord()
}
AudioRtpRecordHandler::AudioRtpRecordHandler(SIPCall *ca) : audioRtpRecord_(), id_(ca->getCallId()), echoCanceller(ca->getMemoryPool()), gainController(8000, -10.0)
AudioRtpRecordHandler::AudioRtpRecordHandler(SIPCall &call) :
audioRtpRecord_(),
id_(call.getCallId()),
echoCanceller(call.getMemoryPool()),
gainController(8000, -10.0)
{}
AudioRtpRecordHandler::~AudioRtpRecordHandler() {}
void AudioRtpRecordHandler::setRtpMedia(AudioCodec* audioCodec)
void AudioRtpRecordHandler::setRtpMedia(AudioCodec *audioCodec)
{
ost::MutexLock lock(audioRtpRecord_.audioCodecMutex_);
......
......@@ -103,7 +103,7 @@ class AudioRtpRecord {
class AudioRtpRecordHandler {
public:
AudioRtpRecordHandler(SIPCall *);
AudioRtpRecordHandler(SIPCall &);
virtual ~AudioRtpRecordHandler();
/**
......
......@@ -43,9 +43,9 @@
#include "manager.h"
namespace sfl {
AudioRtpSession::AudioRtpSession(SIPCall * sipcall, ost::RTPDataQueue *queue, ost::Thread *thread) :
AudioRtpRecordHandler(sipcall)
, ca_(sipcall)
AudioRtpSession::AudioRtpSession(SIPCall &call, ost::RTPDataQueue &queue, ost::Thread &thread) :
AudioRtpRecordHandler(call)
, call_(call)
, timestamp_(0)
, timestampIncrement_(0)
, queue_(queue)
......@@ -55,16 +55,15 @@ AudioRtpSession::AudioRtpSession(SIPCall * sipcall, ost::RTPDataQueue *queue, os
, timestampCount_(0)
, thread_(thread)
{
assert(ca_);
queue_->setTypeOfService(ost::RTPDataQueue::tosEnhanced);
queue_.setTypeOfService(ost::RTPDataQueue::tosEnhanced);
}
AudioRtpSession::~AudioRtpSession()
{
queue_->disableStack();
queue_.disableStack();
}
void AudioRtpSession::updateSessionMedia(AudioCodec *audioCodec)
void AudioRtpSession::updateSessionMedia(AudioCodec &audioCodec)
{
int lastSamplingRate = audioRtpRecord_.codecSampleRate_;
......@@ -79,9 +78,9 @@ void AudioRtpSession::updateSessionMedia(AudioCodec *audioCodec)
}
void AudioRtpSession::setSessionMedia(AudioCodec *audioCodec)
void AudioRtpSession::setSessionMedia(AudioCodec &audioCodec)
{
setRtpMedia(audioCodec);
setRtpMedia(&audioCodec);
// store codec info locally
int payloadType = getCodecPayloadType();
......@@ -102,14 +101,14 @@ void AudioRtpSession::setSessionMedia(AudioCodec *audioCodec)
if (payloadType == g722PayloadType) {
DEBUG("AudioRtpSession: Setting G722 payload format");
queue_->setPayloadFormat(ost::DynamicPayloadFormat((ost::PayloadType) payloadType, g722RtpClockRate));
queue_.setPayloadFormat(ost::DynamicPayloadFormat((ost::PayloadType) payloadType, g722RtpClockRate));
} else {
if (dynamic) {
DEBUG("AudioRtpSession: Setting dynamic payload format");
queue_->setPayloadFormat(ost::DynamicPayloadFormat((ost::PayloadType) payloadType, smplRate));
queue_.setPayloadFormat(ost::DynamicPayloadFormat((ost::PayloadType) payloadType, smplRate));
} else {
DEBUG("AudioRtpSession: Setting static payload format");
queue_->setPayloadFormat(ost::StaticPayloadFormat((ost::StaticPayloadType) payloadType));
queue_.setPayloadFormat(ost::StaticPayloadFormat((ost::StaticPayloadType) payloadType));
}
}
}
......@@ -138,20 +137,20 @@ void AudioRtpSession::sendDtmfEvent()
processDataEncode();
// change Payload type for DTMF payload
queue_->setPayloadFormat(ost::DynamicPayloadFormat((ost::PayloadType) getDtmfPayloadType(), 8000));
queue_.setPayloadFormat(ost::DynamicPayloadFormat((ost::PayloadType) getDtmfPayloadType(), 8000));
queue_->setMark(true);
queue_->sendImmediate(timestamp_, (const unsigned char *)(&payload), sizeof(payload));
queue_->setMark(false);
queue_.setMark(true);
queue_.sendImmediate(timestamp_, (const unsigned char *)(&payload), sizeof(payload));
queue_.setMark(false);
// get back the payload to audio
queue_->setPayloadFormat(ost::StaticPayloadFormat((ost::StaticPayloadType) getCodecPayloadType()));
queue_.setPayloadFormat(ost::StaticPayloadFormat((ost::StaticPayloadType) getCodecPayloadType()));
}
void AudioRtpSession::receiveSpeakerData()
{
const ost::AppDataUnit* adu = queue_->getData(queue_->getFirstTimestamp());
const ost::AppDataUnit* adu = queue_.getData(queue_.getFirstTimestamp());
if (!adu)
return;
......@@ -179,7 +178,7 @@ void AudioRtpSession::sendMicData()
timestamp_ += timestampIncrement_;
// putData puts the data on RTP queue, sendImmediate bypass this queue
queue_->sendImmediate(timestamp_, getMicDataEncoded(), compSize);
queue_.sendImmediate(timestamp_, getMicDataEncoded(), compSize);
}
......@@ -187,28 +186,28 @@ void AudioRtpSession::setSessionTimeouts()
{
DEBUG("AudioRtpSession: Set session scheduling timeout (%d) and expireTimeout (%d)", sfl::schedulingTimeout, sfl::expireTimeout);
queue_->setSchedulingTimeout(sfl::schedulingTimeout);
queue_->setExpireTimeout(sfl::expireTimeout);
queue_.setSchedulingTimeout(sfl::schedulingTimeout);
queue_.setExpireTimeout(sfl::expireTimeout);
}
void AudioRtpSession::setDestinationIpAddress()
{
// Store remote ip in case we would need to forget current destination
remote_ip_ = ost::InetHostAddress(ca_->getLocalSDP()->getRemoteIP().c_str());
remote_ip_ = ost::InetHostAddress(call_.getLocalSDP()->getRemoteIP().c_str());
if (!remote_ip_) {
WARN("AudioRtpSession: Target IP address (%s) is not correct!",
ca_->getLocalSDP()->getRemoteIP().data());
call_.getLocalSDP()->getRemoteIP().data());
return;
}
// Store remote port in case we would need to forget current destination
remote_port_ = (unsigned short) ca_->getLocalSDP()->getRemoteAudioPort();
remote_port_ = (unsigned short) call_.getLocalSDP()->getRemoteAudioPort();
DEBUG("AudioRtpSession: New remote address for session: %s:%d",
ca_->getLocalSDP()->getRemoteIP().data(), remote_port_);
call_.getLocalSDP()->getRemoteIP().data(), remote_port_);
if (!queue_->addDestination(remote_ip_, remote_port_)) {
if (!queue_.addDestination(remote_ip_, remote_port_)) {
WARN("AudioRtpSession: Can't add new destination to session!");
return;
}
......@@ -221,7 +220,7 @@ void AudioRtpSession::updateDestinationIpAddress()
// Destination address are stored in a list in ccrtp
// This method remove the current destination entry
if (!queue_->forgetDestination(remote_ip_, remote_port_, remote_port_ + 1))
if (!queue_.forgetDestination(remote_ip_, remote_port_, remote_port_ + 1))
DEBUG("AudioRtpSession: Did not remove previous destination");
// new destination is stored in call
......@@ -230,7 +229,7 @@ void AudioRtpSession::updateDestinationIpAddress()
}
int AudioRtpSession::startRtpThread(AudioCodec* audiocodec)
int AudioRtpSession::startRtpThread(AudioCodec &audiocodec)
{
if (isStarted_)
return 0;
......@@ -243,8 +242,8 @@ int AudioRtpSession::startRtpThread(AudioCodec* audiocodec)
initBuffers();
initNoiseSuppress();
queue_->enableStack();
return thread_->start();
queue_.enableStack();
return thread_.start();
}
......
......@@ -31,16 +31,18 @@
* shall include the source code for the parts of OpenSSL used as well
* as that of the covered work.
*/
#ifndef SFL_AUDIO_RTP_SESSION_H_
#define SFL_AUDIO_RTP_SESSION_H_
#ifndef AUDIO_RTP_SESSION_H_
#define AUDIO_RTP_SESSION_H_
#include "audio_rtp_record_handler.h"
#include <audio/codecs/audiocodec.h>
#include <ccrtp/rtp.h>
#include <ccrtp/formats.h>
#include "noncopyable.h"
class SIPCall;
namespace ost {
class Thread;
}
namespace sfl {
......@@ -52,12 +54,12 @@ class AudioRtpSession : public AudioRtpRecordHandler {
* Constructor
* @param sipcall The pointer on the SIP call
*/
AudioRtpSession(SIPCall* sipcall, ost::RTPDataQueue *queue, ost::Thread *thread);
AudioRtpSession(SIPCall &sipcall, ost::RTPDataQueue &queue, ost::Thread &thread);
virtual ~AudioRtpSession();
void updateSessionMedia(AudioCodec *audioCodec);
void updateSessionMedia(AudioCodec &audioCodec);
virtual int startRtpThread(AudioCodec*);
virtual int startRtpThread(AudioCodec&);
/**
* Used mostly when receiving a reinvite
......@@ -68,7 +70,7 @@ class AudioRtpSession : public AudioRtpRecordHandler {
/**
* Set the audio codec for this RTP session
*/
virtual void setSessionMedia(AudioCodec *codec) = 0;
virtual void setSessionMedia(AudioCodec &codec) = 0;
bool onRTPPacketRecv(ost::IncomingRTPPkt&);
......@@ -86,7 +88,7 @@ class AudioRtpSession : public AudioRtpRecordHandler {
*/
virtual void sendMicData();
SIPCall *ca_;
SIPCall &call_;
/**
* Timestamp for this session
......@@ -99,7 +101,7 @@ class AudioRtpSession : public AudioRtpRecordHandler {
*/
int timestampIncrement_;
ost::RTPDataQueue *queue_;
ost::RTPDataQueue &queue_;
bool isStarted_;
private:
......@@ -140,7 +142,7 @@ class AudioRtpSession : public AudioRtpRecordHandler {
*/
short timestampCount_;
ost::Thread *thread_;
ost::Thread &thread_;
};
}
......
......@@ -29,8 +29,6 @@
*/
#include "audio_srtp_session.h"
#include "sip/sipcall.h"
#include <openssl/sha.h>
#include <openssl/hmac.h>
#include <openssl/evp.h>
......@@ -44,8 +42,8 @@
namespace sfl {
AudioSrtpSession::AudioSrtpSession(SIPCall * sipcall) :
AudioSymmetricRtpSession(sipcall),
AudioSrtpSession::AudioSrtpSession(SIPCall &call) :
AudioSymmetricRtpSession(call),
remoteCryptoCtx_(NULL),
localCryptoCtx_(NULL),
localCryptoSuite_(0),
......
......@@ -27,10 +27,9 @@
* shall include the source code for the parts of OpenSSL used as well
* as that of the covered work.
*/
#ifndef __AUDIO_SRTP_SESSION_H__
#define __AUDIO_SRTP_SESSION_H__
#ifndef AUDIO_SRTP_SESSION_H_
#define AUDIO_SRTP_SESSION_H_
#include "audio_rtp_session.h"
#include "audio_symmetric_rtp_session.h"
#include "sip/sdes_negotiator.h"
#include "noncopyable.h"
......@@ -73,7 +72,7 @@ class AudioSrtpSession : public AudioSymmetricRtpSession {
/**
* Constructor for this rtp session
*/
AudioSrtpSession(SIPCall * sipcall);
AudioSrtpSession(SIPCall &call);
/**
* Used to get sdp crypto header to be included in sdp session. This
......@@ -85,7 +84,7 @@ class AudioSrtpSession : public AudioSymmetricRtpSession {
/**
* Set remote crypto header from incoming sdp offer
*/
void setRemoteCryptoInfo(sfl::SdesNegotiator& nego);
void setRemoteCryptoInfo(sfl::SdesNegotiator &nego);
/**
* Init local crypto context for outgoing data
......
......@@ -41,26 +41,26 @@
namespace sfl {
AudioSymmetricRtpSession::AudioSymmetricRtpSession(SIPCall * sipcall) :
AudioSymmetricRtpSession::AudioSymmetricRtpSession(SIPCall &call) :
ost::TimerPort()
, ost::SymmetricRTPSession(ost::InetHostAddress(sipcall->getLocalIp().c_str()), sipcall->getLocalAudioPort())
, AudioRtpSession(sipcall, this, this)
, rtpThread_(new AudioRtpThread(this))
, ost::SymmetricRTPSession(ost::InetHostAddress(call.getLocalIp().c_str()), call.getLocalAudioPort())
, AudioRtpSession(call, *this, *this)
, rtpThread_(*this)
{
DEBUG("AudioSymmetricRtpSession: Setting new RTP session with destination %s:%d", ca_->getLocalIp().c_str(), ca_->getLocalAudioPort());
audioRtpRecord_.callId_ = ca_->getCallId();
DEBUG("AudioSymmetricRtpSession: Setting new RTP session with destination %s:%d", call_.getLocalIp().c_str(), call_.getLocalAudioPort());
audioRtpRecord_.callId_ = call_.getCallId();
}
AudioSymmetricRtpSession::~AudioSymmetricRtpSession()
{
rtpThread_->running_ = false;
delete rtpThread_;
if (rtpThread_.running_) {
rtpThread_.running_ = false;
rtpThread_.join();
}
}
AudioSymmetricRtpSession::AudioRtpThread::AudioRtpThread(AudioSymmetricRtpSession *session) : running_(true), rtpSession_(session)
{
assert(rtpSession_);
}
AudioSymmetricRtpSession::AudioRtpThread::AudioRtpThread(AudioSymmetricRtpSession &session) : running_(true), rtpSession_(session)
{}
void AudioSymmetricRtpSession::AudioRtpThread::run()
{
......@@ -72,10 +72,10 @@ void AudioSymmetricRtpSession::AudioRtpThread::run()
while (running_) {
// Send session
if (rtpSession_->DtmfPending())
rtpSession_->sendDtmfEvent();
if (rtpSession_.DtmfPending())
rtpSession_.sendDtmfEvent();
else
rtpSession_->sendMicData();
rtpSession_.sendMicData();
Thread::sleep(TimerPort::getTimer());
......@@ -85,13 +85,13 @@ void AudioSymmetricRtpSession::AudioRtpThread::run()
DEBUG("AudioRtpThread: Leaving audio rtp thread loop");
}
void AudioSymmetricRtpSession::setSessionMedia(AudioCodec *audioCodec)
void AudioSymmetricRtpSession::setSessionMedia(AudioCodec &audioCodec)
{
AudioRtpSession::setSessionMedia(audioCodec);
ca_->setRecordingSmplRate(getCodecSampleRate());
call_.setRecordingSmplRate(getCodecSampleRate());
}
int AudioSymmetricRtpSession::startRtpThread(AudioCodec* audiocodec)
int AudioSymmetricRtpSession::startRtpThread(AudioCodec &audiocodec)
{
DEBUG("AudioSymmetricRtpSession: Starting main thread");
if (isStarted_)
......
......@@ -56,9 +56,9 @@ class AudioSymmetricRtpSession : public ost::TimerPort, public ost::SymmetricRTP
public:
/**
* Constructor
* @param sipcall The pointer on the SIP call
* @param call The SIP call
*/
AudioSymmetricRtpSession(SIPCall* sipcall);
AudioSymmetricRtpSession(SIPCall &call);
~AudioSymmetricRtpSession();
virtual bool onRTPPacketRecv(ost::IncomingRTPPkt& pkt) {
......@@ -66,7 +66,7 @@ class AudioSymmetricRtpSession : public ost::TimerPort, public ost::SymmetricRTP
}
int startSymmetricRtpThread() {
return rtpThread_->start();
return rtpThread_.start();
}
private:
......@@ -74,7 +74,7 @@ class AudioSymmetricRtpSession : public ost::TimerPort, public ost::SymmetricRTP
class AudioRtpThread : public ost::Thread, public ost::TimerPort {
public:
AudioRtpThread(AudioSymmetricRtpSession *session);
AudioRtpThread(AudioSymmetricRtpSession &session);
virtual void run();
......@@ -82,12 +82,12 @@ class AudioSymmetricRtpSession : public ost::TimerPort, public ost::SymmetricRTP
private:
NON_COPYABLE(AudioRtpThread);
AudioSymmetricRtpSession *rtpSession_;
AudioSymmetricRtpSession &rtpSession_;
};
void setSessionMedia(AudioCodec *codec);
int startRtpThread(AudioCodec* audiocodec);
void setSessionMedia(AudioCodec &codec);
int startRtpThread(AudioCodec &audiocodec);
AudioRtpThread *rtpThread_;
AudioRtpThread rtpThread_;
};
}
......
......@@ -49,13 +49,13 @@
namespace sfl {
AudioZrtpSession::AudioZrtpSession(SIPCall * sipcall, const std::string& zidFilename) :
AudioRtpSession(sipcall, this, this),
ost::TRTPSessionBase<ost::SymmetricRTPChannel, ost::SymmetricRTPChannel, ost::ZrtpQueue>(ost::InetHostAddress(sipcall->getLocalIp().c_str()),
sipcall->getLocalAudioPort(),
0,
ost::MembershipBookkeeping::defaultMembersHashSize,
ost::defaultApplication()),
AudioZrtpSession::AudioZrtpSession(SIPCall &call, const std::string& zidFilename) :
AudioRtpSession(call, *this, *this),
ost::TRTPSessionBase<ost::SymmetricRTPChannel, ost::SymmetricRTPChannel, ost::ZrtpQueue>(ost::InetHostAddress(call_.getLocalIp().c_str()),
call_.getLocalAudioPort(),
0,
ost::MembershipBookkeeping::defaultMembersHashSize,
ost::defaultApplication()),
zidFilename_(zidFilename)
{
DEBUG("AudioZrtpSession initialized");
......@@ -63,13 +63,14 @@ AudioZrtpSession::AudioZrtpSession(SIPCall * sipcall, const std::string& zidFile
setCancel(cancelDefault);
DEBUG("AudioZrtpSession: Setting new RTP session with destination %s:%d", ca_->getLocalIp().c_str(), ca_->getLocalAudioPort());
DEBUG("AudioZrtpSession: Setting new RTP session with destination %s:%d",
call_.getLocalIp().c_str(), call_.getLocalAudioPort());
}
AudioZrtpSession::~AudioZrtpSession()
{
ost::Thread::terminate();
Manager::instance().getMainBuffer()->unBindAll(ca_->getCallId());
Manager::instance().getMainBuffer()->unBindAll(call_.getCallId());
}
void AudioZrtpSession::final()
......@@ -102,7 +103,7 @@ void AudioZrtpSession::initializeZid()
if (initialize(zidCompleteFilename.c_str()) >= 0) {
DEBUG("Register callbacks");
setEnableZrtp(true);
setUserCallback(new ZrtpSessionCallback(ca_));
setUserCallback(new ZrtpSessionCallback(call_));
return;
}
......@@ -129,17 +130,17 @@ void AudioZrtpSession::sendMicData()
timestamp_ += timestampIncrement_;
// this step is only needed for ZRTP
queue_->putData(timestamp_, getMicDataEncoded(), compSize);
queue_.putData(timestamp_, getMicDataEncoded(), compSize);
// putData puts the data on RTP queue, sendImmediate bypasses this queue
queue_->sendImmediate(timestamp_, getMicDataEncoded(), compSize);
queue_.sendImmediate(timestamp_, getMicDataEncoded(), compSize);
}
void AudioZrtpSession::run()
{
// Set recording sampling rate
ca_->setRecordingSmplRate(getCodecSampleRate());
DEBUG("AudioZrtpSession: Entering mainloop for call %s", ca_->getCallId().c_str());
call_.setRecordingSmplRate(getCodecSampleRate());
DEBUG("AudioZrtpSession: Entering mainloop for call %s", call_.getCallId().c_str());
uint32 timeout = 0;
......@@ -169,7 +170,7 @@ void AudioZrtpSession::run()
setCancel(cancelImmediate);
timerTick();
} else {
if (isPendingData(timeout/1000)) {
if (isPendingData(timeout / 1000)) {
setCancel(cancelDeferred);
if (isActive())
......@@ -181,17 +182,15 @@ void AudioZrtpSession::run()
}
}
DEBUG("AudioZrtpSession: Left main loop for call %s", ca_->getCallId().c_str());
DEBUG("AudioZrtpSession: Left main loop for call %s", call_.getCallId().c_str());
}
void AudioZrtpSession::incrementTimestampForDTMF()
{
timestamp_ += 160;
}
void AudioZrtpSession::setSessionMedia(AudioCodec *audioCodec)
void AudioZrtpSession::setSessionMedia(AudioCodec &audioCodec)
{
AudioRtpSession::setSessionMedia(audioCodec);
}
......
......@@ -47,16 +47,17 @@ class AudioCodec;
namespace sfl {
class ZrtpZidException: public std::runtime_error {
class ZrtpZidException : public std::runtime_error {
public:
ZrtpZidException(const std::string& str = "") :
std::runtime_error("ZRTP ZID initialization failed." + str) {}
};
// class AudioZrtpSession : public ost::TimerPort, public ost::SymmetricZRTPSession, public AudioRtpRecordHandler
class AudioZrtpSession : public AudioRtpSession, protected ost::Thread, public ost::TRTPSessionBase<ost::SymmetricRTPChannel, ost::SymmetricRTPChannel, ost::ZrtpQueue> {
class AudioZrtpSession :
public AudioRtpSession, protected ost::Thread,
public ost::TRTPSessionBase<ost::SymmetricRTPChannel, ost::SymmetricRTPChannel, ost::ZrtpQueue> {
public:
AudioZrtpSession(SIPCall * sipcall, const std::string& zidFilename);
AudioZrtpSession(SIPCall &call, const std::string& zidFilename);
~AudioZrtpSession();
virtual void final();
......@@ -64,7 +65,7 @@ class AudioZrtpSession : public AudioRtpSession, protected ost::Thread, public o
// Thread associated method
virtual void run();
virtual bool onRTPPacketRecv(ost::IncomingRTPPkt& pkt) {
virtual bool onRTPPacketRecv(ost::IncomingRTPPkt &pkt) {
return AudioRtpSession::onRTPPacketRecv(pkt);
}
......@@ -73,7 +74,7 @@ class AudioZrtpSession : public AudioRtpSession, protected ost::Thread, public o
void initializeZid();
std::string zidFilename_;
void incrementTimestampForDTMF();
void setSessionMedia(AudioCodec *codec);
void setSessionMedia(AudioCodec &codec);
};
}
......
......@@ -45,8 +45,8 @@ using namespace ost;
namespace sfl {
ZrtpSessionCallback::ZrtpSessionCallback(SIPCall *sipcall) :
sipcall_(sipcall)
ZrtpSessionCallback::ZrtpSessionCallback(SIPCall &call) :
call_(call)
{
using std::pair;
using std::string;
......@@ -112,21 +112,21 @@ void
ZrtpSessionCallback::secureOn(std::string cipher)
{
DEBUG("Zrtp: Secure mode is on with cipher %s", cipher.c_str());
Manager::instance().getDbusManager()->getCallManager()->secureZrtpOn(sipcall_->getCallId(), cipher);
Manager::instance().getDbusManager()->getCallManager()->secureZrtpOn(call_.getCallId(), cipher);
}
void
ZrtpSessionCallback::secureOff()
{
DEBUG("Zrtp: Secure mode is off");
Manager::instance().getDbusManager()->getCallManager()->secureZrtpOff(sipcall_->getCallId());
Manager::instance().getDbusManager()->getCallManager()->secureZrtpOff(call_.getCallId());
}
void
ZrtpSessionCallback::showSAS(std::string sas, bool verified)
{
DEBUG("Zrtp: SAS is: %s", sas.c_str());
Manager::instance().getDbusManager()->getCallManager()->showSAS(sipcall_->getCallId(), sas, verified);
Manager::instance().getDbusManager()->getCallManager()->showSAS(call_.getCallId(), sas, verified);
}
......@@ -134,7 +134,7 @@ void
ZrtpSessionCallback::zrtpNotSuppOther()
{
DEBUG("Zrtp: Callee does not support ZRTP");
Manager::instance().getDbusManager()->getCallManager()->zrtpNotSuppOther(sipcall_->getCallId());
Manager::instance().getDbusManager()->getCallManager()->zrtpNotSuppOther(call_.getCallId());
}
......@@ -163,13 +163,13 @@ ZrtpSessionCallback::zrtpNegotiationFailed(MessageSeverity severity, int subCode
std::map<int32, std::string>::const_iterator iter = zrtpMap_.find(subCode);
if (iter != zrtpMap_.end()) {
DEBUG("%s", iter->second.c_str());
Manager::instance().getDbusManager()->getCallManager()->zrtpNegotiationFailed(sipcall_->getCallId(), iter->second, "ZRTP");
Manager::instance().getDbusManager()->getCallManager()->zrtpNegotiationFailed(call_.getCallId(), iter->second, "ZRTP");
}
} else {
std::map<int32, std::string>::const_iterator iter = severeMap_.find(subCode);
if (iter != severeMap_.end()) {
DEBUG("%s", iter->second.c_str());
Manager::instance().getDbusManager()->getCallManager()->zrtpNegotiationFailed(sipcall_->getCallId(), iter->second, "severe");
Manager::instance().getDbusManager()->getCallManager()->zrtpNegotiationFailed(call_.getCallId(), iter->second, "severe");
}
}
}
......@@ -178,7 +178,7 @@ void
ZrtpSessionCallback::confirmGoClear()
{
DEBUG("Zrtp: Received go clear message. Until confirmation, ZRTP won't send any data");
Manager::instance().getDbusManager()->getCallManager()->zrtpNotSuppOther(sipcall_->getCallId());
Manager::instance().getDbusManager()->getCallManager()->zrtpNotSuppOther(call_.getCallId());
}
std::map<int32, std::string> ZrtpSessionCallback::infoMap_;
......
......@@ -28,8 +28,8 @@
* as that of the covered work.
*/
#ifndef __ZRTP_SESSION_CALLBACK_H__
#define __ZRTP_SESSION_CALLBACK_H__
#ifndef ZRTP_SESSION_CALLBACK_H_
#define ZRTP_SESSION_CALLBACK_H_
#include <cstddef>
using std::ptrdiff_t;
......@@ -39,7 +39,6 @@ using std::ptrdiff_t;
#include <libzrtpcpp/ZrtpUserCallback.h>
#include <exception>
#include <map>
#include "noncopyable.h"
class SIPCall;
......@@ -47,7 +46,7 @@ namespace sfl {
class ZrtpSessionCallback: public ZrtpUserCallback {
public:
ZrtpSessionCallback(SIPCall *sipcall);
ZrtpSessionCallback(SIPCall &call);
void secureOn(std::string cipher);
void secureOff();
......@@ -58,12 +57,11 @@ class ZrtpSessionCallback: public ZrtpUserCallback {
void confirmGoClear();
private:
NON_COPYABLE(ZrtpSessionCallback);
SIPCall* sipcall_;