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 16 matching lines...) Expand all Loading... |
27 #include "webrtc/modules/rtp_rtcp/source/byte_io.h" | 27 #include "webrtc/modules/rtp_rtcp/source/byte_io.h" |
28 #include "webrtc/modules/utility/interface/process_thread.h" | 28 #include "webrtc/modules/utility/interface/process_thread.h" |
29 #include "webrtc/system_wrappers/interface/cpu_info.h" | 29 #include "webrtc/system_wrappers/interface/cpu_info.h" |
30 #include "webrtc/system_wrappers/interface/critical_section_wrapper.h" | 30 #include "webrtc/system_wrappers/interface/critical_section_wrapper.h" |
31 #include "webrtc/system_wrappers/interface/logging.h" | 31 #include "webrtc/system_wrappers/interface/logging.h" |
32 #include "webrtc/system_wrappers/interface/rw_lock_wrapper.h" | 32 #include "webrtc/system_wrappers/interface/rw_lock_wrapper.h" |
33 #include "webrtc/system_wrappers/interface/trace.h" | 33 #include "webrtc/system_wrappers/interface/trace.h" |
34 #include "webrtc/system_wrappers/interface/trace_event.h" | 34 #include "webrtc/system_wrappers/interface/trace_event.h" |
35 #include "webrtc/video/video_receive_stream.h" | 35 #include "webrtc/video/video_receive_stream.h" |
36 #include "webrtc/video/video_send_stream.h" | 36 #include "webrtc/video/video_send_stream.h" |
| 37 #include "webrtc/video_engine/call_stats.h" |
37 #include "webrtc/voice_engine/include/voe_codec.h" | 38 #include "webrtc/voice_engine/include/voe_codec.h" |
38 | 39 |
39 namespace webrtc { | 40 namespace webrtc { |
40 | 41 |
41 const int Call::Config::kDefaultStartBitrateBps = 300000; | 42 const int Call::Config::kDefaultStartBitrateBps = 300000; |
42 | 43 |
43 namespace internal { | 44 namespace internal { |
44 | 45 |
45 class Call : public webrtc::Call, public PacketReceiver { | 46 class Call : public webrtc::Call, public PacketReceiver { |
46 public: | 47 public: |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 DeliveryStatus DeliverRtp(MediaType media_type, | 88 DeliveryStatus DeliverRtp(MediaType media_type, |
88 const uint8_t* packet, | 89 const uint8_t* packet, |
89 size_t length, | 90 size_t length, |
90 const PacketTime& packet_time); | 91 const PacketTime& packet_time); |
91 | 92 |
92 void ConfigureSync(const std::string& sync_group) | 93 void ConfigureSync(const std::string& sync_group) |
93 EXCLUSIVE_LOCKS_REQUIRED(receive_crit_); | 94 EXCLUSIVE_LOCKS_REQUIRED(receive_crit_); |
94 | 95 |
95 const int num_cpu_cores_; | 96 const int num_cpu_cores_; |
96 const rtc::scoped_ptr<ProcessThread> module_process_thread_; | 97 const rtc::scoped_ptr<ProcessThread> module_process_thread_; |
| 98 const rtc::scoped_ptr<CallStats> call_stats_; |
97 const rtc::scoped_ptr<ChannelGroup> channel_group_; | 99 const rtc::scoped_ptr<ChannelGroup> channel_group_; |
98 Call::Config config_; | 100 Call::Config config_; |
99 rtc::ThreadChecker configuration_thread_checker_; | 101 rtc::ThreadChecker configuration_thread_checker_; |
100 | 102 |
101 // Needs to be held while write-locking |receive_crit_| or |send_crit_|. This | 103 // Needs to be held while write-locking |receive_crit_| or |send_crit_|. This |
102 // ensures that we have a consistent network state signalled to all senders | 104 // ensures that we have a consistent network state signalled to all senders |
103 // and receivers. | 105 // and receivers. |
104 rtc::CriticalSection network_enabled_crit_; | 106 rtc::CriticalSection network_enabled_crit_; |
105 bool network_enabled_ GUARDED_BY(network_enabled_crit_); | 107 bool network_enabled_ GUARDED_BY(network_enabled_crit_); |
106 | 108 |
(...skipping 24 matching lines...) Expand all Loading... |
131 | 133 |
132 Call* Call::Create(const Call::Config& config) { | 134 Call* Call::Create(const Call::Config& config) { |
133 return new internal::Call(config); | 135 return new internal::Call(config); |
134 } | 136 } |
135 | 137 |
136 namespace internal { | 138 namespace internal { |
137 | 139 |
138 Call::Call(const Call::Config& config) | 140 Call::Call(const Call::Config& config) |
139 : num_cpu_cores_(CpuInfo::DetectNumberOfCores()), | 141 : num_cpu_cores_(CpuInfo::DetectNumberOfCores()), |
140 module_process_thread_(ProcessThread::Create("ModuleProcessThread")), | 142 module_process_thread_(ProcessThread::Create("ModuleProcessThread")), |
141 channel_group_(new ChannelGroup(module_process_thread_.get())), | 143 call_stats_(new CallStats()), |
| 144 channel_group_(new ChannelGroup(module_process_thread_.get(), |
| 145 call_stats_.get())), |
142 config_(config), | 146 config_(config), |
143 network_enabled_(true), | 147 network_enabled_(true), |
144 receive_crit_(RWLockWrapper::CreateRWLock()), | 148 receive_crit_(RWLockWrapper::CreateRWLock()), |
145 send_crit_(RWLockWrapper::CreateRWLock()), | 149 send_crit_(RWLockWrapper::CreateRWLock()), |
146 event_log_(nullptr) { | 150 event_log_(nullptr) { |
147 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); | 151 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); |
148 RTC_DCHECK_GE(config.bitrate_config.min_bitrate_bps, 0); | 152 RTC_DCHECK_GE(config.bitrate_config.min_bitrate_bps, 0); |
149 RTC_DCHECK_GE(config.bitrate_config.start_bitrate_bps, | 153 RTC_DCHECK_GE(config.bitrate_config.start_bitrate_bps, |
150 config.bitrate_config.min_bitrate_bps); | 154 config.bitrate_config.min_bitrate_bps); |
151 if (config.bitrate_config.max_bitrate_bps != -1) { | 155 if (config.bitrate_config.max_bitrate_bps != -1) { |
152 RTC_DCHECK_GE(config.bitrate_config.max_bitrate_bps, | 156 RTC_DCHECK_GE(config.bitrate_config.max_bitrate_bps, |
153 config.bitrate_config.start_bitrate_bps); | 157 config.bitrate_config.start_bitrate_bps); |
154 } | 158 } |
155 if (config.voice_engine) { | 159 if (config.voice_engine) { |
156 VoECodec* voe_codec = VoECodec::GetInterface(config.voice_engine); | 160 VoECodec* voe_codec = VoECodec::GetInterface(config.voice_engine); |
157 if (voe_codec) { | 161 if (voe_codec) { |
158 event_log_ = voe_codec->GetEventLog(); | 162 event_log_ = voe_codec->GetEventLog(); |
159 voe_codec->Release(); | 163 voe_codec->Release(); |
160 } | 164 } |
161 } | 165 } |
162 | 166 |
163 Trace::CreateTrace(); | 167 Trace::CreateTrace(); |
164 module_process_thread_->Start(); | 168 module_process_thread_->Start(); |
| 169 module_process_thread_->RegisterModule(call_stats_.get()); |
165 | 170 |
166 channel_group_->SetBweBitrates(config_.bitrate_config.min_bitrate_bps, | 171 channel_group_->SetBweBitrates(config_.bitrate_config.min_bitrate_bps, |
167 config_.bitrate_config.start_bitrate_bps, | 172 config_.bitrate_config.start_bitrate_bps, |
168 config_.bitrate_config.max_bitrate_bps); | 173 config_.bitrate_config.max_bitrate_bps); |
169 } | 174 } |
170 | 175 |
171 Call::~Call() { | 176 Call::~Call() { |
172 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); | 177 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); |
173 RTC_CHECK(audio_send_ssrcs_.empty()); | 178 RTC_CHECK(audio_send_ssrcs_.empty()); |
174 RTC_CHECK(video_send_ssrcs_.empty()); | 179 RTC_CHECK(video_send_ssrcs_.empty()); |
175 RTC_CHECK(video_send_streams_.empty()); | 180 RTC_CHECK(video_send_streams_.empty()); |
176 RTC_CHECK(audio_receive_ssrcs_.empty()); | 181 RTC_CHECK(audio_receive_ssrcs_.empty()); |
177 RTC_CHECK(video_receive_ssrcs_.empty()); | 182 RTC_CHECK(video_receive_ssrcs_.empty()); |
178 RTC_CHECK(video_receive_streams_.empty()); | 183 RTC_CHECK(video_receive_streams_.empty()); |
179 | 184 |
| 185 module_process_thread_->DeRegisterModule(call_stats_.get()); |
180 module_process_thread_->Stop(); | 186 module_process_thread_->Stop(); |
181 Trace::ReturnTrace(); | 187 Trace::ReturnTrace(); |
182 } | 188 } |
183 | 189 |
184 PacketReceiver* Call::Receiver() { | 190 PacketReceiver* Call::Receiver() { |
185 // TODO(solenberg): Some test cases in EndToEndTest use this from a different | 191 // TODO(solenberg): Some test cases in EndToEndTest use this from a different |
186 // thread. Re-enable once that is fixed. | 192 // thread. Re-enable once that is fixed. |
187 // RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); | 193 // RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); |
188 return this; | 194 return this; |
189 } | 195 } |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
265 | 271 |
266 webrtc::VideoSendStream* Call::CreateVideoSendStream( | 272 webrtc::VideoSendStream* Call::CreateVideoSendStream( |
267 const webrtc::VideoSendStream::Config& config, | 273 const webrtc::VideoSendStream::Config& config, |
268 const VideoEncoderConfig& encoder_config) { | 274 const VideoEncoderConfig& encoder_config) { |
269 TRACE_EVENT0("webrtc", "Call::CreateVideoSendStream"); | 275 TRACE_EVENT0("webrtc", "Call::CreateVideoSendStream"); |
270 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); | 276 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); |
271 | 277 |
272 // TODO(mflodman): Base the start bitrate on a current bandwidth estimate, if | 278 // TODO(mflodman): Base the start bitrate on a current bandwidth estimate, if |
273 // the call has already started. | 279 // the call has already started. |
274 VideoSendStream* send_stream = new VideoSendStream(num_cpu_cores_, | 280 VideoSendStream* send_stream = new VideoSendStream(num_cpu_cores_, |
275 module_process_thread_.get(), channel_group_.get(), config, | 281 module_process_thread_.get(), call_stats_.get(), channel_group_.get(), |
276 encoder_config, suspended_video_send_ssrcs_); | 282 config, encoder_config, suspended_video_send_ssrcs_); |
277 | 283 |
278 // This needs to be taken before send_crit_ as both locks need to be held | 284 // This needs to be taken before send_crit_ as both locks need to be held |
279 // while changing network state. | 285 // while changing network state. |
280 rtc::CritScope lock(&network_enabled_crit_); | 286 rtc::CritScope lock(&network_enabled_crit_); |
281 WriteLockScoped write_lock(*send_crit_); | 287 WriteLockScoped write_lock(*send_crit_); |
282 for (uint32_t ssrc : config.rtp.ssrcs) { | 288 for (uint32_t ssrc : config.rtp.ssrcs) { |
283 RTC_DCHECK(video_send_ssrcs_.find(ssrc) == video_send_ssrcs_.end()); | 289 RTC_DCHECK(video_send_ssrcs_.find(ssrc) == video_send_ssrcs_.end()); |
284 video_send_ssrcs_[ssrc] = send_stream; | 290 video_send_ssrcs_[ssrc] = send_stream; |
285 } | 291 } |
286 video_send_streams_.insert(send_stream); | 292 video_send_streams_.insert(send_stream); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
326 | 332 |
327 delete send_stream_impl; | 333 delete send_stream_impl; |
328 } | 334 } |
329 | 335 |
330 webrtc::VideoReceiveStream* Call::CreateVideoReceiveStream( | 336 webrtc::VideoReceiveStream* Call::CreateVideoReceiveStream( |
331 const webrtc::VideoReceiveStream::Config& config) { | 337 const webrtc::VideoReceiveStream::Config& config) { |
332 TRACE_EVENT0("webrtc", "Call::CreateVideoReceiveStream"); | 338 TRACE_EVENT0("webrtc", "Call::CreateVideoReceiveStream"); |
333 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); | 339 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); |
334 VideoReceiveStream* receive_stream = new VideoReceiveStream( | 340 VideoReceiveStream* receive_stream = new VideoReceiveStream( |
335 num_cpu_cores_, channel_group_.get(), config, config_.voice_engine, | 341 num_cpu_cores_, channel_group_.get(), config, config_.voice_engine, |
336 module_process_thread_.get()); | 342 module_process_thread_.get(), call_stats_.get()); |
337 | 343 |
338 // This needs to be taken before receive_crit_ as both locks need to be held | 344 // This needs to be taken before receive_crit_ as both locks need to be held |
339 // while changing network state. | 345 // while changing network state. |
340 rtc::CritScope lock(&network_enabled_crit_); | 346 rtc::CritScope lock(&network_enabled_crit_); |
341 WriteLockScoped write_lock(*receive_crit_); | 347 WriteLockScoped write_lock(*receive_crit_); |
342 RTC_DCHECK(video_receive_ssrcs_.find(config.rtp.remote_ssrc) == | 348 RTC_DCHECK(video_receive_ssrcs_.find(config.rtp.remote_ssrc) == |
343 video_receive_ssrcs_.end()); | 349 video_receive_ssrcs_.end()); |
344 video_receive_ssrcs_[config.rtp.remote_ssrc] = receive_stream; | 350 video_receive_ssrcs_[config.rtp.remote_ssrc] = receive_stream; |
345 // TODO(pbos): Configure different RTX payloads per receive payload. | 351 // TODO(pbos): Configure different RTX payloads per receive payload. |
346 VideoReceiveStream::Config::Rtp::RtxMap::const_iterator it = | 352 VideoReceiveStream::Config::Rtp::RtxMap::const_iterator it = |
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
592 // thread. Then this check can be enabled. | 598 // thread. Then this check can be enabled. |
593 // RTC_DCHECK(!configuration_thread_checker_.CalledOnValidThread()); | 599 // RTC_DCHECK(!configuration_thread_checker_.CalledOnValidThread()); |
594 if (RtpHeaderParser::IsRtcp(packet, length)) | 600 if (RtpHeaderParser::IsRtcp(packet, length)) |
595 return DeliverRtcp(media_type, packet, length); | 601 return DeliverRtcp(media_type, packet, length); |
596 | 602 |
597 return DeliverRtp(media_type, packet, length, packet_time); | 603 return DeliverRtp(media_type, packet, length, packet_time); |
598 } | 604 } |
599 | 605 |
600 } // namespace internal | 606 } // namespace internal |
601 } // namespace webrtc | 607 } // namespace webrtc |
OLD | NEW |