Add support for 40 and 60 ms frames to AudioEncoderIlbc
BUG=3926 COAUTHOR:kwiberg@webrtc.org R=tina.legrand@webrtc.org Review URL: https://webrtc-codereview.appspot.com/37789004 Cr-Commit-Position: refs/heads/master@{#8182} git-svn-id: http://webrtc.googlecode.com/svn/trunk@8182 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
parent
2a6558c2a5
commit
4aecd008dd
@ -27,12 +27,16 @@ AudioEncoderIlbc::AudioEncoderIlbc(const Config& config)
|
|||||||
: payload_type_(config.payload_type),
|
: payload_type_(config.payload_type),
|
||||||
num_10ms_frames_per_packet_(config.frame_size_ms / 10),
|
num_10ms_frames_per_packet_(config.frame_size_ms / 10),
|
||||||
num_10ms_frames_buffered_(0) {
|
num_10ms_frames_buffered_(0) {
|
||||||
CHECK(config.frame_size_ms == 20 || config.frame_size_ms == 30)
|
CHECK(config.frame_size_ms == 20 || config.frame_size_ms == 30 ||
|
||||||
<< "Frame size must be 20 or 30 ms.";
|
config.frame_size_ms == 40 || config.frame_size_ms == 60)
|
||||||
|
<< "Frame size must be 20, 30, 40, or 60 ms.";
|
||||||
DCHECK_LE(kSampleRateHz / 100 * num_10ms_frames_per_packet_,
|
DCHECK_LE(kSampleRateHz / 100 * num_10ms_frames_per_packet_,
|
||||||
kMaxSamplesPerPacket);
|
kMaxSamplesPerPacket);
|
||||||
CHECK_EQ(0, WebRtcIlbcfix_EncoderCreate(&encoder_));
|
CHECK_EQ(0, WebRtcIlbcfix_EncoderCreate(&encoder_));
|
||||||
CHECK_EQ(0, WebRtcIlbcfix_EncoderInit(encoder_, config.frame_size_ms));
|
const int encoder_frame_size_ms = config.frame_size_ms > 30
|
||||||
|
? config.frame_size_ms / 2
|
||||||
|
: config.frame_size_ms;
|
||||||
|
CHECK_EQ(0, WebRtcIlbcfix_EncoderInit(encoder_, encoder_frame_size_ms));
|
||||||
}
|
}
|
||||||
|
|
||||||
AudioEncoderIlbc::~AudioEncoderIlbc() {
|
AudioEncoderIlbc::~AudioEncoderIlbc() {
|
||||||
@ -57,8 +61,23 @@ bool AudioEncoderIlbc::EncodeInternal(uint32_t rtp_timestamp,
|
|||||||
size_t max_encoded_bytes,
|
size_t max_encoded_bytes,
|
||||||
uint8_t* encoded,
|
uint8_t* encoded,
|
||||||
EncodedInfo* info) {
|
EncodedInfo* info) {
|
||||||
const size_t expected_output_len =
|
size_t expected_output_len;
|
||||||
num_10ms_frames_per_packet_ == 2 ? 38 : 50;
|
switch (num_10ms_frames_per_packet_) {
|
||||||
|
case 2:
|
||||||
|
expected_output_len = 38;
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
expected_output_len = 50;
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
expected_output_len = 2 * 38;
|
||||||
|
break;
|
||||||
|
case 6:
|
||||||
|
expected_output_len = 2 * 50;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
FATAL();
|
||||||
|
}
|
||||||
DCHECK_GE(max_encoded_bytes, expected_output_len);
|
DCHECK_GE(max_encoded_bytes, expected_output_len);
|
||||||
|
|
||||||
// Save timestamp if starting a new packet.
|
// Save timestamp if starting a new packet.
|
||||||
|
@ -23,7 +23,9 @@ class AudioEncoderIlbc : public AudioEncoder {
|
|||||||
Config() : payload_type(102), frame_size_ms(30) {}
|
Config() : payload_type(102), frame_size_ms(30) {}
|
||||||
|
|
||||||
int payload_type;
|
int payload_type;
|
||||||
int frame_size_ms;
|
int frame_size_ms; // Valid values are 20, 30, 40, and 60 ms.
|
||||||
|
// Note that frame size 40 ms produces encodings with two 20 ms frames in
|
||||||
|
// them, and frame size 60 ms consists of two 30 ms frames.
|
||||||
};
|
};
|
||||||
|
|
||||||
explicit AudioEncoderIlbc(const Config& config);
|
explicit AudioEncoderIlbc(const Config& config);
|
||||||
@ -42,7 +44,7 @@ class AudioEncoderIlbc : public AudioEncoder {
|
|||||||
EncodedInfo* info) OVERRIDE;
|
EncodedInfo* info) OVERRIDE;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static const int kMaxSamplesPerPacket = 240;
|
static const int kMaxSamplesPerPacket = 480;
|
||||||
const int payload_type_;
|
const int payload_type_;
|
||||||
const int num_10ms_frames_per_packet_;
|
const int num_10ms_frames_per_packet_;
|
||||||
int num_10ms_frames_buffered_;
|
int num_10ms_frames_buffered_;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user