Adding absolute capture timestamp to AudioTrackSinkInterface.
Bug: webrtc:10739 Change-Id: I8c134cbe82452ac71625cd0c810c783a73f17822 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/167532 Commit-Queue: Minyue Li <minyue@webrtc.org> Reviewed-by: Chen Xing <chxg@google.com> Reviewed-by: Karl Wiberg <kwiberg@webrtc.org> Cr-Commit-Position: refs/heads/master@{#30408}
This commit is contained in:
parent
26b4cb3fc5
commit
99d6d8115b
@ -202,7 +202,25 @@ class AudioTrackSinkInterface {
|
||||
int bits_per_sample,
|
||||
int sample_rate,
|
||||
size_t number_of_channels,
|
||||
size_t number_of_frames) = 0;
|
||||
size_t number_of_frames) {
|
||||
RTC_NOTREACHED() << "This method must be overridden, or not used.";
|
||||
}
|
||||
|
||||
// In this method, |absolute_capture_timestamp_ms|, when available, is
|
||||
// supposed to deliver the timestamp when this audio frame was originally
|
||||
// captured. This timestamp MUST be based on the same clock as
|
||||
// rtc::TimeMillis().
|
||||
virtual void OnData(const void* audio_data,
|
||||
int bits_per_sample,
|
||||
int sample_rate,
|
||||
size_t number_of_channels,
|
||||
size_t number_of_frames,
|
||||
absl::optional<int64_t> absolute_capture_timestamp_ms) {
|
||||
// TODO(bugs.webrtc.org/10739): Deprecate the old OnData and make this one
|
||||
// pure virtual.
|
||||
return OnData(audio_data, bits_per_sample, sample_rate, number_of_channels,
|
||||
number_of_frames);
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual ~AudioTrackSinkInterface() {}
|
||||
|
||||
@ -13,6 +13,8 @@
|
||||
|
||||
#include <cstddef>
|
||||
|
||||
#include "absl/types/optional.h"
|
||||
|
||||
namespace cricket {
|
||||
|
||||
// Abstract interface for providing the audio data.
|
||||
@ -23,11 +25,13 @@ class AudioSource {
|
||||
class Sink {
|
||||
public:
|
||||
// Callback to receive data from the AudioSource.
|
||||
virtual void OnData(const void* audio_data,
|
||||
int bits_per_sample,
|
||||
int sample_rate,
|
||||
size_t number_of_channels,
|
||||
size_t number_of_frames) = 0;
|
||||
virtual void OnData(
|
||||
const void* audio_data,
|
||||
int bits_per_sample,
|
||||
int sample_rate,
|
||||
size_t number_of_channels,
|
||||
size_t number_of_frames,
|
||||
absl::optional<int64_t> absolute_capture_timestamp_ms) = 0;
|
||||
|
||||
// Called when the AudioSource is going away.
|
||||
virtual void OnClose() = 0;
|
||||
|
||||
@ -39,7 +39,8 @@ void FakeVoiceMediaChannel::VoiceChannelAudioSink::OnData(
|
||||
int bits_per_sample,
|
||||
int sample_rate,
|
||||
size_t number_of_channels,
|
||||
size_t number_of_frames) {}
|
||||
size_t number_of_frames,
|
||||
absl::optional<int64_t> absolute_capture_timestamp_ms) {}
|
||||
void FakeVoiceMediaChannel::VoiceChannelAudioSink::OnClose() {
|
||||
source_ = nullptr;
|
||||
}
|
||||
|
||||
@ -368,7 +368,8 @@ class FakeVoiceMediaChannel : public RtpHelper<VoiceMediaChannel> {
|
||||
int bits_per_sample,
|
||||
int sample_rate,
|
||||
size_t number_of_channels,
|
||||
size_t number_of_frames) override;
|
||||
size_t number_of_frames,
|
||||
absl::optional<int64_t> absolute_capture_timestamp_ms) override;
|
||||
void OnClose() override;
|
||||
AudioSource* source() const;
|
||||
|
||||
|
||||
@ -870,7 +870,8 @@ class WebRtcVoiceMediaChannel::WebRtcAudioSendStream
|
||||
int bits_per_sample,
|
||||
int sample_rate,
|
||||
size_t number_of_channels,
|
||||
size_t number_of_frames) override {
|
||||
size_t number_of_frames,
|
||||
absl::optional<int64_t> absolute_capture_timestamp_ms) override {
|
||||
RTC_DCHECK_EQ(16, bits_per_sample);
|
||||
RTC_CHECK_RUNS_SERIALIZED(&audio_capture_race_checker_);
|
||||
RTC_DCHECK(stream_);
|
||||
@ -879,6 +880,8 @@ class WebRtcVoiceMediaChannel::WebRtcAudioSendStream
|
||||
audio_frame->timestamp_, static_cast<const int16_t*>(audio_data),
|
||||
number_of_frames, sample_rate, audio_frame->speech_type_,
|
||||
audio_frame->vad_activity_, number_of_channels);
|
||||
// TODO(bugs.webrtc.org/10739): pass absolute_capture_timestamp_ms to
|
||||
// stream_.
|
||||
stream_->SendAudioData(std::move(audio_frame));
|
||||
}
|
||||
|
||||
|
||||
@ -144,8 +144,11 @@ void RemoteAudioSource::OnData(const AudioSinkInterface::Data& audio) {
|
||||
// Called on the externally-owned audio callback thread, via/from webrtc.
|
||||
rtc::CritScope lock(&sink_lock_);
|
||||
for (auto* sink : sinks_) {
|
||||
// When peerconnection acts as an audio source, it should not provide
|
||||
// absolute capture timestamp.
|
||||
sink->OnData(audio.data, 16, audio.sample_rate, audio.channels,
|
||||
audio.samples_per_channel);
|
||||
audio.samples_per_channel,
|
||||
/*absolute_capture_timestamp_ms=*/absl::nullopt);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -372,15 +372,17 @@ LocalAudioSinkAdapter::~LocalAudioSinkAdapter() {
|
||||
sink_->OnClose();
|
||||
}
|
||||
|
||||
void LocalAudioSinkAdapter::OnData(const void* audio_data,
|
||||
int bits_per_sample,
|
||||
int sample_rate,
|
||||
size_t number_of_channels,
|
||||
size_t number_of_frames) {
|
||||
void LocalAudioSinkAdapter::OnData(
|
||||
const void* audio_data,
|
||||
int bits_per_sample,
|
||||
int sample_rate,
|
||||
size_t number_of_channels,
|
||||
size_t number_of_frames,
|
||||
absl::optional<int64_t> absolute_capture_timestamp_ms) {
|
||||
rtc::CritScope lock(&lock_);
|
||||
if (sink_) {
|
||||
sink_->OnData(audio_data, bits_per_sample, sample_rate, number_of_channels,
|
||||
number_of_frames);
|
||||
number_of_frames, absolute_capture_timestamp_ms);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -213,7 +213,19 @@ class LocalAudioSinkAdapter : public AudioTrackSinkInterface,
|
||||
int bits_per_sample,
|
||||
int sample_rate,
|
||||
size_t number_of_channels,
|
||||
size_t number_of_frames) override;
|
||||
size_t number_of_frames,
|
||||
absl::optional<int64_t> absolute_capture_timestamp_ms) override;
|
||||
|
||||
// AudioSinkInterface implementation.
|
||||
void OnData(const void* audio_data,
|
||||
int bits_per_sample,
|
||||
int sample_rate,
|
||||
size_t number_of_channels,
|
||||
size_t number_of_frames) override {
|
||||
OnData(audio_data, bits_per_sample, sample_rate, number_of_channels,
|
||||
number_of_frames,
|
||||
/*absolute_capture_timestamp_ms=*/absl::nullopt);
|
||||
}
|
||||
|
||||
// cricket::AudioSource implementation.
|
||||
void SetSink(cricket::AudioSource::Sink* sink) override;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user