Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(118)

Unified Diff: content/renderer/media/webrtc/webrtc_audio_sink_adapter.cc

Issue 1647773002: MediaStream audio sourcing: Bypass audio processing for non-WebRTC cases. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: NOT FOR REVIEW -- This will be broken-up across multiple CLs. Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/renderer/media/webrtc/webrtc_audio_sink_adapter.cc
diff --git a/content/renderer/media/webrtc/webrtc_audio_sink_adapter.cc b/content/renderer/media/webrtc/webrtc_audio_sink_adapter.cc
index 2679aff9648a438574fc06749be4af57b5e724fb..d038fe87566e8ce9e7b2a4b71144b07d1dbca07b 100644
--- a/content/renderer/media/webrtc/webrtc_audio_sink_adapter.cc
+++ b/content/renderer/media/webrtc/webrtc_audio_sink_adapter.cc
@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "base/bind.h"
+#include "base/bind_helpers.h"
#include "base/logging.h"
#include "content/renderer/media/webrtc/webrtc_audio_sink_adapter.h"
#include "media/base/audio_bus.h"
@@ -11,7 +13,10 @@ namespace content {
WebRtcAudioSinkAdapter::WebRtcAudioSinkAdapter(
webrtc::AudioTrackSinkInterface* sink)
- : sink_(sink) {
+ : sink_(sink),
+ rechunker_(base::TimeDelta::FromMilliseconds(10),
+ base::Bind(&WebRtcAudioSinkAdapter::DeliverRechunkedAudio,
+ base::Unretained(this))) {
DCHECK(sink);
}
@@ -25,26 +30,33 @@ bool WebRtcAudioSinkAdapter::IsEqual(
void WebRtcAudioSinkAdapter::OnData(const media::AudioBus& audio_bus,
base::TimeTicks estimated_capture_time) {
- DCHECK_EQ(audio_bus.frames(), params_.frames_per_buffer());
- DCHECK_EQ(audio_bus.channels(), params_.channels());
+ // The following will result in zero, one, or multiple synchronous calls to
+ // DeliverRechunkedAudio().
+ rechunker_.Push(audio_bus, estimated_capture_time - base::TimeTicks());
+}
+
+void WebRtcAudioSinkAdapter::DeliverRechunkedAudio(
+ const media::AudioBus& audio_bus,
+ base::TimeDelta timestamp) {
// TODO(henrika): Remove this conversion once the interface in libjingle
// supports float vectors.
audio_bus.ToInterleaved(audio_bus.frames(),
sizeof(interleaved_data_[0]),
interleaved_data_.get());
+ // TODO(miu): Why doesn't a WebRTC sink care about the reference timestamp?
+ // How is AV sync achieved otherwise?
sink_->OnData(interleaved_data_.get(),
16,
- params_.sample_rate(),
+ rechunker_.sample_rate(),
audio_bus.channels(),
audio_bus.frames());
}
-void WebRtcAudioSinkAdapter::OnSetFormat(
- const media::AudioParameters& params) {
+void WebRtcAudioSinkAdapter::OnSetFormat(const media::AudioParameters& params) {
DCHECK(params.IsValid());
- params_ = params;
+ rechunker_.SetSampleRate(params.sample_rate());
const int num_pcm16_data_elements =
- params_.frames_per_buffer() * params_.channels();
+ rechunker_.output_frames() * params.channels();
interleaved_data_.reset(new int16_t[num_pcm16_data_elements]);
}

Powered by Google App Engine
This is Rietveld 408576698