| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2011 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2011 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 audio_source_context_->SignalMediaStreamsUpdate.disconnect(this); | 56 audio_source_context_->SignalMediaStreamsUpdate.disconnect(this); |
| 57 | 57 |
| 58 started_ = false; | 58 started_ = false; |
| 59 ssrc_to_speaking_state_map_.clear(); | 59 ssrc_to_speaking_state_map_.clear(); |
| 60 current_speaker_ssrc_ = 0; | 60 current_speaker_ssrc_ = 0; |
| 61 earliest_permitted_switch_time_ = 0; | 61 earliest_permitted_switch_time_ = 0; |
| 62 } | 62 } |
| 63 } | 63 } |
| 64 | 64 |
| 65 void CurrentSpeakerMonitor::set_min_time_between_switches( | 65 void CurrentSpeakerMonitor::set_min_time_between_switches( |
| 66 uint32_t min_time_between_switches) { | 66 int min_time_between_switches) { |
| 67 min_time_between_switches_ = min_time_between_switches; | 67 min_time_between_switches_ = min_time_between_switches; |
| 68 } | 68 } |
| 69 | 69 |
| 70 void CurrentSpeakerMonitor::OnAudioMonitor( | 70 void CurrentSpeakerMonitor::OnAudioMonitor( |
| 71 AudioSourceContext* audio_source_context, const AudioInfo& info) { | 71 AudioSourceContext* audio_source_context, const AudioInfo& info) { |
| 72 std::map<uint32_t, int> active_ssrc_to_level_map; | 72 std::map<uint32_t, int> active_ssrc_to_level_map; |
| 73 cricket::AudioInfo::StreamList::const_iterator stream_list_it; | 73 cricket::AudioInfo::StreamList::const_iterator stream_list_it; |
| 74 for (stream_list_it = info.active_streams.begin(); | 74 for (stream_list_it = info.active_streams.begin(); |
| 75 stream_list_it != info.active_streams.end(); ++stream_list_it) { | 75 stream_list_it != info.active_streams.end(); ++stream_list_it) { |
| 76 uint32_t ssrc = stream_list_it->first; | 76 uint32_t ssrc = stream_list_it->first; |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 loudest_speaker_ssrc = state_it->first; | 158 loudest_speaker_ssrc = state_it->first; |
| 159 max_level = level; | 159 max_level = level; |
| 160 } else if (level > 0 && level == max_level && is_previous_speaker) { | 160 } else if (level > 0 && level == max_level && is_previous_speaker) { |
| 161 // Favor continuity of loudest speakers if audio levels are equal. | 161 // Favor continuity of loudest speakers if audio levels are equal. |
| 162 loudest_speaker_ssrc = state_it->first; | 162 loudest_speaker_ssrc = state_it->first; |
| 163 } | 163 } |
| 164 } | 164 } |
| 165 | 165 |
| 166 // We avoid over-switching by disabling switching for a period of time after | 166 // We avoid over-switching by disabling switching for a period of time after |
| 167 // a switch is done. | 167 // a switch is done. |
| 168 uint32_t now = rtc::Time(); | 168 int64_t now = rtc::TimeMillis(); |
| 169 if (earliest_permitted_switch_time_ <= now && | 169 if (earliest_permitted_switch_time_ <= now && |
| 170 current_speaker_ssrc_ != loudest_speaker_ssrc) { | 170 current_speaker_ssrc_ != loudest_speaker_ssrc) { |
| 171 current_speaker_ssrc_ = loudest_speaker_ssrc; | 171 current_speaker_ssrc_ = loudest_speaker_ssrc; |
| 172 LOG(LS_INFO) << "Current speaker changed to " << current_speaker_ssrc_; | 172 LOG(LS_INFO) << "Current speaker changed to " << current_speaker_ssrc_; |
| 173 earliest_permitted_switch_time_ = now + min_time_between_switches_; | 173 earliest_permitted_switch_time_ = now + min_time_between_switches_; |
| 174 SignalUpdate(this, current_speaker_ssrc_); | 174 SignalUpdate(this, current_speaker_ssrc_); |
| 175 } | 175 } |
| 176 } | 176 } |
| 177 | 177 |
| 178 void CurrentSpeakerMonitor::OnMediaStreamsUpdate( | 178 void CurrentSpeakerMonitor::OnMediaStreamsUpdate( |
| (...skipping 15 matching lines...) Expand all Loading... |
| 194 } | 194 } |
| 195 | 195 |
| 196 void CurrentSpeakerMonitor::OnMediaStreamsReset( | 196 void CurrentSpeakerMonitor::OnMediaStreamsReset( |
| 197 AudioSourceContext* audio_source_context) { | 197 AudioSourceContext* audio_source_context) { |
| 198 if (audio_source_context == audio_source_context_) { | 198 if (audio_source_context == audio_source_context_) { |
| 199 ssrc_to_speaking_state_map_.clear(); | 199 ssrc_to_speaking_state_map_.clear(); |
| 200 } | 200 } |
| 201 } | 201 } |
| 202 | 202 |
| 203 } // namespace cricket | 203 } // namespace cricket |
| OLD | NEW |