OLD | NEW |
| (Empty) |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef MEDIA_CAST_NET_CAST_NET_DEFINES_H_ | |
6 #define MEDIA_CAST_NET_CAST_NET_DEFINES_H_ | |
7 | |
8 #include <list> | |
9 #include "base/basictypes.h" | |
10 | |
11 namespace media { | |
12 namespace cast { | |
13 | |
14 // Rtcp defines. | |
15 | |
16 // Log messages form sender to receiver. | |
17 enum RtcpSenderFrameStatus { | |
18 kRtcpSenderFrameStatusUnknown = 0, | |
19 kRtcpSenderFrameStatusDroppedByEncoder = 1, | |
20 kRtcpSenderFrameStatusDroppedByFlowControl = 2, | |
21 kRtcpSenderFrameStatusSentToNetwork = 3, | |
22 }; | |
23 | |
24 struct RtcpSenderFrameLogMessage { | |
25 RtcpSenderFrameStatus frame_status; | |
26 uint32 rtp_timestamp; | |
27 }; | |
28 | |
29 struct RtcpSenderInfo { | |
30 // First three members are used for lipsync. | |
31 // First two members are used for rtt. | |
32 uint32 ntp_seconds; | |
33 uint32 ntp_fraction; | |
34 uint32 rtp_timestamp; | |
35 uint32 send_packet_count; | |
36 size_t send_octet_count; | |
37 }; | |
38 | |
39 struct RtcpReportBlock { | |
40 uint32 remote_ssrc; // SSRC of sender of this report. | |
41 uint32 media_ssrc; // SSRC of the RTP packet sender. | |
42 uint8 fraction_lost; | |
43 uint32 cumulative_lost; // 24 bits valid. | |
44 uint32 extended_high_sequence_number; | |
45 uint32 jitter; | |
46 uint32 last_sr; | |
47 uint32 delay_since_last_sr; | |
48 }; | |
49 | |
50 struct RtcpDlrrReportBlock { | |
51 uint32 last_rr; | |
52 uint32 delay_since_last_rr; | |
53 }; | |
54 | |
55 typedef std::list<RtcpSenderFrameLogMessage> RtcpSenderLogMessage; | |
56 | |
57 class FrameIdWrapHelper { | |
58 public: | |
59 FrameIdWrapHelper() | |
60 : first_(true), | |
61 frame_id_wrap_count_(0), | |
62 range_(kLowRange) {} | |
63 | |
64 uint32 MapTo32bitsFrameId(const uint8 over_the_wire_frame_id) { | |
65 if (first_) { | |
66 first_ = false; | |
67 if (over_the_wire_frame_id == 0xff) { | |
68 // Special case for startup. | |
69 return kStartFrameId; | |
70 } | |
71 } | |
72 | |
73 uint32 wrap_count = frame_id_wrap_count_; | |
74 switch (range_) { | |
75 case kLowRange: | |
76 if (over_the_wire_frame_id > kLowRangeThreshold && | |
77 over_the_wire_frame_id < kHighRangeThreshold) { | |
78 range_ = kMiddleRange; | |
79 } | |
80 if (over_the_wire_frame_id > kHighRangeThreshold) { | |
81 // Wrap count was incremented in High->Low transition, but this frame | |
82 // is 'old', actually from before the wrap count got incremented. | |
83 --wrap_count; | |
84 } | |
85 break; | |
86 case kMiddleRange: | |
87 if (over_the_wire_frame_id > kHighRangeThreshold) { | |
88 range_ = kHighRange; | |
89 } | |
90 break; | |
91 case kHighRange: | |
92 if (over_the_wire_frame_id < kLowRangeThreshold) { | |
93 // Wrap-around detected. | |
94 range_ = kLowRange; | |
95 ++frame_id_wrap_count_; | |
96 // Frame triggering wrap-around so wrap count should be incremented as | |
97 // as well to match |frame_id_wrap_count_|. | |
98 ++wrap_count; | |
99 } | |
100 break; | |
101 } | |
102 return (wrap_count << 8) + over_the_wire_frame_id; | |
103 } | |
104 | |
105 private: | |
106 enum Range { | |
107 kLowRange, | |
108 kMiddleRange, | |
109 kHighRange, | |
110 }; | |
111 | |
112 static const uint8 kLowRangeThreshold = 0x0f; | |
113 static const uint8 kHighRangeThreshold = 0xf0; | |
114 static const uint32 kStartFrameId = GG_UINT32_C(0xffffffff); | |
115 | |
116 bool first_; | |
117 uint32 frame_id_wrap_count_; | |
118 Range range_; | |
119 }; | |
120 | |
121 } // namespace cast | |
122 } // namespace media | |
123 | |
124 #endif // MEDIA_CAST_NET_CAST_NET_DEFINES_H_ | |
OLD | NEW |