OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 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/voice_engine/voe_external_media_impl.h" | 11 #include "webrtc/voice_engine/voe_external_media_impl.h" |
12 | 12 |
13 #include "webrtc/audio/utility/audio_frame_operations.h" | 13 #include "webrtc/audio/utility/audio_frame_operations.h" |
14 #include "webrtc/system_wrappers/include/trace.h" | 14 #include "webrtc/system_wrappers/include/trace.h" |
15 #include "webrtc/voice_engine/channel.h" | 15 #include "webrtc/voice_engine/channel.h" |
16 #include "webrtc/voice_engine/include/voe_errors.h" | 16 #include "webrtc/voice_engine/include/voe_errors.h" |
17 #include "webrtc/voice_engine/output_mixer.h" | 17 #include "webrtc/voice_engine/output_mixer.h" |
18 #include "webrtc/voice_engine/transmit_mixer.h" | 18 #include "webrtc/voice_engine/transmit_mixer.h" |
19 #include "webrtc/voice_engine/voice_engine_impl.h" | 19 #include "webrtc/voice_engine/voice_engine_impl.h" |
20 | 20 |
21 namespace webrtc { | 21 namespace webrtc { |
22 | 22 |
23 VoEExternalMedia* VoEExternalMedia::GetInterface(VoiceEngine* voiceEngine) { | 23 VoEExternalMedia* VoEExternalMedia::GetInterface(VoiceEngine* voiceEngine) { |
24 if (NULL == voiceEngine) { | 24 if (nullptr == voiceEngine) { |
25 return NULL; | 25 return nullptr; |
26 } | 26 } |
27 VoiceEngineImpl* s = static_cast<VoiceEngineImpl*>(voiceEngine); | 27 VoiceEngineImpl* s = static_cast<VoiceEngineImpl*>(voiceEngine); |
28 s->AddRef(); | 28 s->AddRef(); |
29 return s; | 29 return s; |
30 } | 30 } |
31 | 31 |
32 VoEExternalMediaImpl::VoEExternalMediaImpl(voe::SharedData* shared) | 32 VoEExternalMediaImpl::VoEExternalMediaImpl(voe::SharedData* shared) |
33 : | 33 : |
34 #ifdef WEBRTC_VOE_EXTERNAL_REC_AND_PLAYOUT | 34 #ifdef WEBRTC_VOE_EXTERNAL_REC_AND_PLAYOUT |
35 playout_delay_ms_(0), | 35 playout_delay_ms_(0), |
(...skipping 18 matching lines...) Expand all Loading... |
54 channel, type, &processObject); | 54 channel, type, &processObject); |
55 if (!shared_->statistics().Initialized()) { | 55 if (!shared_->statistics().Initialized()) { |
56 shared_->SetLastError(VE_NOT_INITED, kTraceError); | 56 shared_->SetLastError(VE_NOT_INITED, kTraceError); |
57 return -1; | 57 return -1; |
58 } | 58 } |
59 switch (type) { | 59 switch (type) { |
60 case kPlaybackPerChannel: | 60 case kPlaybackPerChannel: |
61 case kRecordingPerChannel: { | 61 case kRecordingPerChannel: { |
62 voe::ChannelOwner ch = shared_->channel_manager().GetChannel(channel); | 62 voe::ChannelOwner ch = shared_->channel_manager().GetChannel(channel); |
63 voe::Channel* channelPtr = ch.channel(); | 63 voe::Channel* channelPtr = ch.channel(); |
64 if (channelPtr == NULL) { | 64 if (channelPtr == nullptr) { |
65 shared_->SetLastError( | 65 shared_->SetLastError( |
66 VE_CHANNEL_NOT_VALID, kTraceError, | 66 VE_CHANNEL_NOT_VALID, kTraceError, |
67 "RegisterExternalMediaProcessing() failed to locate " | 67 "RegisterExternalMediaProcessing() failed to locate " |
68 "channel"); | 68 "channel"); |
69 return -1; | 69 return -1; |
70 } | 70 } |
71 return channelPtr->RegisterExternalMediaProcessing(type, processObject); | 71 return channelPtr->RegisterExternalMediaProcessing(type, processObject); |
72 } | 72 } |
73 case kPlaybackAllChannelsMixed: { | 73 case kPlaybackAllChannelsMixed: { |
74 return shared_->output_mixer()->RegisterExternalMediaProcessing( | 74 return shared_->output_mixer()->RegisterExternalMediaProcessing( |
(...skipping 15 matching lines...) Expand all Loading... |
90 "DeRegisterExternalMediaProcessing(channel=%d)", channel); | 90 "DeRegisterExternalMediaProcessing(channel=%d)", channel); |
91 if (!shared_->statistics().Initialized()) { | 91 if (!shared_->statistics().Initialized()) { |
92 shared_->SetLastError(VE_NOT_INITED, kTraceError); | 92 shared_->SetLastError(VE_NOT_INITED, kTraceError); |
93 return -1; | 93 return -1; |
94 } | 94 } |
95 switch (type) { | 95 switch (type) { |
96 case kPlaybackPerChannel: | 96 case kPlaybackPerChannel: |
97 case kRecordingPerChannel: { | 97 case kRecordingPerChannel: { |
98 voe::ChannelOwner ch = shared_->channel_manager().GetChannel(channel); | 98 voe::ChannelOwner ch = shared_->channel_manager().GetChannel(channel); |
99 voe::Channel* channelPtr = ch.channel(); | 99 voe::Channel* channelPtr = ch.channel(); |
100 if (channelPtr == NULL) { | 100 if (channelPtr == nullptr) { |
101 shared_->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, | 101 shared_->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, |
102 "RegisterExternalMediaProcessing() " | 102 "RegisterExternalMediaProcessing() " |
103 "failed to locate channel"); | 103 "failed to locate channel"); |
104 return -1; | 104 return -1; |
105 } | 105 } |
106 return channelPtr->DeRegisterExternalMediaProcessing(type); | 106 return channelPtr->DeRegisterExternalMediaProcessing(type); |
107 } | 107 } |
108 case kPlaybackAllChannelsMixed: { | 108 case kPlaybackAllChannelsMixed: { |
109 return shared_->output_mixer()->DeRegisterExternalMediaProcessing(); | 109 return shared_->output_mixer()->DeRegisterExternalMediaProcessing(); |
110 } | 110 } |
111 case kRecordingAllChannelsMixed: | 111 case kRecordingAllChannelsMixed: |
112 case kRecordingPreprocessing: { | 112 case kRecordingPreprocessing: { |
113 return shared_->transmit_mixer()->DeRegisterExternalMediaProcessing(type); | 113 return shared_->transmit_mixer()->DeRegisterExternalMediaProcessing(type); |
114 } | 114 } |
115 } | 115 } |
116 return -1; | 116 return -1; |
117 } | 117 } |
118 | 118 |
119 int VoEExternalMediaImpl::GetAudioFrame(int channel, int desired_sample_rate_hz, | 119 int VoEExternalMediaImpl::GetAudioFrame(int channel, int desired_sample_rate_hz, |
120 AudioFrame* frame) { | 120 AudioFrame* frame) { |
121 if (!shared_->statistics().Initialized()) { | 121 if (!shared_->statistics().Initialized()) { |
122 shared_->SetLastError(VE_NOT_INITED, kTraceError); | 122 shared_->SetLastError(VE_NOT_INITED, kTraceError); |
123 return -1; | 123 return -1; |
124 } | 124 } |
125 voe::ChannelOwner ch = shared_->channel_manager().GetChannel(channel); | 125 voe::ChannelOwner ch = shared_->channel_manager().GetChannel(channel); |
126 voe::Channel* channelPtr = ch.channel(); | 126 voe::Channel* channelPtr = ch.channel(); |
127 if (channelPtr == NULL) { | 127 if (channelPtr == nullptr) { |
128 shared_->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, | 128 shared_->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, |
129 "GetAudioFrame() failed to locate channel"); | 129 "GetAudioFrame() failed to locate channel"); |
130 return -1; | 130 return -1; |
131 } | 131 } |
132 if (!channelPtr->ExternalMixing()) { | 132 if (!channelPtr->ExternalMixing()) { |
133 shared_->SetLastError(VE_INVALID_OPERATION, kTraceError, | 133 shared_->SetLastError(VE_INVALID_OPERATION, kTraceError, |
134 "GetAudioFrame() was called on channel that is not" | 134 "GetAudioFrame() was called on channel that is not" |
135 " externally mixed."); | 135 " externally mixed."); |
136 return -1; | 136 return -1; |
137 } | 137 } |
(...skipping 20 matching lines...) Expand all Loading... |
158 int VoEExternalMediaImpl::SetExternalMixing(int channel, bool enable) { | 158 int VoEExternalMediaImpl::SetExternalMixing(int channel, bool enable) { |
159 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, | 159 WEBRTC_TRACE(kTraceApiCall, kTraceVoice, |
160 VoEId(shared_->instance_id(), channel), | 160 VoEId(shared_->instance_id(), channel), |
161 "SetExternalMixing(channel=%d, enable=%d)", channel, enable); | 161 "SetExternalMixing(channel=%d, enable=%d)", channel, enable); |
162 if (!shared_->statistics().Initialized()) { | 162 if (!shared_->statistics().Initialized()) { |
163 shared_->SetLastError(VE_NOT_INITED, kTraceError); | 163 shared_->SetLastError(VE_NOT_INITED, kTraceError); |
164 return -1; | 164 return -1; |
165 } | 165 } |
166 voe::ChannelOwner ch = shared_->channel_manager().GetChannel(channel); | 166 voe::ChannelOwner ch = shared_->channel_manager().GetChannel(channel); |
167 voe::Channel* channelPtr = ch.channel(); | 167 voe::Channel* channelPtr = ch.channel(); |
168 if (channelPtr == NULL) { | 168 if (channelPtr == nullptr) { |
169 shared_->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, | 169 shared_->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, |
170 "SetExternalMixing() failed to locate channel"); | 170 "SetExternalMixing() failed to locate channel"); |
171 return -1; | 171 return -1; |
172 } | 172 } |
173 return channelPtr->SetExternalMixing(enable); | 173 return channelPtr->SetExternalMixing(enable); |
174 } | 174 } |
175 | 175 |
176 } // namespace webrtc | 176 } // namespace webrtc |
OLD | NEW |