• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2014 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/net/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 struct RtcpCastMessage {
25   explicit RtcpCastMessage(uint32 ssrc);
26   RtcpCastMessage();
27   ~RtcpCastMessage();
28 
29   uint32 media_ssrc;
30   uint32 ack_frame_id;
31   uint16 target_delay_ms;
32   MissingFramesAndPacketsMap missing_frames_and_packets;
33 };
34 
35 // Log messages from receiver to sender.
36 struct RtcpReceiverEventLogMessage {
37   RtcpReceiverEventLogMessage();
38   ~RtcpReceiverEventLogMessage();
39 
40   CastLoggingEvent type;
41   base::TimeTicks event_timestamp;
42   base::TimeDelta delay_delta;
43   uint16 packet_id;
44 };
45 
46 typedef std::list<RtcpReceiverEventLogMessage> RtcpReceiverEventLogMessages;
47 
48 struct RtcpReceiverFrameLogMessage {
49   explicit RtcpReceiverFrameLogMessage(uint32 rtp_timestamp);
50   ~RtcpReceiverFrameLogMessage();
51 
52   uint32 rtp_timestamp_;
53   RtcpReceiverEventLogMessages event_log_messages_;
54 
55   // TODO(mikhal): Investigate what's the best way to allow adding
56   // DISALLOW_COPY_AND_ASSIGN, as currently it contradicts the implementation
57   // and possible changes have a big impact on design.
58 };
59 
60 typedef std::list<RtcpReceiverFrameLogMessage> RtcpReceiverLogMessage;
61 
62 struct RtcpNackMessage {
63   RtcpNackMessage();
64   ~RtcpNackMessage();
65 
66   uint32 remote_ssrc;
67   std::list<uint16> nack_list;
68 
69   DISALLOW_COPY_AND_ASSIGN(RtcpNackMessage);
70 };
71 
72 struct RtcpReceiverReferenceTimeReport {
73   RtcpReceiverReferenceTimeReport();
74   ~RtcpReceiverReferenceTimeReport();
75 
76   uint32 remote_ssrc;
77   uint32 ntp_seconds;
78   uint32 ntp_fraction;
79 };
80 
81 inline bool operator==(RtcpReceiverReferenceTimeReport lhs,
82                        RtcpReceiverReferenceTimeReport rhs) {
83   return lhs.remote_ssrc == rhs.remote_ssrc &&
84          lhs.ntp_seconds == rhs.ntp_seconds &&
85          lhs.ntp_fraction == rhs.ntp_fraction;
86 }
87 
88 // Struct used by raw event subscribers as an intermediate format before
89 // sending off to the other side via RTCP.
90 // (i.e., {Sender,Receiver}RtcpEventSubscriber)
91 struct RtcpEvent {
92   RtcpEvent();
93   ~RtcpEvent();
94 
95   CastLoggingEvent type;
96 
97   // Time of event logged.
98   base::TimeTicks timestamp;
99 
100   // Render/playout delay. Only set for FRAME_PLAYOUT events.
101   base::TimeDelta delay_delta;
102 
103   // Only set for packet events.
104   uint16 packet_id;
105 };
106 
107 typedef base::Callback<void(const RtcpCastMessage&)> RtcpCastMessageCallback;
108 typedef base::Callback<void(base::TimeDelta)> RtcpRttCallback;
109 typedef
110 base::Callback<void(const RtcpReceiverLogMessage&)> RtcpLogMessageCallback;
111 
112 }  // namespace cast
113 }  // namespace media
114 
115 #endif  // MEDIA_CAST_RTCP_RTCP_DEFINES_H_
116