OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2016 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_VIDEO_SEND_DELAY_STATS_H_ | 11 #ifndef WEBRTC_VIDEO_SEND_DELAY_STATS_H_ |
12 #define WEBRTC_VIDEO_SEND_DELAY_STATS_H_ | 12 #define WEBRTC_VIDEO_SEND_DELAY_STATS_H_ |
13 | 13 |
14 #include <map> | 14 #include <map> |
15 #include <memory> | 15 #include <memory> |
16 #include <set> | 16 #include <set> |
17 | 17 |
18 #include "webrtc/base/criticalsection.h" | 18 #include "webrtc/base/criticalsection.h" |
19 #include "webrtc/base/thread_annotations.h" | 19 #include "webrtc/base/thread_annotations.h" |
20 #include "webrtc/common_types.h" | 20 #include "webrtc/common_types.h" |
21 #include "webrtc/modules/include/module_common_types.h" | 21 #include "webrtc/modules/include/module_common_types.h" |
22 #include "webrtc/system_wrappers/include/clock.h" | 22 #include "webrtc/system_wrappers/include/clock.h" |
| 23 #include "webrtc/video/stats_counter.h" |
23 #include "webrtc/video_send_stream.h" | 24 #include "webrtc/video_send_stream.h" |
24 | 25 |
25 namespace webrtc { | 26 namespace webrtc { |
26 | 27 |
27 class SendDelayStats : public SendPacketObserver { | 28 class SendDelayStats : public SendPacketObserver { |
28 public: | 29 public: |
29 explicit SendDelayStats(Clock* clock); | 30 explicit SendDelayStats(Clock* clock); |
30 virtual ~SendDelayStats(); | 31 virtual ~SendDelayStats(); |
31 | 32 |
32 // Adds the configured ssrcs for the rtp streams. | 33 // Adds the configured ssrcs for the rtp streams. |
(...skipping 21 matching lines...) Expand all Loading... |
54 Packet(uint32_t ssrc, int64_t capture_time_ms, int64_t send_time_ms) | 55 Packet(uint32_t ssrc, int64_t capture_time_ms, int64_t send_time_ms) |
55 : ssrc(ssrc), | 56 : ssrc(ssrc), |
56 capture_time_ms(capture_time_ms), | 57 capture_time_ms(capture_time_ms), |
57 send_time_ms(send_time_ms) {} | 58 send_time_ms(send_time_ms) {} |
58 uint32_t ssrc; | 59 uint32_t ssrc; |
59 int64_t capture_time_ms; | 60 int64_t capture_time_ms; |
60 int64_t send_time_ms; | 61 int64_t send_time_ms; |
61 }; | 62 }; |
62 typedef std::map<uint16_t, Packet, SequenceNumberOlderThan> PacketMap; | 63 typedef std::map<uint16_t, Packet, SequenceNumberOlderThan> PacketMap; |
63 | 64 |
64 class SampleCounter { | |
65 public: | |
66 SampleCounter() : sum(0), num_samples(0) {} | |
67 ~SampleCounter() {} | |
68 void Add(int sample); | |
69 int Avg(int min_required_samples) const; | |
70 | |
71 private: | |
72 int sum; | |
73 int num_samples; | |
74 }; | |
75 | |
76 void UpdateHistograms(); | 65 void UpdateHistograms(); |
77 void RemoveOld(int64_t now, PacketMap* packets) | 66 void RemoveOld(int64_t now, PacketMap* packets) |
78 EXCLUSIVE_LOCKS_REQUIRED(crit_); | 67 EXCLUSIVE_LOCKS_REQUIRED(crit_); |
| 68 AvgCounter* GetSendDelayCounter(uint32_t ssrc) |
| 69 EXCLUSIVE_LOCKS_REQUIRED(crit_); |
79 | 70 |
80 Clock* const clock_; | 71 Clock* const clock_; |
81 rtc::CriticalSection crit_; | 72 rtc::CriticalSection crit_; |
82 | 73 |
83 PacketMap packets_ GUARDED_BY(crit_); | 74 PacketMap packets_ GUARDED_BY(crit_); |
84 size_t num_old_packets_ GUARDED_BY(crit_); | 75 size_t num_old_packets_ GUARDED_BY(crit_); |
85 size_t num_skipped_packets_ GUARDED_BY(crit_); | 76 size_t num_skipped_packets_ GUARDED_BY(crit_); |
86 | 77 |
87 std::set<uint32_t> ssrcs_ GUARDED_BY(crit_); | 78 std::set<uint32_t> ssrcs_ GUARDED_BY(crit_); |
88 std::map<uint32_t, SampleCounter> send_delay_counters_ | 79 |
89 GUARDED_BY(crit_); // Mapped by SSRC. | 80 // Mapped by SSRC. |
| 81 std::map<uint32_t, std::unique_ptr<AvgCounter>> send_delay_counters_ |
| 82 GUARDED_BY(crit_); |
90 }; | 83 }; |
91 | 84 |
92 } // namespace webrtc | 85 } // namespace webrtc |
93 #endif // WEBRTC_VIDEO_SEND_DELAY_STATS_H_ | 86 #endif // WEBRTC_VIDEO_SEND_DELAY_STATS_H_ |
OLD | NEW |