| 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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 const uint8_t* packet, | 87 const uint8_t* packet, |
| 88 size_t length, | 88 size_t length, |
| 89 const PacketTime& packet_time); | 89 const PacketTime& packet_time); |
| 90 | 90 |
| 91 void ConfigureSync(const std::string& sync_group) | 91 void ConfigureSync(const std::string& sync_group) |
| 92 EXCLUSIVE_LOCKS_REQUIRED(receive_crit_); | 92 EXCLUSIVE_LOCKS_REQUIRED(receive_crit_); |
| 93 | 93 |
| 94 const int num_cpu_cores_; | 94 const int num_cpu_cores_; |
| 95 const rtc::scoped_ptr<ProcessThread> module_process_thread_; | 95 const rtc::scoped_ptr<ProcessThread> module_process_thread_; |
| 96 const rtc::scoped_ptr<ChannelGroup> channel_group_; | 96 const rtc::scoped_ptr<ChannelGroup> channel_group_; |
| 97 volatile int next_channel_id_; | |
| 98 Call::Config config_; | 97 Call::Config config_; |
| 99 | 98 |
| 100 // Needs to be held while write-locking |receive_crit_| or |send_crit_|. This | 99 // Needs to be held while write-locking |receive_crit_| or |send_crit_|. This |
| 101 // ensures that we have a consistent network state signalled to all senders | 100 // ensures that we have a consistent network state signalled to all senders |
| 102 // and receivers. | 101 // and receivers. |
| 103 rtc::CriticalSection network_enabled_crit_; | 102 rtc::CriticalSection network_enabled_crit_; |
| 104 bool network_enabled_ GUARDED_BY(network_enabled_crit_); | 103 bool network_enabled_ GUARDED_BY(network_enabled_crit_); |
| 105 | 104 |
| 106 rtc::scoped_ptr<RWLockWrapper> receive_crit_; | 105 rtc::scoped_ptr<RWLockWrapper> receive_crit_; |
| 107 // Audio and Video receive streams are owned by the client that creates them. | 106 // Audio and Video receive streams are owned by the client that creates them. |
| (...skipping 23 matching lines...) Expand all Loading... |
| 131 Call* Call::Create(const Call::Config& config) { | 130 Call* Call::Create(const Call::Config& config) { |
| 132 return new internal::Call(config); | 131 return new internal::Call(config); |
| 133 } | 132 } |
| 134 | 133 |
| 135 namespace internal { | 134 namespace internal { |
| 136 | 135 |
| 137 Call::Call(const Call::Config& config) | 136 Call::Call(const Call::Config& config) |
| 138 : num_cpu_cores_(CpuInfo::DetectNumberOfCores()), | 137 : num_cpu_cores_(CpuInfo::DetectNumberOfCores()), |
| 139 module_process_thread_(ProcessThread::Create("ModuleProcessThread")), | 138 module_process_thread_(ProcessThread::Create("ModuleProcessThread")), |
| 140 channel_group_(new ChannelGroup(module_process_thread_.get())), | 139 channel_group_(new ChannelGroup(module_process_thread_.get())), |
| 141 next_channel_id_(0), | |
| 142 config_(config), | 140 config_(config), |
| 143 network_enabled_(true), | 141 network_enabled_(true), |
| 144 receive_crit_(RWLockWrapper::CreateRWLock()), | 142 receive_crit_(RWLockWrapper::CreateRWLock()), |
| 145 send_crit_(RWLockWrapper::CreateRWLock()), | 143 send_crit_(RWLockWrapper::CreateRWLock()), |
| 146 event_log_(nullptr) { | 144 event_log_(nullptr) { |
| 147 RTC_DCHECK_GE(config.bitrate_config.min_bitrate_bps, 0); | 145 RTC_DCHECK_GE(config.bitrate_config.min_bitrate_bps, 0); |
| 148 RTC_DCHECK_GE(config.bitrate_config.start_bitrate_bps, | 146 RTC_DCHECK_GE(config.bitrate_config.start_bitrate_bps, |
| 149 config.bitrate_config.min_bitrate_bps); | 147 config.bitrate_config.min_bitrate_bps); |
| 150 if (config.bitrate_config.max_bitrate_bps != -1) { | 148 if (config.bitrate_config.max_bitrate_bps != -1) { |
| 151 RTC_DCHECK_GE(config.bitrate_config.max_bitrate_bps, | 149 RTC_DCHECK_GE(config.bitrate_config.max_bitrate_bps, |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 253 } | 251 } |
| 254 | 252 |
| 255 webrtc::VideoSendStream* Call::CreateVideoSendStream( | 253 webrtc::VideoSendStream* Call::CreateVideoSendStream( |
| 256 const webrtc::VideoSendStream::Config& config, | 254 const webrtc::VideoSendStream::Config& config, |
| 257 const VideoEncoderConfig& encoder_config) { | 255 const VideoEncoderConfig& encoder_config) { |
| 258 TRACE_EVENT0("webrtc", "Call::CreateVideoSendStream"); | 256 TRACE_EVENT0("webrtc", "Call::CreateVideoSendStream"); |
| 259 | 257 |
| 260 // TODO(mflodman): Base the start bitrate on a current bandwidth estimate, if | 258 // TODO(mflodman): Base the start bitrate on a current bandwidth estimate, if |
| 261 // the call has already started. | 259 // the call has already started. |
| 262 VideoSendStream* send_stream = new VideoSendStream(num_cpu_cores_, | 260 VideoSendStream* send_stream = new VideoSendStream(num_cpu_cores_, |
| 263 module_process_thread_.get(), channel_group_.get(), | 261 module_process_thread_.get(), channel_group_.get(), config, |
| 264 rtc::AtomicOps::Increment(&next_channel_id_), config, encoder_config, | 262 encoder_config, suspended_video_send_ssrcs_); |
| 265 suspended_video_send_ssrcs_); | |
| 266 | 263 |
| 267 // This needs to be taken before send_crit_ as both locks need to be held | 264 // This needs to be taken before send_crit_ as both locks need to be held |
| 268 // while changing network state. | 265 // while changing network state. |
| 269 rtc::CritScope lock(&network_enabled_crit_); | 266 rtc::CritScope lock(&network_enabled_crit_); |
| 270 WriteLockScoped write_lock(*send_crit_); | 267 WriteLockScoped write_lock(*send_crit_); |
| 271 for (uint32_t ssrc : config.rtp.ssrcs) { | 268 for (uint32_t ssrc : config.rtp.ssrcs) { |
| 272 RTC_DCHECK(video_send_ssrcs_.find(ssrc) == video_send_ssrcs_.end()); | 269 RTC_DCHECK(video_send_ssrcs_.find(ssrc) == video_send_ssrcs_.end()); |
| 273 video_send_ssrcs_[ssrc] = send_stream; | 270 video_send_ssrcs_[ssrc] = send_stream; |
| 274 } | 271 } |
| 275 video_send_streams_.insert(send_stream); | 272 video_send_streams_.insert(send_stream); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 312 suspended_video_send_ssrcs_[it->first] = it->second; | 309 suspended_video_send_ssrcs_[it->first] = it->second; |
| 313 } | 310 } |
| 314 | 311 |
| 315 delete send_stream_impl; | 312 delete send_stream_impl; |
| 316 } | 313 } |
| 317 | 314 |
| 318 webrtc::VideoReceiveStream* Call::CreateVideoReceiveStream( | 315 webrtc::VideoReceiveStream* Call::CreateVideoReceiveStream( |
| 319 const webrtc::VideoReceiveStream::Config& config) { | 316 const webrtc::VideoReceiveStream::Config& config) { |
| 320 TRACE_EVENT0("webrtc", "Call::CreateVideoReceiveStream"); | 317 TRACE_EVENT0("webrtc", "Call::CreateVideoReceiveStream"); |
| 321 VideoReceiveStream* receive_stream = new VideoReceiveStream( | 318 VideoReceiveStream* receive_stream = new VideoReceiveStream( |
| 322 num_cpu_cores_, channel_group_.get(), | 319 num_cpu_cores_, channel_group_.get(), config, config_.voice_engine, |
| 323 rtc::AtomicOps::Increment(&next_channel_id_), config, | 320 module_process_thread_.get()); |
| 324 config_.voice_engine, module_process_thread_.get()); | |
| 325 | 321 |
| 326 // This needs to be taken before receive_crit_ as both locks need to be held | 322 // This needs to be taken before receive_crit_ as both locks need to be held |
| 327 // while changing network state. | 323 // while changing network state. |
| 328 rtc::CritScope lock(&network_enabled_crit_); | 324 rtc::CritScope lock(&network_enabled_crit_); |
| 329 WriteLockScoped write_lock(*receive_crit_); | 325 WriteLockScoped write_lock(*receive_crit_); |
| 330 RTC_DCHECK(video_receive_ssrcs_.find(config.rtp.remote_ssrc) == | 326 RTC_DCHECK(video_receive_ssrcs_.find(config.rtp.remote_ssrc) == |
| 331 video_receive_ssrcs_.end()); | 327 video_receive_ssrcs_.end()); |
| 332 video_receive_ssrcs_[config.rtp.remote_ssrc] = receive_stream; | 328 video_receive_ssrcs_[config.rtp.remote_ssrc] = receive_stream; |
| 333 // TODO(pbos): Configure different RTX payloads per receive payload. | 329 // TODO(pbos): Configure different RTX payloads per receive payload. |
| 334 VideoReceiveStream::Config::Rtp::RtxMap::const_iterator it = | 330 VideoReceiveStream::Config::Rtp::RtxMap::const_iterator it = |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 569 size_t length, | 565 size_t length, |
| 570 const PacketTime& packet_time) { | 566 const PacketTime& packet_time) { |
| 571 if (RtpHeaderParser::IsRtcp(packet, length)) | 567 if (RtpHeaderParser::IsRtcp(packet, length)) |
| 572 return DeliverRtcp(media_type, packet, length); | 568 return DeliverRtcp(media_type, packet, length); |
| 573 | 569 |
| 574 return DeliverRtp(media_type, packet, length, packet_time); | 570 return DeliverRtp(media_type, packet, length, packet_time); |
| 575 } | 571 } |
| 576 | 572 |
| 577 } // namespace internal | 573 } // namespace internal |
| 578 } // namespace webrtc | 574 } // namespace webrtc |
| OLD | NEW |