Commit 2a9992d7 authored by Tristan Matthews's avatar Tristan Matthews
Browse files

* #9903: create DynamicPayloadFormat on stack, initialize earlier

parent ab8db495
......@@ -141,7 +141,8 @@ void AudioRtpSession::sendDtmfEvent()
queue_.setMark(false);
// get back the payload to audio
queue_.setPayloadFormat(ost::StaticPayloadFormat((ost::StaticPayloadType) getCodecPayloadType()));
const ost::StaticPayloadFormat pf(static_cast<ost::StaticPayloadType>(getCodecPayloadType()));
queue_.setPayloadFormat(pf);
}
......
......@@ -44,12 +44,10 @@ AudioCodec::AudioCodec(uint8 payload, const std::string &codecName,
frameSize_(frameSize),
bitrate_(0.0),
bandwidth_(0.0),
hasDynamicPayload_(false),
payload_(payload),
payloadFormat_(0)
{
init(payload, clockRate_);
}
payloadFormat_(payload, clockRate_),
hasDynamicPayload_((payload_ >= 96 and payload_ <= 127) or payload_ == 9)
{}
AudioCodec::AudioCodec(const AudioCodec& c) :
codecName_(c.codecName_),
......@@ -58,23 +56,10 @@ AudioCodec::AudioCodec(const AudioCodec& c) :
frameSize_(c.frameSize_),
bitrate_(c.bitrate_),
bandwidth_(c.bandwidth_),
hasDynamicPayload_(c.hasDynamicPayload_),
payload_(c.payload_),
payloadFormat_(c.payloadFormat_)
{
init(c.payload_, c.clockRate_);
}
void AudioCodec::init(uint8 payloadType, uint32 clockRate)
{
#warning FIXME: we don't need to allocate payloadFormat_ dynamically
payloadFormat_ = new ost::DynamicPayloadFormat(payloadType, clockRate);
// If g722 (payload 9), we need to init libccrtp symetric sessions with using
// dynamic payload format. This way we get control on rtp clockrate.
hasDynamicPayload_ = ((payload_ >= 96 and payload_ <= 127) or payload_ == 9);
}
payloadFormat_(c.payloadFormat_),
hasDynamicPayload_(c.hasDynamicPayload_)
{}
std::string AudioCodec::getMimeSubtype() const
{
......@@ -106,9 +91,4 @@ double AudioCodec::getBitRate() const
return bitrate_;
}
AudioCodec::~AudioCodec()
{
delete payloadFormat_;
}
} // end namespace sfl
......@@ -34,6 +34,8 @@
#include <string>
#include <dlfcn.h>
#include <cc++/config.h>
#include <ccrtp/formats.h> // for ost::DynamicPayloadFormat
#include "codec.h"
......@@ -42,11 +44,6 @@
// Also assume mono
#define DEC_BUFFER_SIZE ((44100 * 20) / 1000)
namespace ost {
class PayloadFormat;
class DynamicPayloadFormat;
}
namespace sfl {
class AudioCodec : public Codec {
......@@ -59,7 +56,7 @@ class AudioCodec : public Codec {
*/
AudioCodec(const AudioCodec& codec);
virtual ~AudioCodec();
virtual ~AudioCodec() {};
/**
* @Override
......@@ -131,15 +128,14 @@ class AudioCodec : public Codec {
/** Bandwidth */
double bandwidth_;
bool hasDynamicPayload_;
private:
AudioCodec& operator=(const AudioCodec&);
uint8 payload_;
ost::DynamicPayloadFormat* payloadFormat_;
ost::DynamicPayloadFormat payloadFormat_;
void init(uint8 payloadType, uint32 clockRate);
protected:
bool hasDynamicPayload_;
};
} // end namespace sfl
......
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