| Index: webrtc/modules/audio_coding/acm2/audio_coding_module.cc
|
| diff --git a/webrtc/modules/audio_coding/acm2/audio_coding_module.cc b/webrtc/modules/audio_coding/acm2/audio_coding_module.cc
|
| index 6170d187bab14ab53b62fe9795c6c56332040c0a..b394c591567926b151b00a62c861f7f7bc35bbd1 100644
|
| --- a/webrtc/modules/audio_coding/acm2/audio_coding_module.cc
|
| +++ b/webrtc/modules/audio_coding/acm2/audio_coding_module.cc
|
| @@ -472,6 +472,11 @@ int32_t AudioCodingModuleImpl::Encode(const InputData& input_data) {
|
| if (!HaveValidEncoder("Process"))
|
| return -1;
|
|
|
| + if(!first_frame_) {
|
| + RTC_DCHECK_GT(input_data.input_timestamp, last_timestamp_)
|
| + << "Time should not move backwards";
|
| + }
|
| +
|
| // Scale the timestamp to the codec's RTP timestamp rate.
|
| uint32_t rtp_timestamp =
|
| first_frame_ ? input_data.input_timestamp
|
| @@ -752,7 +757,8 @@ int AudioCodingModuleImpl::PreprocessToAddData(const AudioFrame& in_frame,
|
| expected_codec_ts_ = in_frame.timestamp_;
|
| first_10ms_data_ = true;
|
| } else if (in_frame.timestamp_ != expected_in_ts_) {
|
| - // TODO(turajs): Do we need a warning here.
|
| + LOG(LS_WARNING) << "Unexpected input timestamp: " << in_frame.timestamp_
|
| + << ", expected: " << expected_in_ts_;
|
| expected_codec_ts_ +=
|
| (in_frame.timestamp_ - expected_in_ts_) *
|
| static_cast<uint32_t>(
|
| @@ -764,9 +770,19 @@ int AudioCodingModuleImpl::PreprocessToAddData(const AudioFrame& in_frame,
|
|
|
| if (!down_mix && !resample) {
|
| // No pre-processing is required.
|
| + if (expected_in_ts_ == expected_codec_ts_) {
|
| + // If we've never resampled, we can use the input frame as-is
|
| + *ptr_out = &in_frame;
|
| + } else {
|
| + // Otherwise we'll need to alter the timestamp. Since in_frame is const,
|
| + // we'll have to make a copy of it.
|
| + preprocess_frame_.CopyFrom(in_frame);
|
| + preprocess_frame_.timestamp_ = expected_codec_ts_;
|
| + *ptr_out = &preprocess_frame_;
|
| + }
|
| +
|
| expected_in_ts_ += static_cast<uint32_t>(in_frame.samples_per_channel_);
|
| expected_codec_ts_ += static_cast<uint32_t>(in_frame.samples_per_channel_);
|
| - *ptr_out = &in_frame;
|
| return 0;
|
| }
|
|
|
|
|