| OLD | NEW |
| (Empty) |
| 1 /* | |
| 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | |
| 3 * | |
| 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 | |
| 6 * tree. An additional intellectual property rights grant can be found | |
| 7 * in the file PATENTS. All contributing project authors may | |
| 8 * be found in the AUTHORS file in the root of the source tree. | |
| 9 */ | |
| 10 | |
| 11 #ifndef WEBRTC_VIDEO_ENGINE_CALL_STATS_H_ | |
| 12 #define WEBRTC_VIDEO_ENGINE_CALL_STATS_H_ | |
| 13 | |
| 14 #include <list> | |
| 15 | |
| 16 #include "webrtc/base/constructormagic.h" | |
| 17 #include "webrtc/base/scoped_ptr.h" | |
| 18 #include "webrtc/modules/include/module.h" | |
| 19 #include "webrtc/system_wrappers/include/clock.h" | |
| 20 | |
| 21 namespace webrtc { | |
| 22 | |
| 23 class CallStatsObserver; | |
| 24 class CriticalSectionWrapper; | |
| 25 class RtcpRttStats; | |
| 26 | |
| 27 // CallStats keeps track of statistics for a call. | |
| 28 class CallStats : public Module { | |
| 29 public: | |
| 30 friend class RtcpObserver; | |
| 31 | |
| 32 explicit CallStats(Clock* clock); | |
| 33 ~CallStats(); | |
| 34 | |
| 35 // Implements Module, to use the process thread. | |
| 36 int64_t TimeUntilNextProcess() override; | |
| 37 int32_t Process() override; | |
| 38 | |
| 39 // Returns a RtcpRttStats to register at a statistics provider. The object | |
| 40 // has the same lifetime as the CallStats instance. | |
| 41 RtcpRttStats* rtcp_rtt_stats() const; | |
| 42 | |
| 43 // Registers/deregisters a new observer to receive statistics updates. | |
| 44 void RegisterStatsObserver(CallStatsObserver* observer); | |
| 45 void DeregisterStatsObserver(CallStatsObserver* observer); | |
| 46 | |
| 47 // Helper struct keeping track of the time a rtt value is reported. | |
| 48 struct RttTime { | |
| 49 RttTime(int64_t new_rtt, int64_t rtt_time) | |
| 50 : rtt(new_rtt), time(rtt_time) {} | |
| 51 const int64_t rtt; | |
| 52 const int64_t time; | |
| 53 }; | |
| 54 | |
| 55 protected: | |
| 56 void OnRttUpdate(int64_t rtt); | |
| 57 | |
| 58 int64_t avg_rtt_ms() const; | |
| 59 | |
| 60 private: | |
| 61 Clock* const clock_; | |
| 62 // Protecting all members. | |
| 63 rtc::scoped_ptr<CriticalSectionWrapper> crit_; | |
| 64 // Observer receiving statistics updates. | |
| 65 rtc::scoped_ptr<RtcpRttStats> rtcp_rtt_stats_; | |
| 66 // The last time 'Process' resulted in statistic update. | |
| 67 int64_t last_process_time_; | |
| 68 // The last RTT in the statistics update (zero if there is no valid estimate). | |
| 69 int64_t max_rtt_ms_; | |
| 70 int64_t avg_rtt_ms_; | |
| 71 | |
| 72 // All Rtt reports within valid time interval, oldest first. | |
| 73 std::list<RttTime> reports_; | |
| 74 | |
| 75 // Observers getting stats reports. | |
| 76 std::list<CallStatsObserver*> observers_; | |
| 77 | |
| 78 RTC_DISALLOW_COPY_AND_ASSIGN(CallStats); | |
| 79 }; | |
| 80 | |
| 81 } // namespace webrtc | |
| 82 | |
| 83 #endif // WEBRTC_VIDEO_ENGINE_CALL_STATS_H_ | |
| OLD | NEW |