aboutsummaryrefslogtreecommitdiff
path: root/modules/audio_coding
diff options
context:
space:
mode:
authorMinyue Li <minyue@webrtc.org>2020-02-18 15:45:41 +0100
committerCommit Bot <commit-bot@chromium.org>2020-02-18 16:54:48 +0000
commitdea73ee8f9c0707aed35b9edb928216877f72091 (patch)
tree76971cd333537db65921386e472377d957c1c542 /modules/audio_coding
parent2272f20a0a14e705adaa21c773b43d594a5a2114 (diff)
downloadwebrtc-dea73ee8f9c0707aed35b9edb928216877f72091.tar.gz
Pass absolute capture time from WebRtcVoiceEngine to ACM.
Bug: webrtc:10739 Change-Id: I6f264cb89ce340db642db3ef7dfc2b5d459f749e Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/167211 Commit-Queue: Minyue Li <minyue@webrtc.org> Reviewed-by: Per Ã…hgren <peah@webrtc.org> Reviewed-by: Chen Xing <chxg@google.com> Reviewed-by: Danil Chapovalov <danilchap@webrtc.org> Cr-Commit-Position: refs/heads/master@{#30547}
Diffstat (limited to 'modules/audio_coding')
-rw-r--r--modules/audio_coding/acm2/audio_coding_module.cc24
1 files changed, 16 insertions, 8 deletions
diff --git a/modules/audio_coding/acm2/audio_coding_module.cc b/modules/audio_coding/acm2/audio_coding_module.cc
index f3dd5b1a1f..e28be186f5 100644
--- a/modules/audio_coding/acm2/audio_coding_module.cc
+++ b/modules/audio_coding/acm2/audio_coding_module.cc
@@ -109,7 +109,6 @@ class AudioCodingModuleImpl final : public AudioCodingModule {
// If a re-mix is required (up or down), this buffer will store a re-mixed
// version of the input.
std::vector<int16_t> buffer;
- int64_t absolute_capture_timestamp_ms;
};
InputData input_data_ RTC_GUARDED_BY(acm_crit_sect_);
@@ -132,7 +131,11 @@ class AudioCodingModuleImpl final : public AudioCodingModule {
int Add10MsDataInternal(const AudioFrame& audio_frame, InputData* input_data)
RTC_EXCLUSIVE_LOCKS_REQUIRED(acm_crit_sect_);
- int Encode(const InputData& input_data)
+
+ // TODO(bugs.webrtc.org/10739): change |absolute_capture_timestamp_ms| to
+ // int64_t when it always receives a valid value.
+ int Encode(const InputData& input_data,
+ absl::optional<int64_t> absolute_capture_timestamp_ms)
RTC_EXCLUSIVE_LOCKS_REQUIRED(acm_crit_sect_);
int InitializeReceiverSafe() RTC_EXCLUSIVE_LOCKS_REQUIRED(acm_crit_sect_);
@@ -231,7 +234,11 @@ AudioCodingModuleImpl::AudioCodingModuleImpl(
AudioCodingModuleImpl::~AudioCodingModuleImpl() = default;
-int32_t AudioCodingModuleImpl::Encode(const InputData& input_data) {
+int32_t AudioCodingModuleImpl::Encode(
+ const InputData& input_data,
+ absl::optional<int64_t> absolute_capture_timestamp_ms) {
+ // TODO(bugs.webrtc.org/10739): add dcheck that
+ // |audio_frame.absolute_capture_timestamp_ms()| always has a value.
AudioEncoder::EncodedInfo encoded_info;
uint8_t previous_pltype;
@@ -304,7 +311,7 @@ int32_t AudioCodingModuleImpl::Encode(const InputData& input_data) {
packetization_callback_->SendData(
frame_type, encoded_info.payload_type, encoded_info.encoded_timestamp,
encode_buffer_.data(), encode_buffer_.size(),
- input_data.absolute_capture_timestamp_ms);
+ absolute_capture_timestamp_ms.value_or(-1));
}
if (vad_callback_) {
@@ -339,7 +346,11 @@ int AudioCodingModuleImpl::RegisterTransportCallback(
int AudioCodingModuleImpl::Add10MsData(const AudioFrame& audio_frame) {
rtc::CritScope lock(&acm_crit_sect_);
int r = Add10MsDataInternal(audio_frame, &input_data_);
- return r < 0 ? r : Encode(input_data_);
+ // TODO(bugs.webrtc.org/10739): add dcheck that
+ // |audio_frame.absolute_capture_timestamp_ms()| always has a value.
+ return r < 0
+ ? r
+ : Encode(input_data_, audio_frame.absolute_capture_timestamp_ms());
}
int AudioCodingModuleImpl::Add10MsDataInternal(const AudioFrame& audio_frame,
@@ -394,9 +405,6 @@ int AudioCodingModuleImpl::Add10MsDataInternal(const AudioFrame& audio_frame,
input_data->input_timestamp = ptr_frame->timestamp_;
input_data->length_per_channel = ptr_frame->samples_per_channel_;
input_data->audio_channel = current_num_channels;
- // TODO(bugs.webrtc.org/10739): Assign from a corresponding field in
- // audio_frame when it is added in AudioFrame.
- input_data->absolute_capture_timestamp_ms = 0;
if (!same_num_channels) {
// Remixes the input frame to the output data and in the process resize the