session-android/jni/redphone/WebRtcCodec.h
Moxie Marlinspike 8e25689c24 Modify upstream webrtc NetEq to pass bounds information to speex
Just in case

Closes #6334
// FREEBIE
2017-03-10 09:28:54 -08:00

52 lines
1.2 KiB
C++

#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,
int16_t* decoded, size_t decodedMaxSize,
SpeechType* speech_type)
{
*speech_type = kSpeech;
return codec.decode((char*)encoded, encoded_len, decoded, decodedMaxSize);
}
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