Chromium Code Reviews| Index: webrtc/video/call.cc |
| diff --git a/webrtc/video/call.cc b/webrtc/video/call.cc |
| index cde41bc77a69d589c2cdb18620fbb981371ef9db..7cd354c2ad9fc1cbfc7bdce64599af7694eb0ae8 100644 |
| --- a/webrtc/video/call.cc |
| +++ b/webrtc/video/call.cc |
| @@ -109,6 +109,9 @@ class Call : public webrtc::Call, public PacketReceiver { |
| void SetBitrateControllerConfig( |
| const webrtc::Call::Config::BitrateConfig& bitrate_config); |
| + void ConfigureSync(const std::string& sync_group) |
| + EXCLUSIVE_LOCKS_REQUIRED(receive_crit_); |
| + |
| const int num_cpu_cores_; |
| const rtc::scoped_ptr<ProcessThread> module_process_thread_; |
| const rtc::scoped_ptr<ChannelGroup> channel_group_; |
| @@ -130,6 +133,8 @@ class Call : public webrtc::Call, public PacketReceiver { |
| GUARDED_BY(receive_crit_); |
| std::set<VideoReceiveStream*> video_receive_streams_ |
| GUARDED_BY(receive_crit_); |
| + std::map<std::string, AudioReceiveStream*> sync_stream_mapping_ |
| + GUARDED_BY(receive_crit_); |
| rtc::scoped_ptr<RWLockWrapper> send_crit_; |
| std::map<uint32_t, VideoSendStream*> video_send_ssrcs_ GUARDED_BY(send_crit_); |
| @@ -219,6 +224,7 @@ webrtc::AudioReceiveStream* Call::CreateAudioReceiveStream( |
| DCHECK(audio_receive_ssrcs_.find(config.rtp.remote_ssrc) == |
| audio_receive_ssrcs_.end()); |
| audio_receive_ssrcs_[config.rtp.remote_ssrc] = receive_stream; |
| + ConfigureSync(config.sync_group); |
| } |
| return receive_stream; |
| } |
| @@ -234,6 +240,13 @@ void Call::DestroyAudioReceiveStream( |
| size_t num_deleted = audio_receive_ssrcs_.erase( |
| audio_receive_stream->config().rtp.remote_ssrc); |
| DCHECK(num_deleted == 1); |
| + const std::string& sync_group = audio_receive_stream->config().sync_group; |
| + const auto it = sync_stream_mapping_.find(sync_group); |
| + if (it != sync_stream_mapping_.end() && |
| + it->second == audio_receive_stream) { |
| + sync_stream_mapping_.erase(it); |
| + ConfigureSync(sync_group); |
| + } |
| } |
| delete audio_receive_stream; |
| } |
| @@ -324,8 +337,11 @@ webrtc::VideoReceiveStream* Call::CreateVideoReceiveStream( |
| video_receive_ssrcs_[it->second.ssrc] = receive_stream; |
| video_receive_streams_.insert(receive_stream); |
| + ConfigureSync(config.sync_group); |
| + |
| if (!network_enabled_) |
| receive_stream->SignalNetworkState(kNetworkDown); |
| + |
| return receive_stream; |
| } |
| @@ -333,7 +349,6 @@ void Call::DestroyVideoReceiveStream( |
| webrtc::VideoReceiveStream* receive_stream) { |
| TRACE_EVENT0("webrtc", "Call::DestroyVideoReceiveStream"); |
| DCHECK(receive_stream != nullptr); |
| - |
| VideoReceiveStream* receive_stream_impl = nullptr; |
| { |
| WriteLockScoped write_lock(*receive_crit_); |
| @@ -428,6 +443,34 @@ void Call::SignalNetworkState(NetworkState state) { |
| } |
| } |
| +void Call::ConfigureSync(const std::string& sync_group) { |
| + // Set sync only if there was no previous one. |
| + if (config_.voice_engine == nullptr || sync_group.empty()) |
| + return; |
| + |
| + AudioReceiveStream* sync_audio_stream = nullptr; |
| + // Find existing audio stream. |
| + const auto it = sync_stream_mapping_.find(sync_group); |
| + if (it != sync_stream_mapping_.end()) |
| + sync_audio_stream = it->second; |
| + // No configured audio stream, see if we can find one. |
| + if (sync_audio_stream == nullptr) { |
|
the sun
2015/06/15 10:28:50
else {
pbos-webrtc
2015/06/15 12:05:33
Done.
|
| + for (const auto& kv : audio_receive_ssrcs_) { |
| + if (kv.second->config().sync_group == sync_group) { |
| + sync_audio_stream = kv.second; |
| + break; |
| + } |
| + } |
| + } |
| + if (sync_audio_stream != nullptr) |
|
the sun
2015/06/15 10:28:50
if (sync_audio_stream)
pbos-webrtc
2015/06/15 12:05:33
Done.
|
| + sync_stream_mapping_[sync_group] = sync_audio_stream; |
| + for (VideoReceiveStream* video_stream : video_receive_streams_) { |
| + video_stream->SetSyncChannel( |
| + config_.voice_engine, |
| + sync_audio_stream ? sync_audio_stream->config().voe_channel_id : -1); |
| + } |
| +} |
| + |
| PacketReceiver::DeliveryStatus Call::DeliverRtcp(MediaType media_type, |
| const uint8_t* packet, |
| size_t length) { |