Send absolute capture time through audio coding module.

Bug: webrtc:10739
Change-Id: I44e0305be7c84b253172511c2977b1d700e40c1b
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/167067
Reviewed-by: Oskar Sundbom <ossu@webrtc.org>
Reviewed-by: Danil Chapovalov <danilchap@webrtc.org>
Reviewed-by: Chen Xing <chxg@google.com>
Commit-Queue: Minyue Li <minyue@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#30363}
This commit is contained in:
Minyue Li
2020-01-23 13:45:50 +01:00
committed by Commit Bot
parent cdd73e095c
commit 48655cfdbf
17 changed files with 69 additions and 30 deletions

View File

@ -107,7 +107,8 @@ class AcmReceiverTestOldApi : public AudioPacketizationCallback,
uint8_t payload_type,
uint32_t timestamp,
const uint8_t* payload_data,
size_t payload_len_bytes) override {
size_t payload_len_bytes,
int64_t absolute_capture_timestamp_ms) override {
if (frame_type == AudioFrameType::kEmptyFrame)
return 0;

View File

@ -126,7 +126,8 @@ int32_t AcmSendTestOldApi::SendData(AudioFrameType frame_type,
uint8_t payload_type,
uint32_t timestamp,
const uint8_t* payload_data,
size_t payload_len_bytes) {
size_t payload_len_bytes,
int64_t absolute_capture_timestamp_ms) {
// Store the packet locally.
frame_type_ = frame_type;
payload_type_ = payload_type;

View File

@ -54,7 +54,8 @@ class AcmSendTestOldApi : public AudioPacketizationCallback,
uint8_t payload_type,
uint32_t timestamp,
const uint8_t* payload_data,
size_t payload_len_bytes) override;
size_t payload_len_bytes,
int64_t absolute_capture_timestamp_ms) override;
AudioCodingModule* acm() { return acm_.get(); }

View File

@ -11,7 +11,6 @@
#include "modules/audio_coding/include/audio_coding_module.h"
#include <assert.h>
#include <algorithm>
#include <cstdint>
@ -110,6 +109,7 @@ 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_);
@ -253,6 +253,7 @@ int32_t AudioCodingModuleImpl::Encode(const InputData& input_data) {
int64_t{input_data.input_timestamp - last_timestamp_} *
encoder_stack_->RtpTimestampRateHz(),
int64_t{encoder_stack_->SampleRateHz()}));
last_timestamp_ = input_data.input_timestamp;
last_rtp_timestamp_ = rtp_timestamp;
first_frame_ = false;
@ -302,7 +303,8 @@ int32_t AudioCodingModuleImpl::Encode(const InputData& input_data) {
if (packetization_callback_) {
packetization_callback_->SendData(
frame_type, encoded_info.payload_type, encoded_info.encoded_timestamp,
encode_buffer_.data(), encode_buffer_.size());
encode_buffer_.data(), encode_buffer_.size(),
input_data.absolute_capture_timestamp_ms);
}
if (vad_callback_) {
@ -392,6 +394,9 @@ 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

View File

@ -111,7 +111,8 @@ class PacketizationCallbackStubOldApi : public AudioPacketizationCallback {
uint8_t payload_type,
uint32_t timestamp,
const uint8_t* payload_data,
size_t payload_len_bytes) override {
size_t payload_len_bytes,
int64_t absolute_capture_timestamp_ms) override {
rtc::CritScope lock(&crit_sect_);
++num_calls_;
last_frame_type_ = frame_type;