OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_audio_device_impl.h" | 5 #include "content/renderer/media/webrtc_audio_device_impl.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
10 #include "base/trace_event/trace_event.h" | |
10 #include "base/win/windows_version.h" | 11 #include "base/win/windows_version.h" |
11 #include "content/renderer/media/webrtc/processed_local_audio_source.h" | 12 #include "content/renderer/media/webrtc/processed_local_audio_source.h" |
12 #include "content/renderer/media/webrtc_audio_renderer.h" | 13 #include "content/renderer/media/webrtc_audio_renderer.h" |
13 #include "media/audio/sample_rates.h" | 14 #include "media/audio/sample_rates.h" |
14 #include "media/base/audio_bus.h" | 15 #include "media/base/audio_bus.h" |
15 #include "media/base/audio_parameters.h" | 16 #include "media/base/audio_parameters.h" |
16 | 17 |
17 using media::AudioParameters; | 18 using media::AudioParameters; |
18 using media::ChannelLayout; | 19 using media::ChannelLayout; |
19 | 20 |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
87 int frames_per_10_ms = (sample_rate / 100); | 88 int frames_per_10_ms = (sample_rate / 100); |
88 int bytes_per_sample = sizeof(render_buffer_[0]); | 89 int bytes_per_sample = sizeof(render_buffer_[0]); |
89 // Client should always ask for 10ms. | 90 // Client should always ask for 10ms. |
90 DCHECK_EQ(audio_bus->frames(), frames_per_10_ms); | 91 DCHECK_EQ(audio_bus->frames(), frames_per_10_ms); |
91 | 92 |
92 // Get 10ms audio and copy result to temporary byte buffer. | 93 // Get 10ms audio and copy result to temporary byte buffer. |
93 int64_t elapsed_time_ms = -1; | 94 int64_t elapsed_time_ms = -1; |
94 int64_t ntp_time_ms = -1; | 95 int64_t ntp_time_ms = -1; |
95 static const int kBitsPerByte = 8; | 96 static const int kBitsPerByte = 8; |
96 int16_t* audio_data = &render_buffer_[0]; | 97 int16_t* audio_data = &render_buffer_[0]; |
98 | |
99 TRACE_EVENT_BEGIN0("audio", "VoE::PullRenderData"); | |
Henrik Grunell
2016/08/22 08:29:06
Nit: VoiceEngine is kind of an implementation deta
| |
97 audio_transport_callback_->PullRenderData( | 100 audio_transport_callback_->PullRenderData( |
98 bytes_per_sample * kBitsPerByte, sample_rate, audio_bus->channels(), | 101 bytes_per_sample * kBitsPerByte, sample_rate, audio_bus->channels(), |
99 frames_per_10_ms, audio_data, &elapsed_time_ms, &ntp_time_ms); | 102 frames_per_10_ms, audio_data, &elapsed_time_ms, &ntp_time_ms); |
103 TRACE_EVENT_END0("audio", "VoE::PullRenderData"); | |
100 if (elapsed_time_ms >= 0) { | 104 if (elapsed_time_ms >= 0) { |
101 *current_time = base::TimeDelta::FromMilliseconds(elapsed_time_ms); | 105 *current_time = base::TimeDelta::FromMilliseconds(elapsed_time_ms); |
102 } | 106 } |
103 | 107 |
104 // De-interleave each channel and convert to 32-bit floating-point | 108 // De-interleave each channel and convert to 32-bit floating-point |
105 // with nominal range -1.0 -> +1.0 to match the callback format. | 109 // with nominal range -1.0 -> +1.0 to match the callback format. |
106 audio_bus->FromInterleaved(&render_buffer_[0], | 110 audio_bus->FromInterleaved(&render_buffer_[0], |
107 audio_bus->frames(), | 111 audio_bus->frames(), |
108 bytes_per_sample); | 112 bytes_per_sample); |
109 | 113 |
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
487 | 491 |
488 *session_id = device_info.session_id; | 492 *session_id = device_info.session_id; |
489 *output_sample_rate = device_info.device.matched_output.sample_rate; | 493 *output_sample_rate = device_info.device.matched_output.sample_rate; |
490 *output_frames_per_buffer = | 494 *output_frames_per_buffer = |
491 device_info.device.matched_output.frames_per_buffer; | 495 device_info.device.matched_output.frames_per_buffer; |
492 | 496 |
493 return true; | 497 return true; |
494 } | 498 } |
495 | 499 |
496 } // namespace content | 500 } // namespace content |
OLD | NEW |