Adding EncodedInfo struct to AudioEncoder::Encode
This struct will be expanded in future changes. BUG=3926 R=kwiberg@webrtc.org Review URL: https://webrtc-codereview.appspot.com/31049004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@7771 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
parent
20446e7e56
commit
1db20a4180
@ -22,6 +22,10 @@ namespace webrtc {
|
||||
// codec type must have an implementation of this class.
|
||||
class AudioEncoder {
|
||||
public:
|
||||
struct EncodedInfo {
|
||||
uint32_t encoded_timestamp;
|
||||
};
|
||||
|
||||
virtual ~AudioEncoder() {}
|
||||
|
||||
// Accepts one 10 ms block of input audio (i.e., sample_rate_hz() / 100 *
|
||||
@ -37,7 +41,7 @@ class AudioEncoder {
|
||||
size_t max_encoded_bytes,
|
||||
uint8_t* encoded,
|
||||
size_t* encoded_bytes,
|
||||
uint32_t* encoded_timestamp) {
|
||||
EncodedInfo* info) {
|
||||
CHECK_EQ(num_samples_per_channel,
|
||||
static_cast<size_t>(sample_rate_hz() / 100));
|
||||
bool ret = Encode(timestamp,
|
||||
@ -45,7 +49,7 @@ class AudioEncoder {
|
||||
max_encoded_bytes,
|
||||
encoded,
|
||||
encoded_bytes,
|
||||
encoded_timestamp);
|
||||
info);
|
||||
CHECK_LE(*encoded_bytes, max_encoded_bytes);
|
||||
return ret;
|
||||
}
|
||||
@ -68,7 +72,7 @@ class AudioEncoder {
|
||||
size_t max_encoded_bytes,
|
||||
uint8_t* encoded,
|
||||
size_t* encoded_bytes,
|
||||
uint32_t* encoded_timestamp) = 0;
|
||||
EncodedInfo* info) = 0;
|
||||
};
|
||||
|
||||
} // namespace webrtc
|
||||
|
@ -57,7 +57,7 @@ bool AudioEncoderPcm::Encode(uint32_t timestamp,
|
||||
size_t max_encoded_bytes,
|
||||
uint8_t* encoded,
|
||||
size_t* encoded_bytes,
|
||||
uint32_t* encoded_timestamp) {
|
||||
EncodedInfo* info) {
|
||||
const int num_samples = sample_rate_hz() / 100 * num_channels();
|
||||
if (speech_buffer_.empty()) {
|
||||
first_timestamp_in_buffer_ = timestamp;
|
||||
@ -72,7 +72,7 @@ bool AudioEncoderPcm::Encode(uint32_t timestamp,
|
||||
CHECK_EQ(speech_buffer_.size(), static_cast<size_t>(full_frame_samples_));
|
||||
int16_t ret = EncodeCall(&speech_buffer_[0], full_frame_samples_, encoded);
|
||||
speech_buffer_.clear();
|
||||
*encoded_timestamp = first_timestamp_in_buffer_;
|
||||
info->encoded_timestamp = first_timestamp_in_buffer_;
|
||||
if (ret < 0)
|
||||
return false;
|
||||
*encoded_bytes = static_cast<size_t>(ret);
|
||||
|
@ -40,7 +40,7 @@ class AudioEncoderPcm : public AudioEncoder {
|
||||
size_t max_encoded_bytes,
|
||||
uint8_t* encoded,
|
||||
size_t* encoded_bytes,
|
||||
uint32_t* encoded_timestamp) OVERRIDE;
|
||||
EncodedInfo* info) OVERRIDE;
|
||||
|
||||
virtual int16_t EncodeCall(const int16_t* audio,
|
||||
size_t input_len,
|
||||
|
@ -76,7 +76,7 @@ bool AudioEncoderOpus::Encode(uint32_t timestamp,
|
||||
size_t max_encoded_bytes,
|
||||
uint8_t* encoded,
|
||||
size_t* encoded_bytes,
|
||||
uint32_t* encoded_timestamp) {
|
||||
EncodedInfo* info) {
|
||||
if (input_buffer_.empty())
|
||||
first_timestamp_in_buffer_ = timestamp;
|
||||
input_buffer_.insert(input_buffer_.end(), audio,
|
||||
@ -97,7 +97,7 @@ bool AudioEncoderOpus::Encode(uint32_t timestamp,
|
||||
if (r < 0)
|
||||
return false;
|
||||
*encoded_bytes = r;
|
||||
*encoded_timestamp = first_timestamp_in_buffer_;
|
||||
info->encoded_timestamp = first_timestamp_in_buffer_;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -40,7 +40,7 @@ class AudioEncoderOpus : public AudioEncoder {
|
||||
size_t max_encoded_bytes,
|
||||
uint8_t* encoded,
|
||||
size_t* encoded_bytes,
|
||||
uint32_t* encoded_timestamp) OVERRIDE;
|
||||
EncodedInfo* info) OVERRIDE;
|
||||
|
||||
private:
|
||||
const int num_10ms_frames_per_packet_;
|
||||
|
@ -102,7 +102,6 @@ class AudioDecoderTest : public ::testing::Test {
|
||||
data_length_(0),
|
||||
encoded_bytes_(0),
|
||||
channels_(1),
|
||||
output_timestamp_(0),
|
||||
decoder_(NULL) {}
|
||||
|
||||
virtual ~AudioDecoderTest() {}
|
||||
@ -152,7 +151,7 @@ class AudioDecoderTest : public ::testing::Test {
|
||||
|
||||
EXPECT_TRUE(audio_encoder_->Encode(
|
||||
0, interleaved_input.get(), audio_encoder_->sample_rate_hz() / 100,
|
||||
data_length_ * 2, output, &enc_len_bytes, &output_timestamp_));
|
||||
data_length_ * 2, output, &enc_len_bytes, &encoded_info_));
|
||||
}
|
||||
return static_cast<int>(enc_len_bytes);
|
||||
}
|
||||
@ -263,7 +262,7 @@ class AudioDecoderTest : public ::testing::Test {
|
||||
size_t data_length_;
|
||||
size_t encoded_bytes_;
|
||||
size_t channels_;
|
||||
uint32_t output_timestamp_;
|
||||
AudioEncoder::EncodedInfo encoded_info_;
|
||||
AudioDecoder* decoder_;
|
||||
scoped_ptr<AudioEncoder> audio_encoder_;
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user