123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149 |
- #ifndef VIDEO_CALL_STATS2_H_
- #define VIDEO_CALL_STATS2_H_
- #include <list>
- #include <memory>
- #include "api/units/timestamp.h"
- #include "modules/include/module_common_types.h"
- #include "modules/rtp_rtcp/include/rtp_rtcp_defines.h"
- #include "rtc_base/constructor_magic.h"
- #include "rtc_base/synchronization/sequence_checker.h"
- #include "rtc_base/system/no_unique_address.h"
- #include "rtc_base/task_queue.h"
- #include "rtc_base/task_utils/pending_task_safety_flag.h"
- #include "rtc_base/task_utils/repeating_task.h"
- #include "system_wrappers/include/clock.h"
- namespace webrtc {
- namespace internal {
- class CallStats {
- public:
-
- static constexpr TimeDelta kUpdateInterval = TimeDelta::Millis(1000);
- CallStats(Clock* clock, TaskQueueBase* task_queue);
- ~CallStats();
-
-
-
-
-
- RtcpRttStats* AsRtcpRttStats() { return &rtcp_rtt_stats_impl_; }
-
-
- void RegisterStatsObserver(CallStatsObserver* observer);
- void DeregisterStatsObserver(CallStatsObserver* observer);
-
-
-
-
-
-
-
- int64_t LastProcessedRtt() const;
-
- void UpdateHistogramsForTest() { UpdateHistograms(); }
-
- struct RttTime {
- RttTime(int64_t new_rtt, int64_t rtt_time) : rtt(new_rtt), time(rtt_time) {}
- const int64_t rtt;
- const int64_t time;
- };
- private:
-
- void OnRttUpdate(int64_t rtt);
- void UpdateAndReport();
-
-
- void UpdateHistograms();
- class RtcpRttStatsImpl : public RtcpRttStats {
- public:
- explicit RtcpRttStatsImpl(CallStats* owner) : owner_(owner) {}
- ~RtcpRttStatsImpl() override = default;
- private:
- void OnRttUpdate(int64_t rtt) override {
-
-
-
-
- owner_->OnRttUpdate(rtt);
- }
- int64_t LastProcessedRtt() const override {
-
-
-
-
- RTC_NOTREACHED() << "Legacy call path";
- return 0;
- }
- CallStats* const owner_;
- } rtcp_rtt_stats_impl_{this};
- Clock* const clock_;
-
- RepeatingTaskHandle repeating_task_
- RTC_GUARDED_BY(construction_thread_checker_);
-
- int64_t max_rtt_ms_ RTC_GUARDED_BY(construction_thread_checker_);
-
- int64_t avg_rtt_ms_ RTC_GUARDED_BY(construction_thread_checker_);
-
-
-
-
- int64_t sum_avg_rtt_ms_ RTC_GUARDED_BY(construction_thread_checker_);
- int64_t num_avg_rtt_ RTC_GUARDED_BY(construction_thread_checker_);
- int64_t time_of_first_rtt_ms_ RTC_GUARDED_BY(construction_thread_checker_);
-
- std::list<RttTime> reports_ RTC_GUARDED_BY(construction_thread_checker_);
-
-
-
-
-
- std::list<CallStatsObserver*> observers_;
- RTC_NO_UNIQUE_ADDRESS SequenceChecker construction_thread_checker_;
- RTC_NO_UNIQUE_ADDRESS SequenceChecker process_thread_checker_;
- TaskQueueBase* const task_queue_;
-
- ScopedTaskSafety task_safety_;
- RTC_DISALLOW_COPY_AND_ASSIGN(CallStats);
- };
- }
- }
- #endif
|