Commit 35dae9e9 authored by Tristan Matthews's avatar Tristan Matthews

* #7131: remove (void), rename _foobar

parent be6905d9
......@@ -59,7 +59,7 @@ AudioRecorder::AudioRecorder(AudioRecord *arec, MainBuffer *mb) : Thread()
/**
* Reimplementation of run()
*/
void AudioRecorder::run(void)
void AudioRecorder::run()
{
int bufferLength = 10000;
......
......@@ -104,7 +104,7 @@ void AudioRtpRecordHandler::putDtmfEvent(int digit)
std::ofstream teststream("test_process_data_encode.raw");
#endif
int AudioRtpRecordHandler::processDataEncode(void)
int AudioRtpRecordHandler::processDataEncode()
{
SFLDataFormat *micData = audioRtpRecord_.decData_;
unsigned char *micDataEncoded = audioRtpRecord_.encodedData_;
......
......@@ -135,7 +135,7 @@ void AudioSrtpSession::setRemoteCryptoInfo(sfl::SdesNegotiator& nego)
}
}
void AudioSrtpSession::initializeLocalMasterKey(void)
void AudioSrtpSession::initializeLocalMasterKey()
{
_debug("AudioSrtp: Init local master key");
......@@ -156,7 +156,7 @@ void AudioSrtpSession::initializeLocalMasterKey(void)
memcpy(localMasterKey_, random_key, localMasterKeyLength_);
}
void AudioSrtpSession::initializeLocalMasterSalt(void)
void AudioSrtpSession::initializeLocalMasterSalt()
{
// @TODO key may have different length depending on cipher suite
localMasterSaltLength_ = sfl::CryptoSuites[localCryptoSuite_].masterSaltLength / 8;
......@@ -212,7 +212,7 @@ void AudioSrtpSession::unBase64ConcatenatedKeys(std::string base64keys)
delete[] output;
}
void AudioSrtpSession::initializeRemoteCryptoContext(void)
void AudioSrtpSession::initializeRemoteCryptoContext()
{
_debug("AudioSrtp: Initialize remote crypto context");
......@@ -239,7 +239,7 @@ void AudioSrtpSession::initializeRemoteCryptoContext(void)
}
void AudioSrtpSession::initializeLocalCryptoContext(void)
void AudioSrtpSession::initializeLocalCryptoContext()
{
_debug("AudioSrtp: Initialize local crypto context");
......
......@@ -131,7 +131,7 @@ ZrtpSessionCallback::secureOn(std::string cipher)
}
void
ZrtpSessionCallback::secureOff(void)
ZrtpSessionCallback::secureOff()
{
_debug("Zrtp: Secure mode is off");
Manager::instance().getDbusManager()->getCallManager()->secureZrtpOff(_sipcall->getCallId());
......
......@@ -49,9 +49,9 @@ class ZrtpSessionCallback: public ZrtpUserCallback {
ZrtpSessionCallback(SIPCall *sipcall);
void secureOn(std::string cipher);
void secureOff(void);
void secureOff();
void showSAS(std::string sas, bool verified);
void zrtpNotSuppOther(void);
void zrtpNotSuppOther();
void showMessage(GnuZrtpCodes::MessageSeverity sev, int32_t subCode);
void zrtpNegotiationFailed(GnuZrtpCodes::MessageSeverity severity, int subCode);
void confirmGoClear();
......
......@@ -40,33 +40,33 @@ class Alaw : public sfl::AudioCodec {
// 8 PCMA A 8000 1 [RFC3551]
Alaw(int payload=8)
: sfl::AudioCodec(payload, "PCMA") {
_clockRate = 8000;
_frameSize = 160; // samples, 20 ms at 8kHz
_channel = 1;
_bitrate = 64;
_hasDynamicPayload = false;
clockRate_ = 8000;
frameSize_ = 160; // samples, 20 ms at 8kHz
channel_ = 1;
bitrate_ = 64;
hasDynamicPayload_ = false;
}
virtual ~Alaw() {}
virtual int decode(short *dst, unsigned char *src, size_t buf_size) {
assert(buf_size == _frameSize / 2 /* compression factor = 2:1 */ * sizeof(SFLDataFormat));
unsigned char* end = src+buf_size;
assert(buf_size == frameSize_ / 2 /* compression factor = 2:1 */ * sizeof(SFLDataFormat));
unsigned char* end = src + buf_size;
while (src<end)
while (src < end)
*dst++ = ALawDecode(*src++);
return _frameSize;
return frameSize_;
}
virtual int encode(unsigned char *dst, short *src, size_t buf_size) {
assert(buf_size >= _frameSize / 2 /* compression factor = 2:1 */ * sizeof(SFLDataFormat));
uint8* end = dst+_frameSize;
assert(buf_size >= frameSize_ / 2 /* compression factor = 2:1 */ * sizeof(SFLDataFormat));
uint8* end = dst + frameSize_;
while (dst<end)
while (dst < end)
*dst++ = ALawEncode(*src++);
return _frameSize / 2 /* compression factor = 2:1 */ * sizeof(SFLDataFormat);
return frameSize_ / 2 /* compression factor = 2:1 */ * sizeof(SFLDataFormat);
}
......@@ -80,9 +80,9 @@ class Alaw : public sfl::AudioCodec {
alaw &= 0x7f;
if (alaw>=0x20) {
if (alaw >= 0x20) {
linear |= 0x100; // Put in MSB
uint shift = (alaw>>4)-1;
uint shift = (alaw >> 4) - 1;
linear <<= shift;
}
......@@ -97,7 +97,7 @@ class Alaw : public sfl::AudioCodec {
int p = pcm16;
uint a; // u-law value we are forming
if (p<0) {
if (p < 0) {
p = ~p;
a = 0x00; // sign = 0
} else {
......
......@@ -37,32 +37,27 @@ using std::ptrdiff_t;
namespace sfl {
AudioCodec::AudioCodec(uint8 payload, const std::string &codecName) :
_codecName(codecName), _clockRate(8000), _channel(1), _bitrate(0.0),
_hasDynamicPayload(false), _payload(payload)
codecName_(codecName), clockRate_(8000), channel_(1), bitrate_(0.0),
hasDynamicPayload_(false), payload_(payload)
{
init(payload, _clockRate);
init(payload, clockRate_);
}
AudioCodec::AudioCodec(const AudioCodec& codec) :
_codecName(codec._codecName), _clockRate(codec._clockRate), _channel(
codec._channel), _bitrate(codec._bitrate),
_hasDynamicPayload(false), _payload(codec._payload)
codecName_(codec.codecName_), clockRate_(codec.clockRate_), channel_(
codec.channel_), bitrate_(codec.bitrate_),
hasDynamicPayload_(false), payload_(codec.payload_)
{
init(codec._payload, codec._clockRate);
init(codec.payload_, codec.clockRate_);
}
void AudioCodec::init(uint8 payloadType, uint32 clockRate)
{
_payloadFormat = new ost::DynamicPayloadFormat(payloadType, clockRate);
_hasDynamicPayload = (_payload >= 96 && _payload <= 127) ? true : false;
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.
if (_payload == 9) {
_hasDynamicPayload = true;
}
hasDynamicPayload_ = ((payload_ >= 96 and payload_ <= 127) or payload_ == 9);
}
std::string AudioCodec::getMimeType() const
......@@ -72,47 +67,47 @@ std::string AudioCodec::getMimeType() const
std::string AudioCodec::getMimeSubtype() const
{
return _codecName;
return codecName_;
}
const ost::PayloadFormat& AudioCodec::getPayloadFormat()
{
return (*_payloadFormat);
return *payloadFormat_;
}
uint8 AudioCodec::getPayloadType(void) const
uint8 AudioCodec::getPayloadType() const
{
return _payload;
return payload_;
}
bool AudioCodec::hasDynamicPayload(void) const
bool AudioCodec::hasDynamicPayload() const
{
return _hasDynamicPayload;
return hasDynamicPayload_;
}
uint32 AudioCodec::getClockRate(void) const
uint32 AudioCodec::getClockRate() const
{
return _clockRate;
return clockRate_;
}
unsigned AudioCodec::getFrameSize(void) const
unsigned AudioCodec::getFrameSize() const
{
return _frameSize;
return frameSize_;
}
uint8 AudioCodec::getChannel(void) const
uint8 AudioCodec::getChannel() const
{
return _channel;
return channel_;
}
double AudioCodec::getBitRate(void) const
double AudioCodec::getBitRate() const
{
return _bitrate;
return bitrate_;
}
AudioCodec::~AudioCodec()
{
delete _payloadFormat;
delete payloadFormat_;
}
} // end namespace sfl
......@@ -111,7 +111,7 @@ class AudioCodec : public Codec {
* @Override
*/
void setPayloadType(uint8 pt) {
_payload = pt;
payload_ = pt;
}
/**
......@@ -141,29 +141,29 @@ class AudioCodec : public Codec {
protected:
/** Holds SDP-compliant codec name */
std::string _codecName; // what we put inside sdp
std::string codecName_; // what we put inside sdp
/** Clock rate or sample rate of the codec, in Hz */
uint32 _clockRate;
uint32 clockRate_;
/** Number of channel 1 = mono, 2 = stereo */
uint8 _channel;
uint8 channel_;
/** codec frame size in samples*/
unsigned _frameSize;
unsigned frameSize_;
/** Bitrate */
double _bitrate;
double bitrate_;
/** Bandwidth */
double _bandwidth;
double bandwidth_;
bool _hasDynamicPayload;
bool hasDynamicPayload_;
private:
uint8 _payload;
uint8 payload_;
ost::DynamicPayloadFormat* _payloadFormat;
ost::DynamicPayloadFormat* payloadFormat_;
void init(uint8 payloadType, uint32 clockRate);
};
......
......@@ -37,17 +37,15 @@
class Celt : public sfl::AudioCodec {
public:
Celt(int payload=115) : sfl::AudioCodec(payload, "celt") {
_clockRate = 32000;
_frameSize = 320; // fixed frameSize, TODO: support variable size from 64 to 512
_channel = 1;
_bitrate = 0;
_hasDynamicPayload = true;
Celt(int payload = 115) : sfl::AudioCodec(payload, "celt") {
clockRate_ = 32000;
frameSize_ = 320; // fixed frameSize, TODO: support variable size from 64 to 512
channel_ = 1;
bitrate_ = 0;
hasDynamicPayload_ = true;
int error = 0;
_mode = celt_mode_create(_clockRate, _frameSize, &error);
mode_ = celt_mode_create(clockRate_, frameSize_, &error);
if (error != CELT_OK) {
switch (error) {
......@@ -78,72 +76,58 @@ class Celt : public sfl::AudioCodec {
}
if (_mode == NULL)
if (mode_ == NULL)
throw std::runtime_error("Celt: Failed to create Celt mode");
// bytes_per_packet = 1024;
// if (bytes_per_packet < 0 || bytes_per_packet > MAX_PACKET)
// {
// throw std::runtime_error("bytes per packet must be between 0 and %d");
// }
// celt_mode_info(mode, CELT_GET_FRAME_SIZE, &frame_size);
// celt_mode_info(mode, CELT_GET_NB_CHANNELS, &_channel);
_enc = celt_encoder_create(_mode, _channel, &error);
enc_ = celt_encoder_create(mode_, channel_, &error);
dec_ = celt_decoder_create(mode_, channel_, &error);
_dec = celt_decoder_create(_mode, _channel, &error);
celt_encoder_ctl(_enc, CELT_SET_COMPLEXITY(2));
celt_decoder_ctl(_dec, CELT_SET_COMPLEXITY(2));
celt_encoder_ctl(_enc, CELT_SET_PREDICTION(2));
celt_decoder_ctl(_dec, CELT_SET_PREDICTION(2));
celt_encoder_ctl(enc_, CELT_SET_COMPLEXITY(2));
celt_decoder_ctl(dec_, CELT_SET_COMPLEXITY(2));
celt_encoder_ctl(enc_, CELT_SET_PREDICTION(2));
celt_decoder_ctl(dec_, CELT_SET_PREDICTION(2));
}
Celt(const Celt&);
Celt& operator= (const Celt&);
~Celt() {
celt_encoder_destroy(_enc);
celt_decoder_destroy(_dec);
celt_mode_destroy(_mode);
celt_encoder_destroy(enc_);
celt_decoder_destroy(dec_);
celt_mode_destroy(mode_);
}
virtual int decode(short *dst, unsigned char *src, size_t buf_size) {
#ifdef BUILD_CELT_91 // == 91
//int err = 0;
/*err =*/ celt_decode(_dec, src, buf_size, (celt_int16*) dst, _frameSize);
celt_decode(dec_, src, buf_size, (celt_int16*) dst, frameSize_);
#endif
#ifdef BUILD_CELT_71
//int err = 0; // FIXME: check error code
/*err =*/ celt_decode(_dec, src, buf_size, (celt_int16*) dst);
celt_decode(dec_, src, buf_size, (celt_int16*) dst);
#endif
return _frameSize;
return frameSize_;
}
virtual int encode(unsigned char *dst, short *src, size_t buf_size) {
int len = 0;
#ifdef BUILD_CELT_91// == 91
len = celt_encode(_enc, (celt_int16*) src, _frameSize, dst, buf_size);
len = celt_encode(enc_, (celt_int16*) src, frameSize_, dst, buf_size);
#endif
#ifdef BUILD_CELT_71
len = celt_encode(_enc, (celt_int16*) src, (celt_int16 *) src, dst, buf_size);
len = celt_encode(enc_, (celt_int16*) src, (celt_int16 *) src, dst, buf_size);
#endif
return len;
}
private:
CELTMode *_mode;
CELTEncoder *_enc;
CELTDecoder *_dec;
CELTMode *mode_;
celt_int32 _celt_frame_size;
celt_int32 skip;
CELTEncoder *enc_;
CELTDecoder *dec_;
celt_int32 celt_frame_size_;
celt_int32 skip_;
};
// the class factories
......
......@@ -51,11 +51,11 @@ class G722 : public sfl::AudioCodec {
G722(int payload=9)
: sfl::AudioCodec(payload, "G722") {
_clockRate = 16000;
_frameSize = 320; // samples, 20 ms at 16kHz
_channel = 1;
_bitrate = 64;
_hasDynamicPayload = false;
clockRate_ = 16000;
frameSize_ = 320; // samples, 20 ms at 16kHz
channel_ = 1;
bitrate_ = 64;
hasDynamicPayload_ = false;
decode_s = new g722_decode_state_t;
......@@ -72,19 +72,18 @@ class G722 : public sfl::AudioCodec {
}
virtual int decode(short *dst, unsigned char *src, size_t buf_size) {
assert(buf_size == _frameSize / sizeof(SFLDataFormat) * encode_s->bits_per_sample / 8);
assert(buf_size == frameSize_ / sizeof(SFLDataFormat) * encode_s->bits_per_sample / 8);
return g722_decode((int16_t*) dst, (const uint8_t*) src, buf_size);
}
virtual int encode(unsigned char *dst, short *src, size_t buf_size) {
int out = g722_encode((uint8_t*) dst, (const int16_t*) src, _frameSize);
int out = g722_encode((uint8_t*) dst, (const int16_t*) src, frameSize_);
assert((size_t)out <= buf_size);
return out;
}
void g722_encode_init(void) {
encode_s->itu_test_mode = FALSE;
// 8 => 64 kbps; 7 => 56 kbps; 6 => 48 kbps
......
......@@ -136,11 +136,11 @@ typedef struct {
extern "C" {
#endif
void g722_encode_init(void);
void g722_encode_init();
int g722_encode_release();
int g722_encode(uint8_t g722_data[], const int16_t amp[], int len);
void g722_decode_init(void);
void g722_decode_init();
int g722_decode_release();
int g722_decode(int16_t amp[], const uint8_t g722_data[], int len);
......
......@@ -46,17 +46,17 @@ class Gsm : public sfl::AudioCodec {
public:
// _payload should be 3
Gsm(int payload=3) : sfl::AudioCodec(payload, "GSM"), _decode_gsmhandle(NULL), _encode_gsmhandle(NULL) {
_clockRate = 8000;
_frameSize = 160; // samples, 20 ms at 8kHz
_channel = 1;
_bitrate = 13.3;
_hasDynamicPayload = false;
if (!(_decode_gsmhandle = gsm_create()))
Gsm(int payload=3) : sfl::AudioCodec(payload, "GSM"), decode_gsmhandle_(NULL), encode_gsmhandle_(NULL) {
clockRate_ = 8000;
frameSize_ = 160; // samples, 20 ms at 8kHz
channel_ = 1;
bitrate_ = 13.3;
hasDynamicPayload_ = false;
if (!(decode_gsmhandle_ = gsm_create()))
throw std::runtime_error("ERROR: decode_gsm_create\n");
if (!(_encode_gsmhandle = gsm_create()))
if (!(encode_gsmhandle_ = gsm_create()))
throw std::runtime_error("ERROR: encode_gsm_create\n");
}
......@@ -65,30 +65,28 @@ class Gsm : public sfl::AudioCodec {
Gsm& operator= (const Gsm&);
virtual ~Gsm(void) {
gsm_destroy(_decode_gsmhandle);
gsm_destroy(_encode_gsmhandle);
gsm_destroy(decode_gsmhandle_);
gsm_destroy(encode_gsmhandle_);
}
virtual int decode(short * dst, unsigned char * src, size_t buf_size) {
assert(buf_size == 33);
(void) buf_size;
if (gsm_decode(_decode_gsmhandle, (gsm_byte*) src, (gsm_signal*) dst) < 0)
if (gsm_decode(decode_gsmhandle_, (gsm_byte*) src, (gsm_signal*) dst) < 0)
throw std::runtime_error("ERROR: gsm_decode\n");
return _frameSize;
return frameSize_;
}
virtual int encode(unsigned char * dst, short * src, size_t buf_size) {
(void) buf_size;
assert(buf_size >= 33);
gsm_encode(_encode_gsmhandle, (gsm_signal*) src, (gsm_byte*) dst);
gsm_encode(encode_gsmhandle_, (gsm_signal*) src, (gsm_byte*) dst);
return 33;
}
private:
gsm _decode_gsmhandle;
gsm _encode_gsmhandle;
gsm decode_gsmhandle_;
gsm encode_gsmhandle_;
};
extern "C" sfl::Codec* create()
......
......@@ -71,22 +71,22 @@ class Speex : public sfl::AudioCodec {
112 == PAYLOAD_CODEC_SPEEX_32000);
int type = payload - 110;
_clockRate = clockRate[type];
_frameSize = frameSize[type];
_channel = 1;
_bitrate = bitRate[type];
_hasDynamicPayload = dynamicPayload[type];
clockRate_ = clockRate[type];
frameSize_ = frameSize[type];
channel_ = 1;
bitrate_ = bitRate[type];
hasDynamicPayload_ = dynamicPayload[type];
// Init the decoder struct
speex_bits_init(&_speex_dec_bits);
_speex_dec_state = speex_decoder_init(speexMode[type]);
speex_bits_init(&speex_dec_bits_);
speex_dec_state_ = speex_decoder_init(speexMode[type]);
// Init the encoder struct
speex_bits_init(&_speex_enc_bits);
_speex_enc_state = speex_encoder_init(speexMode[type]);
speex_bits_init(&speex_enc_bits_);
speex_enc_state_ = speex_encoder_init(speexMode[type]);
speex_encoder_ctl(_speex_enc_state,SPEEX_SET_SAMPLING_RATE,&_clockRate);
speex_decoder_ctl(_speex_dec_state, SPEEX_GET_FRAME_SIZE, &_speex_frame_size);
speex_encoder_ctl(speex_enc_state_, SPEEX_SET_SAMPLING_RATE, &clockRate_);
speex_decoder_ctl(speex_dec_state_, SPEEX_GET_FRAME_SIZE, &speex_frame_size_);
}
Speex(const Speex&);
......@@ -94,32 +94,32 @@ class Speex : public sfl::AudioCodec {
~Speex() {
// Destroy the decoder struct
speex_bits_destroy(&_speex_dec_bits);
speex_decoder_destroy(_speex_dec_state);
_speex_dec_state = 0;
speex_bits_destroy(&speex_dec_bits_);
speex_decoder_destroy(speex_dec_state_);
speex_dec_state_ = 0;
// Destroy the encoder struct
speex_bits_destroy(&_speex_enc_bits);
speex_encoder_destroy(_speex_enc_state);
_speex_enc_state = 0;
speex_bits_destroy(&speex_enc_bits_);
speex_encoder_destroy(speex_enc_state_);
speex_enc_state_ = 0;
}
virtual int decode(short *dst, unsigned char *src, size_t buf_size) {
speex_bits_read_from(&_speex_dec_bits, (char*) src, buf_size);
speex_decode_int(_speex_dec_state, &_speex_dec_bits, dst);
return _frameSize;
speex_bits_read_from(&speex_dec_bits_, (char*) src, buf_size);
speex_decode_int(speex_dec_state_, &speex_dec_bits_, dst);
return frameSize_;
}
virtual int encode(unsigned char *dst, short *src, size_t buf_size) {
speex_bits_reset(&_speex_enc_bits);