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