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

Side by Side Diff: content/renderer/media/webrtc/webrtc_audio_sink_adapter.cc

Issue 1834323002: MediaStream audio: Refactor 3 separate "glue" implementations into one. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: REBASE + Workaround to ensure MediaStreamAudioProcessor is destroyed on the main thread. Created 4 years, 7 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "base/logging.h"
6 #include "content/renderer/media/webrtc/webrtc_audio_sink_adapter.h"
7 #include "media/base/audio_bus.h"
8 #include "third_party/webrtc/api/mediastreaminterface.h"
9
10 namespace content {
11
12 WebRtcAudioSinkAdapter::WebRtcAudioSinkAdapter(
13 webrtc::AudioTrackSinkInterface* sink)
14 : sink_(sink) {
15 DCHECK(sink);
16 }
17
18 WebRtcAudioSinkAdapter::~WebRtcAudioSinkAdapter() {
19 }
20
21 bool WebRtcAudioSinkAdapter::IsEqual(
22 const webrtc::AudioTrackSinkInterface* other) const {
23 return (other == sink_);
24 }
25
26 void WebRtcAudioSinkAdapter::OnData(const media::AudioBus& audio_bus,
27 base::TimeTicks estimated_capture_time) {
28 DCHECK_EQ(audio_bus.frames(), params_.frames_per_buffer());
29 DCHECK_EQ(audio_bus.channels(), params_.channels());
30 // TODO(henrika): Remove this conversion once the interface in libjingle
31 // supports float vectors.
32 audio_bus.ToInterleaved(audio_bus.frames(),
33 sizeof(interleaved_data_[0]),
34 interleaved_data_.get());
35 sink_->OnData(interleaved_data_.get(),
36 16,
37 params_.sample_rate(),
38 audio_bus.channels(),
39 audio_bus.frames());
40 }
41
42 void WebRtcAudioSinkAdapter::OnSetFormat(
43 const media::AudioParameters& params) {
44 DCHECK(params.IsValid());
45 params_ = params;
46 const int num_pcm16_data_elements =
47 params_.frames_per_buffer() * params_.channels();
48 interleaved_data_.reset(new int16_t[num_pcm16_data_elements]);
49 }
50
51 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698