2015-09-09 13:54:29 -07:00
|
|
|
#ifndef __WEB_RTC_CODEC_H__
|
|
|
|
#define __WEB_RTC_CODEC_H__
|
|
|
|
|
|
|
|
#include "AudioCodec.h"
|
|
|
|
#include <sys/types.h>
|
|
|
|
|
|
|
|
#include <modules/audio_coding/neteq/interface/audio_decoder.h>
|
|
|
|
|
|
|
|
class WebRtcCodec : public webrtc::AudioDecoder {
|
|
|
|
|
|
|
|
private:
|
|
|
|
AudioCodec &codec;
|
|
|
|
|
|
|
|
public:
|
|
|
|
WebRtcCodec(AudioCodec &codec) :
|
|
|
|
AudioDecoder(webrtc::kDecoderArbitrary), codec(codec)
|
|
|
|
{}
|
|
|
|
|
|
|
|
int Decode(const uint8_t* encoded, size_t encoded_len,
|
2017-03-10 09:28:54 -08:00
|
|
|
int16_t* decoded, size_t decodedMaxSize,
|
|
|
|
SpeechType* speech_type)
|
2015-09-09 13:54:29 -07:00
|
|
|
{
|
|
|
|
*speech_type = kSpeech;
|
2017-03-10 09:28:54 -08:00
|
|
|
return codec.decode((char*)encoded, encoded_len, decoded, decodedMaxSize);
|
2015-09-09 13:54:29 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
bool HasDecodePlc() const {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
int DecodePlc(int num_frames, int16_t* decoded) {
|
|
|
|
return codec.conceal(num_frames, decoded);
|
|
|
|
}
|
|
|
|
|
|
|
|
int Init() { return 0; }
|
|
|
|
|
|
|
|
int PacketDuration(const uint8_t* encoded, size_t encoded_len) const {
|
|
|
|
return (encoded_len / SPEEX_ENCODED_FRAME_SIZE) * SPEEX_FRAME_SIZE;
|
|
|
|
}
|
|
|
|
|
|
|
|
int PacketDurationRedundant(const uint8_t* encoded, size_t encoded_len) const {
|
|
|
|
return this->PacketDuration(encoded, encoded_len);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool PacketHasFec(const uint8_t* encoded, size_t encoded_len) const {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|