Chromium Code Reviews| 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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 58 void NormalUsage() override { | 58 void NormalUsage() override { |
| 59 rtc::CritScope lock(&crit_); | 59 rtc::CritScope lock(&crit_); |
| 60 overuse_callback_->OnLoadUpdate(LoadObserver::kUnderuse); | 60 overuse_callback_->OnLoadUpdate(LoadObserver::kUnderuse); |
| 61 } | 61 } |
| 62 | 62 |
| 63 private: | 63 private: |
| 64 rtc::CriticalSection crit_; | 64 rtc::CriticalSection crit_; |
| 65 LoadObserver* overuse_callback_ GUARDED_BY(crit_); | 65 LoadObserver* overuse_callback_ GUARDED_BY(crit_); |
| 66 }; | 66 }; |
| 67 | 67 |
| 68 class SyncGroup { | |
|
the sun
2015/06/11 11:52:04
Simplify as discussed offline.
pbos-webrtc
2015/06/11 14:48:53
Done.
| |
| 69 public: | |
| 70 explicit SyncGroup(VoiceEngine* voice_engine) : voice_engine_(voice_engine) { | |
| 71 DCHECK(voice_engine != nullptr); | |
| 72 } | |
| 73 | |
| 74 ~SyncGroup() { | |
| 75 DCHECK(audio_channel_map_.empty()); | |
| 76 DCHECK(video_streams_.empty()); | |
| 77 } | |
| 78 | |
| 79 void AddAudioReceiveStream(AudioReceiveStream* receive_stream, | |
| 80 int channel_id) { | |
| 81 if (sync_channel_ == -1) | |
| 82 SetSyncChannel(channel_id); | |
| 83 audio_channel_map_[receive_stream] = channel_id; | |
| 84 } | |
| 85 | |
| 86 void RemoveAudioReceiveStream(AudioReceiveStream* receive_stream) { | |
| 87 DCHECK(audio_channel_map_.find(receive_stream) != audio_channel_map_.end()); | |
| 88 int old_channel = audio_channel_map_[receive_stream]; | |
| 89 int current_channel = sync_channel_; | |
| 90 audio_channel_map_.erase(receive_stream); | |
| 91 if (old_channel != current_channel) | |
| 92 return; | |
| 93 SetSyncChannel( | |
| 94 audio_channel_map_.empty() ? -1 : audio_channel_map_.begin()->second); | |
| 95 } | |
| 96 | |
| 97 void AddVideoReceiveStream(VideoReceiveStream* receive_stream) { | |
| 98 video_streams_.insert(receive_stream); | |
| 99 if (sync_channel_ == -1) | |
| 100 return; | |
| 101 receive_stream->SetSyncChannel(voice_engine_, sync_channel_); | |
| 102 } | |
| 103 | |
| 104 void RemoveVideoReceiveStream(VideoReceiveStream* receive_stream) { | |
| 105 receive_stream->SetSyncChannel(voice_engine_, -1); | |
| 106 video_streams_.erase(receive_stream); | |
| 107 } | |
| 108 | |
| 109 private: | |
| 110 void SetSyncChannel(int channel_id) { | |
| 111 sync_channel_ = channel_id; | |
| 112 for (VideoReceiveStream* video_stream : video_streams_) | |
| 113 video_stream->SetSyncChannel(voice_engine_, channel_id); | |
| 114 } | |
| 115 | |
| 116 VoiceEngine* const voice_engine_; | |
| 117 int sync_channel_ = -1; | |
| 118 std::map<AudioReceiveStream*, int> audio_channel_map_; | |
| 119 std::set<VideoReceiveStream*> video_streams_; | |
| 120 }; | |
| 121 | |
| 68 class Call : public webrtc::Call, public PacketReceiver { | 122 class Call : public webrtc::Call, public PacketReceiver { |
| 69 public: | 123 public: |
| 70 explicit Call(const Call::Config& config); | 124 explicit Call(const Call::Config& config); |
| 71 virtual ~Call(); | 125 virtual ~Call(); |
| 72 | 126 |
| 73 PacketReceiver* Receiver() override; | 127 PacketReceiver* Receiver() override; |
| 74 | 128 |
| 75 webrtc::AudioSendStream* CreateAudioSendStream( | 129 webrtc::AudioSendStream* CreateAudioSendStream( |
| 76 const webrtc::AudioSendStream::Config& config) override; | 130 const webrtc::AudioSendStream::Config& config) override; |
| 77 void DestroyAudioSendStream(webrtc::AudioSendStream* send_stream) override; | 131 void DestroyAudioSendStream(webrtc::AudioSendStream* send_stream) override; |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 102 | 156 |
| 103 private: | 157 private: |
| 104 DeliveryStatus DeliverRtcp(MediaType media_type, const uint8_t* packet, | 158 DeliveryStatus DeliverRtcp(MediaType media_type, const uint8_t* packet, |
| 105 size_t length); | 159 size_t length); |
| 106 DeliveryStatus DeliverRtp(MediaType media_type, const uint8_t* packet, | 160 DeliveryStatus DeliverRtp(MediaType media_type, const uint8_t* packet, |
| 107 size_t length); | 161 size_t length); |
| 108 | 162 |
| 109 void SetBitrateControllerConfig( | 163 void SetBitrateControllerConfig( |
| 110 const webrtc::Call::Config::BitrateConfig& bitrate_config); | 164 const webrtc::Call::Config::BitrateConfig& bitrate_config); |
| 111 | 165 |
| 166 void AddAudioReceiveStreamSync(AudioReceiveStream* stream, | |
| 167 const std::string& sync_group, | |
| 168 int channel_id); | |
| 169 void RemoveAudioReceiveStreamSync(AudioReceiveStream* stream); | |
| 170 | |
| 171 void AddVideoReceiveStreamSync(VideoReceiveStream* stream, | |
| 172 const std::string& sync_group); | |
| 173 void RemoveVideoReceiveStreamSync(VideoReceiveStream* stream); | |
| 174 | |
| 175 SyncGroup* FindSyncGroup(const std::string& sync_group) | |
| 176 EXCLUSIVE_LOCKS_REQUIRED(sync_group_crit_); | |
| 177 | |
| 112 const int num_cpu_cores_; | 178 const int num_cpu_cores_; |
| 113 const rtc::scoped_ptr<ProcessThread> module_process_thread_; | 179 const rtc::scoped_ptr<ProcessThread> module_process_thread_; |
| 114 const rtc::scoped_ptr<ChannelGroup> channel_group_; | 180 const rtc::scoped_ptr<ChannelGroup> channel_group_; |
| 115 const int base_channel_id_; | 181 const int base_channel_id_; |
| 116 volatile int next_channel_id_; | 182 volatile int next_channel_id_; |
| 117 Call::Config config_; | 183 Call::Config config_; |
| 118 | 184 |
| 119 // Needs to be held while write-locking |receive_crit_| or |send_crit_|. This | 185 // Needs to be held while write-locking |receive_crit_| or |send_crit_|. This |
| 120 // ensures that we have a consistent network state signalled to all senders | 186 // ensures that we have a consistent network state signalled to all senders |
| 121 // and receivers. | 187 // and receivers. |
| 122 rtc::CriticalSection network_enabled_crit_; | 188 rtc::CriticalSection network_enabled_crit_; |
| 123 bool network_enabled_ GUARDED_BY(network_enabled_crit_); | 189 bool network_enabled_ GUARDED_BY(network_enabled_crit_); |
| 124 TransportAdapter transport_adapter_; | 190 TransportAdapter transport_adapter_; |
| 125 | 191 |
| 126 rtc::scoped_ptr<RWLockWrapper> receive_crit_; | 192 rtc::scoped_ptr<RWLockWrapper> receive_crit_; |
| 127 std::map<uint32_t, AudioReceiveStream*> audio_receive_ssrcs_ | 193 std::map<uint32_t, AudioReceiveStream*> audio_receive_ssrcs_ |
| 128 GUARDED_BY(receive_crit_); | 194 GUARDED_BY(receive_crit_); |
| 129 std::map<uint32_t, VideoReceiveStream*> video_receive_ssrcs_ | 195 std::map<uint32_t, VideoReceiveStream*> video_receive_ssrcs_ |
| 130 GUARDED_BY(receive_crit_); | 196 GUARDED_BY(receive_crit_); |
| 131 std::set<VideoReceiveStream*> video_receive_streams_ | 197 std::set<VideoReceiveStream*> video_receive_streams_ |
| 132 GUARDED_BY(receive_crit_); | 198 GUARDED_BY(receive_crit_); |
| 133 | 199 |
| 134 rtc::scoped_ptr<RWLockWrapper> send_crit_; | 200 rtc::scoped_ptr<RWLockWrapper> send_crit_; |
| 135 std::map<uint32_t, VideoSendStream*> video_send_ssrcs_ GUARDED_BY(send_crit_); | 201 std::map<uint32_t, VideoSendStream*> video_send_ssrcs_ GUARDED_BY(send_crit_); |
| 136 std::set<VideoSendStream*> video_send_streams_ GUARDED_BY(send_crit_); | 202 std::set<VideoSendStream*> video_send_streams_ GUARDED_BY(send_crit_); |
| 137 | 203 |
| 204 rtc::CriticalSection sync_group_crit_; | |
| 205 std::map<VideoReceiveStream*, std::string> video_sync_groups_ | |
| 206 GUARDED_BY(sync_group_crit_); | |
| 207 std::map<AudioReceiveStream*, std::string> audio_sync_groups_ | |
| 208 GUARDED_BY(sync_group_crit_); | |
| 209 std::map<std::string, SyncGroup*> sync_groups_ GUARDED_BY(sync_group_crit_); | |
| 210 | |
| 138 rtc::scoped_ptr<CpuOveruseObserverProxy> overuse_observer_proxy_; | 211 rtc::scoped_ptr<CpuOveruseObserverProxy> overuse_observer_proxy_; |
| 139 | 212 |
| 140 VideoSendStream::RtpStateMap suspended_video_send_ssrcs_; | 213 VideoSendStream::RtpStateMap suspended_video_send_ssrcs_; |
| 141 | 214 |
| 142 DISALLOW_COPY_AND_ASSIGN(Call); | 215 DISALLOW_COPY_AND_ASSIGN(Call); |
| 143 }; | 216 }; |
| 144 } // namespace internal | 217 } // namespace internal |
| 145 | 218 |
| 146 Call* Call::Create(const Call::Config& config) { | 219 Call* Call::Create(const Call::Config& config) { |
| 147 return new internal::Call(config); | 220 return new internal::Call(config); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 185 | 258 |
| 186 SetBitrateControllerConfig(config_.bitrate_config); | 259 SetBitrateControllerConfig(config_.bitrate_config); |
| 187 } | 260 } |
| 188 | 261 |
| 189 Call::~Call() { | 262 Call::~Call() { |
| 190 CHECK_EQ(0u, video_send_ssrcs_.size()); | 263 CHECK_EQ(0u, video_send_ssrcs_.size()); |
| 191 CHECK_EQ(0u, video_send_streams_.size()); | 264 CHECK_EQ(0u, video_send_streams_.size()); |
| 192 CHECK_EQ(0u, audio_receive_ssrcs_.size()); | 265 CHECK_EQ(0u, audio_receive_ssrcs_.size()); |
| 193 CHECK_EQ(0u, video_receive_ssrcs_.size()); | 266 CHECK_EQ(0u, video_receive_ssrcs_.size()); |
| 194 CHECK_EQ(0u, video_receive_streams_.size()); | 267 CHECK_EQ(0u, video_receive_streams_.size()); |
| 268 for (auto& kv : sync_groups_) | |
| 269 delete kv.second; | |
| 195 | 270 |
| 196 channel_group_->DeleteChannel(base_channel_id_); | 271 channel_group_->DeleteChannel(base_channel_id_); |
| 197 module_process_thread_->Stop(); | 272 module_process_thread_->Stop(); |
| 198 Trace::ReturnTrace(); | 273 Trace::ReturnTrace(); |
| 199 } | 274 } |
| 200 | 275 |
| 201 PacketReceiver* Call::Receiver() { return this; } | 276 PacketReceiver* Call::Receiver() { return this; } |
| 202 | 277 |
| 203 webrtc::AudioSendStream* Call::CreateAudioSendStream( | 278 webrtc::AudioSendStream* Call::CreateAudioSendStream( |
| 204 const webrtc::AudioSendStream::Config& config) { | 279 const webrtc::AudioSendStream::Config& config) { |
| 205 return nullptr; | 280 return nullptr; |
| 206 } | 281 } |
| 207 | 282 |
| 208 void Call::DestroyAudioSendStream(webrtc::AudioSendStream* send_stream) { | 283 void Call::DestroyAudioSendStream(webrtc::AudioSendStream* send_stream) { |
| 209 } | 284 } |
| 210 | 285 |
| 211 webrtc::AudioReceiveStream* Call::CreateAudioReceiveStream( | 286 webrtc::AudioReceiveStream* Call::CreateAudioReceiveStream( |
| 212 const webrtc::AudioReceiveStream::Config& config) { | 287 const webrtc::AudioReceiveStream::Config& config) { |
| 213 TRACE_EVENT0("webrtc", "Call::CreateAudioReceiveStream"); | 288 TRACE_EVENT0("webrtc", "Call::CreateAudioReceiveStream"); |
| 214 LOG(LS_INFO) << "CreateAudioReceiveStream: " << config.ToString(); | 289 LOG(LS_INFO) << "CreateAudioReceiveStream: " << config.ToString(); |
| 215 AudioReceiveStream* receive_stream = new AudioReceiveStream( | 290 AudioReceiveStream* receive_stream = new AudioReceiveStream( |
| 216 channel_group_->GetRemoteBitrateEstimator(), config); | 291 channel_group_->GetRemoteBitrateEstimator(), config); |
| 292 AddAudioReceiveStreamSync(receive_stream, config.sync_group, | |
| 293 config.channel_id); | |
| 217 { | 294 { |
| 218 WriteLockScoped write_lock(*receive_crit_); | 295 WriteLockScoped write_lock(*receive_crit_); |
| 219 DCHECK(audio_receive_ssrcs_.find(config.rtp.remote_ssrc) == | 296 DCHECK(audio_receive_ssrcs_.find(config.rtp.remote_ssrc) == |
| 220 audio_receive_ssrcs_.end()); | 297 audio_receive_ssrcs_.end()); |
| 221 audio_receive_ssrcs_[config.rtp.remote_ssrc] = receive_stream; | 298 audio_receive_ssrcs_[config.rtp.remote_ssrc] = receive_stream; |
| 222 } | 299 } |
| 223 return receive_stream; | 300 return receive_stream; |
| 224 } | 301 } |
| 225 | 302 |
| 226 void Call::DestroyAudioReceiveStream( | 303 void Call::DestroyAudioReceiveStream( |
| 227 webrtc::AudioReceiveStream* receive_stream) { | 304 webrtc::AudioReceiveStream* receive_stream) { |
| 228 TRACE_EVENT0("webrtc", "Call::DestroyAudioReceiveStream"); | 305 TRACE_EVENT0("webrtc", "Call::DestroyAudioReceiveStream"); |
| 229 DCHECK(receive_stream != nullptr); | 306 DCHECK(receive_stream != nullptr); |
| 230 AudioReceiveStream* audio_receive_stream = | 307 AudioReceiveStream* audio_receive_stream = |
| 231 static_cast<AudioReceiveStream*>(receive_stream); | 308 static_cast<AudioReceiveStream*>(receive_stream); |
| 309 RemoveAudioReceiveStreamSync(audio_receive_stream); | |
| 232 { | 310 { |
| 233 WriteLockScoped write_lock(*receive_crit_); | 311 WriteLockScoped write_lock(*receive_crit_); |
| 234 size_t num_deleted = audio_receive_ssrcs_.erase( | 312 size_t num_deleted = audio_receive_ssrcs_.erase( |
| 235 audio_receive_stream->config().rtp.remote_ssrc); | 313 audio_receive_stream->config().rtp.remote_ssrc); |
| 236 DCHECK(num_deleted == 1); | 314 DCHECK(num_deleted == 1); |
| 237 } | 315 } |
| 238 delete audio_receive_stream; | 316 delete audio_receive_stream; |
| 239 } | 317 } |
| 240 | 318 |
| 241 webrtc::VideoSendStream* Call::CreateVideoSendStream( | 319 webrtc::VideoSendStream* Call::CreateVideoSendStream( |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 302 } | 380 } |
| 303 | 381 |
| 304 webrtc::VideoReceiveStream* Call::CreateVideoReceiveStream( | 382 webrtc::VideoReceiveStream* Call::CreateVideoReceiveStream( |
| 305 const webrtc::VideoReceiveStream::Config& config) { | 383 const webrtc::VideoReceiveStream::Config& config) { |
| 306 TRACE_EVENT0("webrtc", "Call::CreateVideoReceiveStream"); | 384 TRACE_EVENT0("webrtc", "Call::CreateVideoReceiveStream"); |
| 307 LOG(LS_INFO) << "CreateVideoReceiveStream: " << config.ToString(); | 385 LOG(LS_INFO) << "CreateVideoReceiveStream: " << config.ToString(); |
| 308 VideoReceiveStream* receive_stream = new VideoReceiveStream( | 386 VideoReceiveStream* receive_stream = new VideoReceiveStream( |
| 309 num_cpu_cores_, base_channel_id_, channel_group_.get(), | 387 num_cpu_cores_, base_channel_id_, channel_group_.get(), |
| 310 rtc::AtomicOps::Increment(&next_channel_id_), config, | 388 rtc::AtomicOps::Increment(&next_channel_id_), config, |
| 311 config_.send_transport, config_.voice_engine); | 389 config_.send_transport, config_.voice_engine); |
| 390 AddVideoReceiveStreamSync(receive_stream, config.sync_group); | |
| 312 | 391 |
| 313 // This needs to be taken before receive_crit_ as both locks need to be held | 392 // This needs to be taken before receive_crit_ as both locks need to be held |
| 314 // while changing network state. | 393 // while changing network state. |
| 315 rtc::CritScope lock(&network_enabled_crit_); | 394 rtc::CritScope lock(&network_enabled_crit_); |
| 316 WriteLockScoped write_lock(*receive_crit_); | 395 WriteLockScoped write_lock(*receive_crit_); |
| 317 DCHECK(video_receive_ssrcs_.find(config.rtp.remote_ssrc) == | 396 DCHECK(video_receive_ssrcs_.find(config.rtp.remote_ssrc) == |
| 318 video_receive_ssrcs_.end()); | 397 video_receive_ssrcs_.end()); |
| 319 video_receive_ssrcs_[config.rtp.remote_ssrc] = receive_stream; | 398 video_receive_ssrcs_[config.rtp.remote_ssrc] = receive_stream; |
| 320 // TODO(pbos): Configure different RTX payloads per receive payload. | 399 // TODO(pbos): Configure different RTX payloads per receive payload. |
| 321 VideoReceiveStream::Config::Rtp::RtxMap::const_iterator it = | 400 VideoReceiveStream::Config::Rtp::RtxMap::const_iterator it = |
| 322 config.rtp.rtx.begin(); | 401 config.rtp.rtx.begin(); |
| 323 if (it != config.rtp.rtx.end()) | 402 if (it != config.rtp.rtx.end()) |
| 324 video_receive_ssrcs_[it->second.ssrc] = receive_stream; | 403 video_receive_ssrcs_[it->second.ssrc] = receive_stream; |
| 325 video_receive_streams_.insert(receive_stream); | 404 video_receive_streams_.insert(receive_stream); |
| 326 | 405 |
| 327 if (!network_enabled_) | 406 if (!network_enabled_) |
| 328 receive_stream->SignalNetworkState(kNetworkDown); | 407 receive_stream->SignalNetworkState(kNetworkDown); |
| 329 return receive_stream; | 408 return receive_stream; |
| 330 } | 409 } |
| 331 | 410 |
| 332 void Call::DestroyVideoReceiveStream( | 411 void Call::DestroyVideoReceiveStream( |
| 333 webrtc::VideoReceiveStream* receive_stream) { | 412 webrtc::VideoReceiveStream* receive_stream) { |
| 334 TRACE_EVENT0("webrtc", "Call::DestroyVideoReceiveStream"); | 413 TRACE_EVENT0("webrtc", "Call::DestroyVideoReceiveStream"); |
| 335 DCHECK(receive_stream != nullptr); | 414 DCHECK(receive_stream != nullptr); |
| 336 | |
| 337 VideoReceiveStream* receive_stream_impl = nullptr; | 415 VideoReceiveStream* receive_stream_impl = nullptr; |
| 338 { | 416 { |
| 339 WriteLockScoped write_lock(*receive_crit_); | 417 WriteLockScoped write_lock(*receive_crit_); |
| 340 // Remove all ssrcs pointing to a receive stream. As RTX retransmits on a | 418 // Remove all ssrcs pointing to a receive stream. As RTX retransmits on a |
| 341 // separate SSRC there can be either one or two. | 419 // separate SSRC there can be either one or two. |
| 342 auto it = video_receive_ssrcs_.begin(); | 420 auto it = video_receive_ssrcs_.begin(); |
| 343 while (it != video_receive_ssrcs_.end()) { | 421 while (it != video_receive_ssrcs_.end()) { |
| 344 if (it->second == static_cast<VideoReceiveStream*>(receive_stream)) { | 422 if (it->second == static_cast<VideoReceiveStream*>(receive_stream)) { |
| 345 if (receive_stream_impl != nullptr) | 423 if (receive_stream_impl != nullptr) |
| 346 DCHECK(receive_stream_impl == it->second); | 424 DCHECK(receive_stream_impl == it->second); |
| 347 receive_stream_impl = it->second; | 425 receive_stream_impl = it->second; |
| 348 video_receive_ssrcs_.erase(it++); | 426 video_receive_ssrcs_.erase(it++); |
| 349 } else { | 427 } else { |
| 350 ++it; | 428 ++it; |
| 351 } | 429 } |
| 352 } | 430 } |
| 353 video_receive_streams_.erase(receive_stream_impl); | 431 video_receive_streams_.erase(receive_stream_impl); |
| 354 } | 432 } |
| 355 CHECK(receive_stream_impl != nullptr); | 433 CHECK(receive_stream_impl != nullptr); |
| 434 RemoveVideoReceiveStreamSync(receive_stream_impl); | |
| 356 delete receive_stream_impl; | 435 delete receive_stream_impl; |
| 357 } | 436 } |
| 358 | 437 |
| 359 Call::Stats Call::GetStats() const { | 438 Call::Stats Call::GetStats() const { |
| 360 Stats stats; | 439 Stats stats; |
| 361 // Fetch available send/receive bitrates. | 440 // Fetch available send/receive bitrates. |
| 362 uint32_t send_bandwidth = 0; | 441 uint32_t send_bandwidth = 0; |
| 363 channel_group_->GetBitrateController()->AvailableBandwidth(&send_bandwidth); | 442 channel_group_->GetBitrateController()->AvailableBandwidth(&send_bandwidth); |
| 364 std::vector<unsigned int> ssrcs; | 443 std::vector<unsigned int> ssrcs; |
| 365 uint32_t recv_bandwidth = 0; | 444 uint32_t recv_bandwidth = 0; |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 421 } | 500 } |
| 422 } | 501 } |
| 423 { | 502 { |
| 424 ReadLockScoped write_lock(*receive_crit_); | 503 ReadLockScoped write_lock(*receive_crit_); |
| 425 for (auto& kv : video_receive_ssrcs_) { | 504 for (auto& kv : video_receive_ssrcs_) { |
| 426 kv.second->SignalNetworkState(state); | 505 kv.second->SignalNetworkState(state); |
| 427 } | 506 } |
| 428 } | 507 } |
| 429 } | 508 } |
| 430 | 509 |
| 510 void Call::AddAudioReceiveStreamSync(AudioReceiveStream* stream, | |
| 511 const std::string& sync_group, | |
| 512 int channel_id) { | |
| 513 if (!config_.voice_engine || sync_group.empty()) | |
| 514 return; | |
| 515 rtc::CritScope lock(&sync_group_crit_); | |
| 516 audio_sync_groups_[stream] = sync_group; | |
| 517 SyncGroup* group = FindSyncGroup(sync_group); | |
| 518 group->AddAudioReceiveStream(stream, channel_id); | |
| 519 } | |
| 520 | |
| 521 void Call::RemoveAudioReceiveStreamSync(AudioReceiveStream* stream) { | |
| 522 if (!config_.voice_engine) | |
| 523 return; | |
| 524 rtc::CritScope lock(&sync_group_crit_); | |
| 525 SyncGroup* group = FindSyncGroup(audio_sync_groups_[stream]); | |
| 526 group->RemoveAudioReceiveStream(stream); | |
| 527 } | |
| 528 | |
| 529 void Call::AddVideoReceiveStreamSync(VideoReceiveStream* stream, | |
| 530 const std::string& sync_group) { | |
| 531 if (!config_.voice_engine || sync_group.empty()) | |
| 532 return; | |
| 533 rtc::CritScope lock(&sync_group_crit_); | |
| 534 video_sync_groups_[stream] = sync_group; | |
| 535 SyncGroup* group = FindSyncGroup(sync_group); | |
| 536 group->AddVideoReceiveStream(stream); | |
| 537 } | |
| 538 | |
| 539 void Call::RemoveVideoReceiveStreamSync(VideoReceiveStream* stream) { | |
| 540 if (!config_.voice_engine) | |
| 541 return; | |
| 542 rtc::CritScope lock(&sync_group_crit_); | |
| 543 SyncGroup* group = FindSyncGroup(video_sync_groups_[stream]); | |
| 544 group->RemoveVideoReceiveStream(stream); | |
| 545 } | |
| 546 | |
| 547 SyncGroup* Call::FindSyncGroup(const std::string& sync_group) { | |
| 548 DCHECK(!sync_group.empty()); | |
| 549 | |
| 550 if (sync_groups_.find(sync_group) == sync_groups_.end()) | |
| 551 sync_groups_[sync_group] = new SyncGroup(config_.voice_engine); | |
| 552 | |
| 553 SyncGroup* group = sync_groups_[sync_group]; | |
| 554 return group; | |
| 555 } | |
| 556 | |
| 431 PacketReceiver::DeliveryStatus Call::DeliverRtcp(MediaType media_type, | 557 PacketReceiver::DeliveryStatus Call::DeliverRtcp(MediaType media_type, |
| 432 const uint8_t* packet, | 558 const uint8_t* packet, |
| 433 size_t length) { | 559 size_t length) { |
| 434 // TODO(pbos): Figure out what channel needs it actually. | 560 // TODO(pbos): Figure out what channel needs it actually. |
| 435 // Do NOT broadcast! Also make sure it's a valid packet. | 561 // Do NOT broadcast! Also make sure it's a valid packet. |
| 436 // Return DELIVERY_UNKNOWN_SSRC if it can be determined that | 562 // Return DELIVERY_UNKNOWN_SSRC if it can be determined that |
| 437 // there's no receiver of the packet. | 563 // there's no receiver of the packet. |
| 438 bool rtcp_delivered = false; | 564 bool rtcp_delivered = false; |
| 439 if (media_type == MediaType::ANY || media_type == MediaType::VIDEO) { | 565 if (media_type == MediaType::ANY || media_type == MediaType::VIDEO) { |
| 440 ReadLockScoped read_lock(*receive_crit_); | 566 ReadLockScoped read_lock(*receive_crit_); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 484 const uint8_t* packet, | 610 const uint8_t* packet, |
| 485 size_t length) { | 611 size_t length) { |
| 486 if (RtpHeaderParser::IsRtcp(packet, length)) | 612 if (RtpHeaderParser::IsRtcp(packet, length)) |
| 487 return DeliverRtcp(media_type, packet, length); | 613 return DeliverRtcp(media_type, packet, length); |
| 488 | 614 |
| 489 return DeliverRtp(media_type, packet, length); | 615 return DeliverRtp(media_type, packet, length); |
| 490 } | 616 } |
| 491 | 617 |
| 492 } // namespace internal | 618 } // namespace internal |
| 493 } // namespace webrtc | 619 } // namespace webrtc |
| OLD | NEW |