| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 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 #ifndef WEBRTC_VOICE_ENGINE_MONITOR_MODULE_H | 11 #ifndef WEBRTC_VOICE_ENGINE_MONITOR_MODULE_H |
| 12 #define WEBRTC_VOICE_ENGINE_MONITOR_MODULE_H | 12 #define WEBRTC_VOICE_ENGINE_MONITOR_MODULE_H |
| 13 | 13 |
| 14 #include "webrtc/base/criticalsection.h" | |
| 15 #include "webrtc/base/thread_annotations.h" | |
| 16 #include "webrtc/modules/include/module.h" | 14 #include "webrtc/modules/include/module.h" |
| 17 #include "webrtc/typedefs.h" | |
| 18 #include "webrtc/voice_engine/voice_engine_defines.h" | |
| 19 | |
| 20 class MonitorObserver | |
| 21 { | |
| 22 public: | |
| 23 virtual void OnPeriodicProcess() = 0; | |
| 24 protected: | |
| 25 virtual ~MonitorObserver() {} | |
| 26 }; | |
| 27 | |
| 28 | 15 |
| 29 namespace webrtc { | 16 namespace webrtc { |
| 30 namespace voe { | 17 namespace voe { |
| 31 | 18 |
| 32 class MonitorModule : public Module | 19 // When associated with a ProcessThread, calls a callback method |
| 33 { | 20 // |OnPeriodicProcess()| implemented by the |Observer|. |
| 34 public: | 21 // TODO(tommi): This could be replaced with PostDelayedTask(). |
| 35 int32_t RegisterObserver(MonitorObserver& observer); | 22 // Better yet, delete it and delete code related to |_saturationWarning| |
| 23 // in TransmitMixer (and the OnPeriodicProcess callback). |
| 24 template <typename Observer> |
| 25 class MonitorModule : public Module { |
| 26 public: |
| 27 explicit MonitorModule(Observer* observer) : observer_(observer) {} |
| 28 ~MonitorModule() override {} |
| 36 | 29 |
| 37 int32_t DeRegisterObserver(); | 30 private: |
| 31 int64_t TimeUntilNextProcess() override { return 1000; } |
| 32 void Process() override { observer_->OnPeriodicProcess(); } |
| 38 | 33 |
| 39 MonitorModule(); | 34 Observer* const observer_; |
| 40 | |
| 41 virtual ~MonitorModule(); | |
| 42 public:»// module | |
| 43 int64_t TimeUntilNextProcess() override; | |
| 44 | |
| 45 void Process() override; | |
| 46 | |
| 47 private: | |
| 48 rtc::CriticalSection _callbackCritSect; | |
| 49 MonitorObserver* _observerPtr GUARDED_BY(_callbackCritSect); | |
| 50 int64_t _lastProcessTime; | |
| 51 }; | 35 }; |
| 52 | 36 |
| 53 } // namespace voe | 37 } // namespace voe |
| 54 | |
| 55 } // namespace webrtc | 38 } // namespace webrtc |
| 56 | 39 |
| 57 #endif // VOICE_ENGINE_MONITOR_MODULE | 40 #endif // VOICE_ENGINE_MONITOR_MODULE |
| OLD | NEW |