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

Side by Side Diff: webrtc/audio/audio_state.cc

Issue 2383023003: Test upload to see if the ADM is passed correctly to audio_state. (Closed)
Patch Set: forgot send-stream config Created 4 years, 2 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
« no previous file with comments | « webrtc/audio/audio_state.h ('k') | webrtc/audio/audio_state_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #include "webrtc/audio/audio_state.h" 11 #include "webrtc/audio/audio_state.h"
12 12
13 #include "webrtc/base/atomicops.h" 13 #include "webrtc/base/atomicops.h"
14 #include "webrtc/base/checks.h" 14 #include "webrtc/base/checks.h"
15 #include "webrtc/base/logging.h" 15 #include "webrtc/base/logging.h"
16 #include "webrtc/voice_engine/include/voe_errors.h" 16 #include "webrtc/voice_engine/include/voe_errors.h"
17 #include "webrtc/modules/audio_device/include/audio_device.h"
18 #include "webrtc/modules/audio_device/include/audio_device_defines.h"
17 19
18 namespace webrtc { 20 namespace webrtc {
21
22 namespace {
23 class MiMAudioTransport : public AudioTransport {
24 public:
25 MiMAudioTransport(AudioTransport* voe_audio_transport)
26 : voe_audio_transport_(voe_audio_transport) {}
27
28 virtual ~MiMAudioTransport() {}
29
30 int32_t RecordedDataIsAvailable(const void* audioSamples,
31 const size_t nSamples,
32 const size_t nBytesPerSample,
33 const size_t nChannels,
34 const uint32_t samplesPerSec,
35 const uint32_t totalDelayMS,
36 const int32_t clockDrift,
37 const uint32_t currentMicLevel,
38 const bool keyPressed,
39 uint32_t& newMicLevel) override {
40 // Used by native apps to PUSH data to VoE (those that do not
41 // supply their own ADM).
42
43 // Just pass through.
44 return voe_audio_transport_->RecordedDataIsAvailable(
45 audioSamples, nSamples, nBytesPerSample, nChannels, samplesPerSec,
46 totalDelayMS, clockDrift, currentMicLevel, keyPressed, newMicLevel);
47 }
48 int32_t NeedMorePlayData(const size_t nSamples,
49 const size_t nBytesPerSample,
50 const size_t nChannels,
51 const uint32_t samplesPerSec,
52 void* audioSamples,
53 size_t& nSamplesOut,
54 int64_t* elapsed_time_ms,
55 int64_t* ntp_time_ms) override {
56 return voe_audio_transport_->NeedMorePlayData(
57 nSamples, nBytesPerSample, nChannels, samplesPerSec, audioSamples,
58 nSamplesOut, elapsed_time_ms, ntp_time_ms);
59 }
60
61 void PushCaptureData(int voe_channel,
62 const void* audio_data,
63 int bits_per_sample,
64 int sample_rate,
65 size_t number_of_channels,
66 size_t number_of_frames) override {
67 RTC_NOTREACHED();
68 }
69 void PullRenderData(int bits_per_sample,
70 int sample_rate,
71 size_t number_of_channels,
72 size_t number_of_frames,
73 void* audio_data,
74 int64_t* elapsed_time_ms,
75 int64_t* ntp_time_ms) override {
76 return voe_audio_transport_->PullRenderData(
77 bits_per_sample, sample_rate, number_of_channels, number_of_frames,
78 audio_data, elapsed_time_ms, ntp_time_ms);
79 }
80
81 private:
82 AudioTransport* voe_audio_transport_;
83 };
84 } // namespace
85
19 namespace internal { 86 namespace internal {
20 87
21 AudioState::AudioState(const AudioState::Config& config) 88 AudioState::AudioState(const AudioState::Config& config)
22 : config_(config), voe_base_(config.voice_engine) { 89 : config_(config), voe_base_(config.voice_engine) {
23 process_thread_checker_.DetachFromThread(); 90 process_thread_checker_.DetachFromThread();
24 // Only one AudioState should be created per VoiceEngine. 91 // Only one AudioState should be created per VoiceEngine.
25 RTC_CHECK(voe_base_->RegisterVoiceEngineObserver(*this) != -1); 92 RTC_CHECK(voe_base_->RegisterVoiceEngineObserver(*this) != -1);
93
94 if (voe_base_->audio_transport()) {
95 mim_transport_ = new MiMAudioTransport(voe_base_->audio_transport());
96
97 // first reset the old one (which is VoE->audio_transport())
98 audio_device()->RegisterAudioCallback(nullptr);
99 audio_device()->RegisterAudioCallback(mim_transport_);
100 } else {
101 LOG(LS_INFO) << "fail fail fail!";
102 }
26 } 103 }
27 104
28 AudioState::~AudioState() { 105 AudioState::~AudioState() {
29 RTC_DCHECK(thread_checker_.CalledOnValidThread()); 106 RTC_DCHECK(thread_checker_.CalledOnValidThread());
107 // voe_base_->audio_device_module()->RegisterAudioCallback(nullptr);
30 voe_base_->DeRegisterVoiceEngineObserver(); 108 voe_base_->DeRegisterVoiceEngineObserver();
109 if (mim_transport_) {
110 delete static_cast<MiMAudioTransport*>(mim_transport_);
111 }
31 } 112 }
32 113
33 VoiceEngine* AudioState::voice_engine() { 114 VoiceEngine* AudioState::voice_engine() {
34 RTC_DCHECK(thread_checker_.CalledOnValidThread()); 115 RTC_DCHECK(thread_checker_.CalledOnValidThread());
35 return config_.voice_engine; 116 return config_.voice_engine;
36 } 117 }
37 118
119 AudioDeviceModule* AudioState::audio_device() {
120 RTC_DCHECK(thread_checker_.CalledOnValidThread());
121 // if (config_.audio_device_module) {
122 // return config_.audio_device_module;
123 // }
124 RTC_CHECK(voe_base_->audio_device_module());
125 return voe_base_->audio_device_module();
126 }
127
38 bool AudioState::typing_noise_detected() const { 128 bool AudioState::typing_noise_detected() const {
39 RTC_DCHECK(thread_checker_.CalledOnValidThread()); 129 RTC_DCHECK(thread_checker_.CalledOnValidThread());
40 rtc::CritScope lock(&crit_sect_); 130 rtc::CritScope lock(&crit_sect_);
41 return typing_noise_detected_; 131 return typing_noise_detected_;
42 } 132 }
43 133
44 // Reference count; implementation copied from rtc::RefCountedObject. 134 // Reference count; implementation copied from rtc::RefCountedObject.
45 int AudioState::AddRef() const { 135 int AudioState::AddRef() const {
46 return rtc::AtomicOps::Increment(&ref_count_); 136 return rtc::AtomicOps::Increment(&ref_count_);
47 } 137 }
(...skipping 22 matching lines...) Expand all
70 typing_noise_detected_ = false; 160 typing_noise_detected_ = false;
71 } 161 }
72 } 162 }
73 } // namespace internal 163 } // namespace internal
74 164
75 rtc::scoped_refptr<AudioState> AudioState::Create( 165 rtc::scoped_refptr<AudioState> AudioState::Create(
76 const AudioState::Config& config) { 166 const AudioState::Config& config) {
77 return rtc::scoped_refptr<AudioState>(new internal::AudioState(config)); 167 return rtc::scoped_refptr<AudioState>(new internal::AudioState(config));
78 } 168 }
79 } // namespace webrtc 169 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/audio/audio_state.h ('k') | webrtc/audio/audio_state_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698