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

Side by Side Diff: content/renderer/media/webrtc_local_audio_renderer.cc

Issue 37793005: move the APM to chrome. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 1 month 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/renderer/media/webrtc_local_audio_renderer.h" 5 #include "content/renderer/media/webrtc_local_audio_renderer.h"
6 6
7 #include "base/debug/trace_event.h" 7 #include "base/debug/trace_event.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/message_loop/message_loop_proxy.h" 9 #include "base/message_loop/message_loop_proxy.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 } 52 }
53 53
54 return audio_bus->frames(); 54 return audio_bus->frames();
55 } 55 }
56 56
57 void WebRtcLocalAudioRenderer::OnRenderError() { 57 void WebRtcLocalAudioRenderer::OnRenderError() {
58 NOTIMPLEMENTED(); 58 NOTIMPLEMENTED();
59 } 59 }
60 60
61 // content::WebRtcAudioCapturerSink implementation 61 // content::WebRtcAudioCapturerSink implementation
62 int WebRtcLocalAudioRenderer::CaptureData(const std::vector<int>& channels, 62 void WebRtcLocalAudioRenderer::CaptureData(const std::vector<int>& channels,
63 const int16* audio_data, 63 const int16* audio_data,
64 int sample_rate, 64 int sample_rate,
65 int number_of_channels, 65 int number_of_channels,
66 int number_of_frames, 66 int number_of_frames) {
67 int audio_delay_milliseconds,
68 int current_volume,
69 bool need_audio_processing,
70 bool key_pressed) {
71 TRACE_EVENT0("audio", "WebRtcLocalAudioRenderer::CaptureData"); 67 TRACE_EVENT0("audio", "WebRtcLocalAudioRenderer::CaptureData");
72 base::AutoLock auto_lock(thread_lock_); 68 base::AutoLock auto_lock(thread_lock_);
73 if (!playing_ || !volume_) 69 if (!playing_ || !volume_)
74 return 0; 70 return;
75 71
76 // Push captured audio to FIFO so it can be read by a local sink. 72 // Push captured audio to FIFO so it can be read by a local sink.
77 if (loopback_fifo_) { 73 if (loopback_fifo_) {
78 if (loopback_fifo_->frames() + number_of_frames <= 74 if (loopback_fifo_->frames() + number_of_frames <=
79 loopback_fifo_->max_frames()) { 75 loopback_fifo_->max_frames()) {
80 scoped_ptr<media::AudioBus> audio_source = media::AudioBus::Create( 76 scoped_ptr<media::AudioBus> audio_source = media::AudioBus::Create(
81 number_of_channels, number_of_frames); 77 number_of_channels, number_of_frames);
82 audio_source->FromInterleaved(audio_data, 78 audio_source->FromInterleaved(audio_data,
83 audio_source->frames(), 79 audio_source->frames(),
84 sizeof(audio_data[0])); 80 sizeof(audio_data[0]));
85 loopback_fifo_->Push(audio_source.get()); 81 loopback_fifo_->Push(audio_source.get());
86 82
87 base::Time now = base::Time::Now(); 83 base::Time now = base::Time::Now();
88 total_render_time_ += now - last_render_time_; 84 total_render_time_ += now - last_render_time_;
89 last_render_time_ = now; 85 last_render_time_ = now;
90 } else { 86 } else {
91 DVLOG(1) << "FIFO is full"; 87 DVLOG(1) << "FIFO is full";
92 } 88 }
93 } 89 }
94
95 return 0;
96 } 90 }
97 91
98 void WebRtcLocalAudioRenderer::SetCaptureFormat( 92 void WebRtcLocalAudioRenderer::SetCaptureFormat(
99 const media::AudioParameters& params) { 93 const media::AudioParameters& params) {
100 audio_params_ = params; 94 audio_params_ = params;
101 } 95 }
102 96
103 // WebRtcLocalAudioRenderer::WebRtcLocalAudioRenderer implementation. 97 // WebRtcLocalAudioRenderer::WebRtcLocalAudioRenderer implementation.
104 WebRtcLocalAudioRenderer::WebRtcLocalAudioRenderer( 98 WebRtcLocalAudioRenderer::WebRtcLocalAudioRenderer(
105 WebRtcLocalAudioTrack* audio_track, 99 WebRtcLocalAudioTrack* audio_track,
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 return; 275 return;
282 276
283 sink_->Start(); 277 sink_->Start();
284 sink_started_ = true; 278 sink_started_ = true;
285 279
286 UMA_HISTOGRAM_ENUMERATION("Media.LocalRendererSinkStates", 280 UMA_HISTOGRAM_ENUMERATION("Media.LocalRendererSinkStates",
287 kSinkStarted, kSinkStatesMax); 281 kSinkStarted, kSinkStatesMax);
288 } 282 }
289 283
290 } // namespace content 284 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698