Adding a payload type to AudioEncoder objects

The type is set in the Config struct and is provided in the EncodedInfo
output struct from each Encode() call. The audio_decoder_unittest is
updated to verify correct propagation of the payload type.

BUG=3926
R=kwiberg@webrtc.org

Review URL: https://webrtc-codereview.appspot.com/27299004

git-svn-id: http://webrtc.googlecode.com/svn/trunk@7780 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
henrik.lundin@webrtc.org
2014-12-02 12:08:39 +00:00
parent 0cd5558f2b
commit 7f1dfa5b61
8 changed files with 37 additions and 3 deletions

View File

@ -36,7 +36,9 @@ int16_t CastInt16(size_t x) {
} // namespace
AudioEncoderOpus::Config::Config() : frame_size_ms(20), num_channels(1) {}
AudioEncoderOpus::Config::Config()
: frame_size_ms(20), num_channels(1), payload_type(120) {
}
bool AudioEncoderOpus::Config::IsOk() const {
if (frame_size_ms <= 0 || frame_size_ms % 10 != 0)
@ -49,6 +51,7 @@ bool AudioEncoderOpus::Config::IsOk() const {
AudioEncoderOpus::AudioEncoderOpus(const Config& config)
: num_10ms_frames_per_packet_(DivExact(config.frame_size_ms, 10)),
num_channels_(config.num_channels),
payload_type_(config.payload_type),
samples_per_10ms_frame_(DivExact(kSampleRateHz, 100) * num_channels_) {
CHECK(config.IsOk());
input_buffer_.reserve(num_10ms_frames_per_packet_ * samples_per_10ms_frame_);
@ -98,6 +101,7 @@ bool AudioEncoderOpus::Encode(uint32_t timestamp,
return false;
*encoded_bytes = r;
info->encoded_timestamp = first_timestamp_in_buffer_;
info->payload_type = payload_type_;
return true;
}

View File

@ -25,6 +25,7 @@ class AudioEncoderOpus : public AudioEncoder {
bool IsOk() const;
int frame_size_ms;
int num_channels;
int payload_type;
};
explicit AudioEncoderOpus(const Config& config);
@ -45,6 +46,7 @@ class AudioEncoderOpus : public AudioEncoder {
private:
const int num_10ms_frames_per_packet_;
const int num_channels_;
const int payload_type_;
const int samples_per_10ms_frame_;
std::vector<int16_t> input_buffer_;
OpusEncInst* inst_;