• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_RTCP_RTCP_DEFINES_H_
6 #define MEDIA_CAST_RTCP_RTCP_DEFINES_H_
7 
8 #include <list>
9 #include <map>
10 #include <set>
11 
12 #include "media/cast/cast_config.h"
13 #include "media/cast/cast_defines.h"
14 #include "media/cast/logging/logging_defines.h"
15 
16 namespace media {
17 namespace cast {
18 
19 // Handle the per frame ACK and NACK messages.
20 class RtcpCastMessage {
21  public:
22   explicit RtcpCastMessage(uint32 media_ssrc);
23   ~RtcpCastMessage();
24 
25   uint32 media_ssrc_;
26   uint32 ack_frame_id_;
27   MissingFramesAndPacketsMap missing_frames_and_packets_;
28 };
29 
30 // Log messages form sender to receiver.
31 enum RtcpSenderFrameStatus {
32   kRtcpSenderFrameStatusUnknown = 0,
33   kRtcpSenderFrameStatusDroppedByEncoder = 1,
34   kRtcpSenderFrameStatusDroppedByFlowControl = 2,
35   kRtcpSenderFrameStatusSentToNetwork = 3,
36 };
37 
38 struct RtcpSenderFrameLogMessage {
39   RtcpSenderFrameStatus frame_status;
40   uint32 rtp_timestamp;
41 };
42 
43 typedef std::list<RtcpSenderFrameLogMessage> RtcpSenderLogMessage;
44 
45 // Log messages from receiver to sender.
46 struct RtcpReceiverEventLogMessage {
47   CastLoggingEvent type;
48   base::TimeTicks event_timestamp;
49   base::TimeDelta delay_delta;
50   uint16 packet_id;
51 };
52 
53 typedef std::list<RtcpReceiverEventLogMessage> RtcpReceiverEventLogMessages;
54 
55 class RtcpReceiverFrameLogMessage {
56  public:
57   explicit RtcpReceiverFrameLogMessage(uint32 rtp_timestamp);
58   ~RtcpReceiverFrameLogMessage();
59 
60   uint32 rtp_timestamp_;
61   RtcpReceiverEventLogMessages event_log_messages_;
62 };
63 
64 typedef std::list<RtcpReceiverFrameLogMessage> RtcpReceiverLogMessage;
65 
66 struct RtcpSenderInfo {
67   // First three members are used for lipsync.
68   // First two members are used for rtt.
69   uint32 ntp_seconds;
70   uint32 ntp_fraction;
71   uint32 rtp_timestamp;
72   uint32 send_packet_count;
73   size_t send_octet_count;
74 };
75 
76 struct RtcpReportBlock {
77   uint32 remote_ssrc;  // SSRC of sender of this report.
78   uint32 media_ssrc;  // SSRC of the RTP packet sender.
79   uint8 fraction_lost;
80   uint32 cumulative_lost;  // 24 bits valid.
81   uint32 extended_high_sequence_number;
82   uint32 jitter;
83   uint32 last_sr;
84   uint32 delay_since_last_sr;
85 };
86 
87 struct RtcpRpsiMessage {
88   uint32 remote_ssrc;
89   uint8 payload_type;
90   uint64 picture_id;
91 };
92 
93 class RtcpNackMessage {
94  public:
95   RtcpNackMessage();
96   ~RtcpNackMessage();
97 
98   uint32 remote_ssrc;
99   std::list<uint16> nack_list;
100 };
101 
102 class RtcpRembMessage {
103  public:
104   RtcpRembMessage();
105   ~RtcpRembMessage();
106 
107   uint32 remb_bitrate;
108   std::list<uint32> remb_ssrcs;
109 };
110 
111 struct RtcpReceiverReferenceTimeReport {
112   uint32 remote_ssrc;
113   uint32 ntp_seconds;
114   uint32 ntp_fraction;
115 };
116 
117 struct RtcpDlrrReportBlock {
118   uint32 last_rr;
119   uint32 delay_since_last_rr;
120 };
121 
122 inline bool operator==(RtcpReportBlock lhs, RtcpReportBlock rhs) {
123   return lhs.remote_ssrc == rhs.remote_ssrc &&
124       lhs.media_ssrc == rhs.media_ssrc &&
125       lhs.fraction_lost == rhs.fraction_lost &&
126       lhs.cumulative_lost == rhs.cumulative_lost &&
127       lhs.extended_high_sequence_number == rhs.extended_high_sequence_number &&
128       lhs.jitter == rhs.jitter &&
129       lhs.last_sr == rhs.last_sr &&
130       lhs.delay_since_last_sr == rhs.delay_since_last_sr;
131 }
132 
133 inline bool operator==(RtcpSenderInfo lhs, RtcpSenderInfo rhs) {
134   return lhs.ntp_seconds == rhs.ntp_seconds &&
135       lhs.ntp_fraction == rhs.ntp_fraction &&
136       lhs.rtp_timestamp == rhs.rtp_timestamp &&
137       lhs.send_packet_count == rhs.send_packet_count &&
138       lhs.send_octet_count == rhs.send_octet_count;
139 }
140 
141 inline bool operator==(RtcpReceiverReferenceTimeReport lhs,
142                        RtcpReceiverReferenceTimeReport rhs) {
143   return lhs.remote_ssrc == rhs.remote_ssrc &&
144       lhs.ntp_seconds == rhs.ntp_seconds &&
145       lhs.ntp_fraction == rhs.ntp_fraction;
146 }
147 
148 }  // namespace cast
149 }  // namespace media
150 
151 #endif  // MEDIA_CAST_RTCP_RTCP_DEFINES_H_
152