| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2005 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2005 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 |
| 11 #include "webrtc/base/checks.h" |
| 11 #include "webrtc/base/common.h" | 12 #include "webrtc/base/common.h" |
| 12 #include "webrtc/pc/channelmanager.h" | 13 #include "webrtc/pc/channelmanager.h" |
| 13 #include "webrtc/pc/mediamonitor.h" | 14 #include "webrtc/pc/mediamonitor.h" |
| 14 | 15 |
| 15 namespace cricket { | 16 namespace cricket { |
| 16 | 17 |
| 17 enum { | 18 enum { |
| 18 MSG_MONITOR_POLL = 1, | 19 MSG_MONITOR_POLL = 1, |
| 19 MSG_MONITOR_START = 2, | 20 MSG_MONITOR_START = 2, |
| 20 MSG_MONITOR_STOP = 3, | 21 MSG_MONITOR_STOP = 3, |
| (...skipping 22 matching lines...) Expand all Loading... |
| 43 void MediaMonitor::Stop() { | 44 void MediaMonitor::Stop() { |
| 44 worker_thread_->Post(RTC_FROM_HERE, this, MSG_MONITOR_STOP); | 45 worker_thread_->Post(RTC_FROM_HERE, this, MSG_MONITOR_STOP); |
| 45 rate_ = 0; | 46 rate_ = 0; |
| 46 } | 47 } |
| 47 | 48 |
| 48 void MediaMonitor::OnMessage(rtc::Message* message) { | 49 void MediaMonitor::OnMessage(rtc::Message* message) { |
| 49 rtc::CritScope cs(&crit_); | 50 rtc::CritScope cs(&crit_); |
| 50 | 51 |
| 51 switch (message->message_id) { | 52 switch (message->message_id) { |
| 52 case MSG_MONITOR_START: | 53 case MSG_MONITOR_START: |
| 53 ASSERT(rtc::Thread::Current() == worker_thread_); | 54 RTC_DCHECK(rtc::Thread::Current() == worker_thread_); |
| 54 if (!monitoring_) { | 55 if (!monitoring_) { |
| 55 monitoring_ = true; | 56 monitoring_ = true; |
| 56 PollMediaChannel(); | 57 PollMediaChannel(); |
| 57 } | 58 } |
| 58 break; | 59 break; |
| 59 | 60 |
| 60 case MSG_MONITOR_STOP: | 61 case MSG_MONITOR_STOP: |
| 61 ASSERT(rtc::Thread::Current() == worker_thread_); | 62 RTC_DCHECK(rtc::Thread::Current() == worker_thread_); |
| 62 if (monitoring_) { | 63 if (monitoring_) { |
| 63 monitoring_ = false; | 64 monitoring_ = false; |
| 64 worker_thread_->Clear(this); | 65 worker_thread_->Clear(this); |
| 65 } | 66 } |
| 66 break; | 67 break; |
| 67 | 68 |
| 68 case MSG_MONITOR_POLL: | 69 case MSG_MONITOR_POLL: |
| 69 ASSERT(rtc::Thread::Current() == worker_thread_); | 70 RTC_DCHECK(rtc::Thread::Current() == worker_thread_); |
| 70 PollMediaChannel(); | 71 PollMediaChannel(); |
| 71 break; | 72 break; |
| 72 | 73 |
| 73 case MSG_MONITOR_SIGNAL: | 74 case MSG_MONITOR_SIGNAL: |
| 74 ASSERT(rtc::Thread::Current() == monitor_thread_); | 75 RTC_DCHECK(rtc::Thread::Current() == monitor_thread_); |
| 75 Update(); | 76 Update(); |
| 76 break; | 77 break; |
| 77 } | 78 } |
| 78 } | 79 } |
| 79 | 80 |
| 80 void MediaMonitor::PollMediaChannel() { | 81 void MediaMonitor::PollMediaChannel() { |
| 81 rtc::CritScope cs(&crit_); | 82 rtc::CritScope cs(&crit_); |
| 82 ASSERT(rtc::Thread::Current() == worker_thread_); | 83 RTC_DCHECK(rtc::Thread::Current() == worker_thread_); |
| 83 | 84 |
| 84 GetStats(); | 85 GetStats(); |
| 85 | 86 |
| 86 // Signal the monitoring thread, start another poll timer | 87 // Signal the monitoring thread, start another poll timer |
| 87 monitor_thread_->Post(RTC_FROM_HERE, this, MSG_MONITOR_SIGNAL); | 88 monitor_thread_->Post(RTC_FROM_HERE, this, MSG_MONITOR_SIGNAL); |
| 88 worker_thread_->PostDelayed(RTC_FROM_HERE, rate_, this, MSG_MONITOR_POLL); | 89 worker_thread_->PostDelayed(RTC_FROM_HERE, rate_, this, MSG_MONITOR_POLL); |
| 89 } | 90 } |
| 90 | 91 |
| 91 } // namespace cricket | 92 } // namespace cricket |
| OLD | NEW |