Commit 908e1fb3 authored by Alexandre Savard's avatar Alexandre Savard
Browse files

#14848: Remove explicite reference to audioCodec->getFrameSize

move transportRate to audioRtpSession instead of audioSymmetricRtpSession
parent fd1583b8
......@@ -45,6 +45,7 @@ AudioRtpSession::AudioRtpSession(SIPCall &call, ost::RTPDataQueue &queue, ost::T
, call_(call)
, timestamp_(0)
, timestampIncrement_(0)
, transportRate_(20)
, queue_(queue)
, isStarted_(false)
, remote_ip_()
......@@ -98,6 +99,12 @@ void AudioRtpSession::setSessionMedia(AudioCodec &audioCodec)
else
queue_.setPayloadFormat(ost::StaticPayloadFormat(static_cast<ost::StaticPayloadType>(payloadType)));
}
call_.setRecordingSmplRate(getCodecSampleRate());
int transportRate = getCodecFrameSize() / (getCodecSampleRate() / 1000);
transportRate_ = (transportRate > 0)?transportRate:20;
DEBUG("Switching to a transport rate of %d ms",transportRate_);
}
void AudioRtpSession::sendDtmfEvent()
......
......@@ -80,7 +80,7 @@ class AudioRtpSession : public AudioRtpRecordHandler {
/**
* Set the audio codec for this RTP session
*/
virtual void setSessionMedia(AudioCodec &codec) = 0;
void setSessionMedia(AudioCodec &codec);
bool onRTPPacketRecv(ost::IncomingRTPPkt&);
......@@ -111,6 +111,12 @@ class AudioRtpSession : public AudioRtpRecordHandler {
*/
int timestampIncrement_;
/**
* Rate at which the transport layer handle packets, should be
* synchronized with codec requirements.
*/
unsigned int transportRate_;
ost::RTPDataQueue &queue_;
bool isStarted_;
......
......@@ -43,7 +43,6 @@ AudioSymmetricRtpSession::AudioSymmetricRtpSession(SIPCall &call) :
, ost::SymmetricRTPSession(ost::InetHostAddress(call.getLocalIp().c_str()), call.getLocalAudioPort())
, AudioRtpSession(call, *this, *this)
, rtpThread_(*this)
, transportRate_(20)
{
DEBUG("Setting new RTP session with destination %s:%d",
call_.getLocalIp().c_str(), call_.getLocalAudioPort());
......@@ -78,16 +77,6 @@ void AudioSymmetricRtpSession::AudioRtpThread::run()
}
}
void AudioSymmetricRtpSession::setSessionMedia(AudioCodec &audioCodec)
{
AudioRtpSession::setSessionMedia(audioCodec);
call_.setRecordingSmplRate(getCodecSampleRate());
int transportRate = audioCodec.getFrameSize() / (audioCodec.getClockRate()/1000);
transportRate_ = (transportRate > 0)?transportRate:20;
DEBUG("Switching to a transport rate of %d ms",transportRate_);
}
int AudioSymmetricRtpSession::startRtpThread(AudioCodec &audiocodec)
{
DEBUG("Starting main thread");
......
......@@ -96,11 +96,9 @@ class AudioSymmetricRtpSession : public ost::TimerPort, public ost::SymmetricRTP
NON_COPYABLE(AudioRtpThread);
AudioSymmetricRtpSession &rtpSession_;
};
void setSessionMedia(AudioCodec &codec);
int startRtpThread(AudioCodec &audiocodec);
AudioRtpThread rtpThread_ ;
unsigned int transportRate_;
AudioRtpThread rtpThread_;
};
}
......
......@@ -126,12 +126,9 @@ AudioZrtpSession::AudioZrtpThread::AudioZrtpThread(AudioZrtpSession &session) :
void AudioZrtpSession::AudioZrtpThread::run()
{
// Set recording sampling rate
int threadSleep = 20;
DEBUG("Entering Audio zrtp thread main loop %s", running_ ? "running" : "not running");
TimerPort::setTimer(threadSleep);
TimerPort::setTimer(zrtpSession_.transportRate_);
while (running_) {
// Send session
......@@ -142,7 +139,7 @@ void AudioZrtpSession::AudioZrtpThread::run()
Thread::sleep(TimerPort::getTimer());
TimerPort::incTimer(threadSleep);
TimerPort::incTimer(zrtpSession_.transportRate_);
}
DEBUG("Leaving audio rtp thread loop");
......@@ -153,11 +150,6 @@ int AudioZrtpSession::getIncrementForDTMF() const
return 160;
}
void AudioZrtpSession::setSessionMedia(AudioCodec &audioCodec)
{
AudioRtpSession::setSessionMedia(audioCodec);
}
int AudioZrtpSession::startRtpThread(AudioCodec &audiocodec)
{
if(isStarted_)
......
......@@ -96,7 +96,6 @@ class AudioZrtpSession :
void sendMicData();
void initializeZid();
std::string zidFilename_;
void setSessionMedia(AudioCodec &codec);
int startRtpThread(AudioCodec &audiocodec);
virtual int getIncrementForDTMF() const;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment