• 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 <map>
9 #include <set>
10 
11 #include "media/cast/cast_config.h"
12 #include "media/cast/cast_defines.h"
13 #include "media/cast/logging/logging_defines.h"
14 #include "media/cast/transport/cast_transport_defines.h"
15 
16 namespace media {
17 namespace cast {
18 
19 static const size_t kRtcpCastLogHeaderSize = 12;
20 static const size_t kRtcpReceiverFrameLogSize = 8;
21 static const size_t kRtcpReceiverEventLogSize = 4;
22 
23 // Handle the per frame ACK and NACK messages.
24 class RtcpCastMessage {
25  public:
26   explicit RtcpCastMessage(uint32 media_ssrc);
27   ~RtcpCastMessage();
28 
29   void Copy(const RtcpCastMessage& cast_message);
30 
31   uint32 media_ssrc_;
32   uint32 ack_frame_id_;
33   uint16 target_delay_ms_;
34   MissingFramesAndPacketsMap missing_frames_and_packets_;
35 
36   DISALLOW_COPY_AND_ASSIGN(RtcpCastMessage);
37 };
38 
39 // Log messages from receiver to sender.
40 struct RtcpReceiverEventLogMessage {
41   RtcpReceiverEventLogMessage();
42   ~RtcpReceiverEventLogMessage();
43 
44   CastLoggingEvent type;
45   base::TimeTicks event_timestamp;
46   base::TimeDelta delay_delta;
47   uint16 packet_id;
48 };
49 
50 typedef std::list<RtcpReceiverEventLogMessage> RtcpReceiverEventLogMessages;
51 
52 struct RtcpReceiverFrameLogMessage {
53   explicit RtcpReceiverFrameLogMessage(uint32 rtp_timestamp);
54   ~RtcpReceiverFrameLogMessage();
55 
56   uint32 rtp_timestamp_;
57   RtcpReceiverEventLogMessages event_log_messages_;
58 
59   // TODO(mikhal): Investigate what's the best way to allow adding
60   // DISALLOW_COPY_AND_ASSIGN, as currently it contradicts the implementation
61   // and possible changes have a big impact on design.
62 };
63 
64 typedef std::list<RtcpReceiverFrameLogMessage> RtcpReceiverLogMessage;
65 
66 struct RtcpRpsiMessage {
67   RtcpRpsiMessage();
68   ~RtcpRpsiMessage();
69 
70   uint32 remote_ssrc;
71   uint8 payload_type;
72   uint64 picture_id;
73 };
74 
75 struct RtcpNackMessage {
76   RtcpNackMessage();
77   ~RtcpNackMessage();
78 
79   uint32 remote_ssrc;
80   std::list<uint16> nack_list;
81 
82   DISALLOW_COPY_AND_ASSIGN(RtcpNackMessage);
83 };
84 
85 struct RtcpRembMessage {
86   RtcpRembMessage();
87   ~RtcpRembMessage();
88 
89   uint32 remb_bitrate;
90   std::list<uint32> remb_ssrcs;
91 
92   DISALLOW_COPY_AND_ASSIGN(RtcpRembMessage);
93 };
94 
95 struct RtcpReceiverReferenceTimeReport {
96   RtcpReceiverReferenceTimeReport();
97   ~RtcpReceiverReferenceTimeReport();
98 
99   uint32 remote_ssrc;
100   uint32 ntp_seconds;
101   uint32 ntp_fraction;
102 };
103 
104 inline bool operator==(RtcpReceiverReferenceTimeReport lhs,
105                        RtcpReceiverReferenceTimeReport rhs) {
106   return lhs.remote_ssrc == rhs.remote_ssrc &&
107          lhs.ntp_seconds == rhs.ntp_seconds &&
108          lhs.ntp_fraction == rhs.ntp_fraction;
109 }
110 
111 // Struct used by raw event subscribers as an intermediate format before
112 // sending off to the other side via RTCP.
113 // (i.e., {Sender,Receiver}RtcpEventSubscriber)
114 struct RtcpEvent {
115   RtcpEvent();
116   ~RtcpEvent();
117 
118   CastLoggingEvent type;
119 
120   // Time of event logged.
121   base::TimeTicks timestamp;
122 
123   // Render/playout delay. Only set for FRAME_PLAYOUT events.
124   base::TimeDelta delay_delta;
125 
126   // Only set for packet events.
127   uint16 packet_id;
128 };
129 
130 }  // namespace cast
131 }  // namespace media
132 
133 #endif  // MEDIA_CAST_RTCP_RTCP_DEFINES_H_
134