OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2013 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 |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 GUARDED_BY(receive_crit_); | 116 GUARDED_BY(receive_crit_); |
117 | 117 |
118 rtc::scoped_ptr<RWLockWrapper> send_crit_; | 118 rtc::scoped_ptr<RWLockWrapper> send_crit_; |
119 // Audio and Video send streams are owned by the client that creates them. | 119 // Audio and Video send streams are owned by the client that creates them. |
120 std::map<uint32_t, AudioSendStream*> audio_send_ssrcs_ GUARDED_BY(send_crit_); | 120 std::map<uint32_t, AudioSendStream*> audio_send_ssrcs_ GUARDED_BY(send_crit_); |
121 std::map<uint32_t, VideoSendStream*> video_send_ssrcs_ GUARDED_BY(send_crit_); | 121 std::map<uint32_t, VideoSendStream*> video_send_ssrcs_ GUARDED_BY(send_crit_); |
122 std::set<VideoSendStream*> video_send_streams_ GUARDED_BY(send_crit_); | 122 std::set<VideoSendStream*> video_send_streams_ GUARDED_BY(send_crit_); |
123 | 123 |
124 VideoSendStream::RtpStateMap suspended_video_send_ssrcs_; | 124 VideoSendStream::RtpStateMap suspended_video_send_ssrcs_; |
125 | 125 |
126 RtcEventLog* event_log_; | 126 RtcEventLog* event_log_ = nullptr; |
| 127 VoECodec* voe_codec_ = nullptr; |
127 | 128 |
128 RTC_DISALLOW_COPY_AND_ASSIGN(Call); | 129 RTC_DISALLOW_COPY_AND_ASSIGN(Call); |
129 }; | 130 }; |
130 } // namespace internal | 131 } // namespace internal |
131 | 132 |
132 Call* Call::Create(const Call::Config& config) { | 133 Call* Call::Create(const Call::Config& config) { |
133 return new internal::Call(config); | 134 return new internal::Call(config); |
134 } | 135 } |
135 | 136 |
136 namespace internal { | 137 namespace internal { |
137 | 138 |
138 Call::Call(const Call::Config& config) | 139 Call::Call(const Call::Config& config) |
139 : num_cpu_cores_(CpuInfo::DetectNumberOfCores()), | 140 : num_cpu_cores_(CpuInfo::DetectNumberOfCores()), |
140 module_process_thread_(ProcessThread::Create("ModuleProcessThread")), | 141 module_process_thread_(ProcessThread::Create("ModuleProcessThread")), |
141 channel_group_(new ChannelGroup(module_process_thread_.get())), | 142 channel_group_(new ChannelGroup(module_process_thread_.get())), |
142 config_(config), | 143 config_(config), |
143 network_enabled_(true), | 144 network_enabled_(true), |
144 receive_crit_(RWLockWrapper::CreateRWLock()), | 145 receive_crit_(RWLockWrapper::CreateRWLock()), |
145 send_crit_(RWLockWrapper::CreateRWLock()), | 146 send_crit_(RWLockWrapper::CreateRWLock()) { |
146 event_log_(nullptr) { | |
147 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); | 147 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); |
148 RTC_DCHECK_GE(config.bitrate_config.min_bitrate_bps, 0); | 148 RTC_DCHECK_GE(config.bitrate_config.min_bitrate_bps, 0); |
149 RTC_DCHECK_GE(config.bitrate_config.start_bitrate_bps, | 149 RTC_DCHECK_GE(config.bitrate_config.start_bitrate_bps, |
150 config.bitrate_config.min_bitrate_bps); | 150 config.bitrate_config.min_bitrate_bps); |
151 if (config.bitrate_config.max_bitrate_bps != -1) { | 151 if (config.bitrate_config.max_bitrate_bps != -1) { |
152 RTC_DCHECK_GE(config.bitrate_config.max_bitrate_bps, | 152 RTC_DCHECK_GE(config.bitrate_config.max_bitrate_bps, |
153 config.bitrate_config.start_bitrate_bps); | 153 config.bitrate_config.start_bitrate_bps); |
154 } | 154 } |
155 if (config.voice_engine) { | 155 if (config.voice_engine) { |
156 VoECodec* voe_codec = VoECodec::GetInterface(config.voice_engine); | 156 // Keep a reference to VoECodec, so we're sure the VoiceEngine lives for the |
157 if (voe_codec) { | 157 // duration of the call. |
158 event_log_ = voe_codec->GetEventLog(); | 158 voe_codec_ = VoECodec::GetInterface(config.voice_engine); |
159 voe_codec->Release(); | 159 if (voe_codec_) |
160 } | 160 event_log_ = voe_codec_->GetEventLog(); |
161 } | 161 } |
162 | 162 |
163 Trace::CreateTrace(); | 163 Trace::CreateTrace(); |
164 module_process_thread_->Start(); | 164 module_process_thread_->Start(); |
165 | 165 |
166 channel_group_->SetBweBitrates(config_.bitrate_config.min_bitrate_bps, | 166 channel_group_->SetBweBitrates(config_.bitrate_config.min_bitrate_bps, |
167 config_.bitrate_config.start_bitrate_bps, | 167 config_.bitrate_config.start_bitrate_bps, |
168 config_.bitrate_config.max_bitrate_bps); | 168 config_.bitrate_config.max_bitrate_bps); |
169 } | 169 } |
170 | 170 |
171 Call::~Call() { | 171 Call::~Call() { |
172 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); | 172 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); |
173 RTC_CHECK(audio_send_ssrcs_.empty()); | 173 RTC_CHECK(audio_send_ssrcs_.empty()); |
174 RTC_CHECK(video_send_ssrcs_.empty()); | 174 RTC_CHECK(video_send_ssrcs_.empty()); |
175 RTC_CHECK(video_send_streams_.empty()); | 175 RTC_CHECK(video_send_streams_.empty()); |
176 RTC_CHECK(audio_receive_ssrcs_.empty()); | 176 RTC_CHECK(audio_receive_ssrcs_.empty()); |
177 RTC_CHECK(video_receive_ssrcs_.empty()); | 177 RTC_CHECK(video_receive_ssrcs_.empty()); |
178 RTC_CHECK(video_receive_streams_.empty()); | 178 RTC_CHECK(video_receive_streams_.empty()); |
179 | 179 |
180 module_process_thread_->Stop(); | 180 module_process_thread_->Stop(); |
181 Trace::ReturnTrace(); | 181 Trace::ReturnTrace(); |
| 182 |
| 183 if (voe_codec_) |
| 184 voe_codec_->Release(); |
182 } | 185 } |
183 | 186 |
184 PacketReceiver* Call::Receiver() { | 187 PacketReceiver* Call::Receiver() { |
185 // TODO(solenberg): Some test cases in EndToEndTest use this from a different | 188 // TODO(solenberg): Some test cases in EndToEndTest use this from a different |
186 // thread. Re-enable once that is fixed. | 189 // thread. Re-enable once that is fixed. |
187 // RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); | 190 // RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); |
188 return this; | 191 return this; |
189 } | 192 } |
190 | 193 |
191 webrtc::AudioSendStream* Call::CreateAudioSendStream( | 194 webrtc::AudioSendStream* Call::CreateAudioSendStream( |
(...skipping 30 matching lines...) Expand all Loading... |
222 RTC_DCHECK(num_deleted == 1); | 225 RTC_DCHECK(num_deleted == 1); |
223 } | 226 } |
224 delete audio_send_stream; | 227 delete audio_send_stream; |
225 } | 228 } |
226 | 229 |
227 webrtc::AudioReceiveStream* Call::CreateAudioReceiveStream( | 230 webrtc::AudioReceiveStream* Call::CreateAudioReceiveStream( |
228 const webrtc::AudioReceiveStream::Config& config) { | 231 const webrtc::AudioReceiveStream::Config& config) { |
229 TRACE_EVENT0("webrtc", "Call::CreateAudioReceiveStream"); | 232 TRACE_EVENT0("webrtc", "Call::CreateAudioReceiveStream"); |
230 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); | 233 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); |
231 AudioReceiveStream* receive_stream = new AudioReceiveStream( | 234 AudioReceiveStream* receive_stream = new AudioReceiveStream( |
232 channel_group_->GetRemoteBitrateEstimator(false), config); | 235 channel_group_->GetRemoteBitrateEstimator(false), config, |
| 236 config_.voice_engine); |
233 { | 237 { |
234 WriteLockScoped write_lock(*receive_crit_); | 238 WriteLockScoped write_lock(*receive_crit_); |
235 RTC_DCHECK(audio_receive_ssrcs_.find(config.rtp.remote_ssrc) == | 239 RTC_DCHECK(audio_receive_ssrcs_.find(config.rtp.remote_ssrc) == |
236 audio_receive_ssrcs_.end()); | 240 audio_receive_ssrcs_.end()); |
237 audio_receive_ssrcs_[config.rtp.remote_ssrc] = receive_stream; | 241 audio_receive_ssrcs_[config.rtp.remote_ssrc] = receive_stream; |
238 ConfigureSync(config.sync_group); | 242 ConfigureSync(config.sync_group); |
239 } | 243 } |
240 return receive_stream; | 244 return receive_stream; |
241 } | 245 } |
242 | 246 |
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
592 // thread. Then this check can be enabled. | 596 // thread. Then this check can be enabled. |
593 // RTC_DCHECK(!configuration_thread_checker_.CalledOnValidThread()); | 597 // RTC_DCHECK(!configuration_thread_checker_.CalledOnValidThread()); |
594 if (RtpHeaderParser::IsRtcp(packet, length)) | 598 if (RtpHeaderParser::IsRtcp(packet, length)) |
595 return DeliverRtcp(media_type, packet, length); | 599 return DeliverRtcp(media_type, packet, length); |
596 | 600 |
597 return DeliverRtp(media_type, packet, length, packet_time); | 601 return DeliverRtp(media_type, packet, length, packet_time); |
598 } | 602 } |
599 | 603 |
600 } // namespace internal | 604 } // namespace internal |
601 } // namespace webrtc | 605 } // namespace webrtc |
OLD | NEW |