Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / media / cast / net / rtcp / rtcp_defines.h
blobb35e14bfe6352a1480f3b426d827d2ec366de83a
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.
5 #ifndef MEDIA_CAST_RTCP_RTCP_DEFINES_H_
6 #define MEDIA_CAST_RTCP_RTCP_DEFINES_H_
8 #include <map>
9 #include <set>
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"
16 namespace media {
17 namespace cast {
19 static const size_t kRtcpCastLogHeaderSize = 12;
20 static const size_t kRtcpReceiverFrameLogSize = 8;
21 static const size_t kRtcpReceiverEventLogSize = 4;
23 // Handle the per frame ACK and NACK messages.
24 struct RtcpCastMessage {
25 explicit RtcpCastMessage(uint32 ssrc);
26 RtcpCastMessage();
27 ~RtcpCastMessage();
29 uint32 media_ssrc;
30 uint32 ack_frame_id;
31 uint16 target_delay_ms;
32 MissingFramesAndPacketsMap missing_frames_and_packets;
35 // Log messages from receiver to sender.
36 struct RtcpReceiverEventLogMessage {
37 RtcpReceiverEventLogMessage();
38 ~RtcpReceiverEventLogMessage();
40 CastLoggingEvent type;
41 base::TimeTicks event_timestamp;
42 base::TimeDelta delay_delta;
43 uint16 packet_id;
46 typedef std::list<RtcpReceiverEventLogMessage> RtcpReceiverEventLogMessages;
48 struct RtcpReceiverFrameLogMessage {
49 explicit RtcpReceiverFrameLogMessage(uint32 rtp_timestamp);
50 ~RtcpReceiverFrameLogMessage();
52 uint32 rtp_timestamp_;
53 RtcpReceiverEventLogMessages event_log_messages_;
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.
60 typedef std::list<RtcpReceiverFrameLogMessage> RtcpReceiverLogMessage;
62 struct RtcpNackMessage {
63 RtcpNackMessage();
64 ~RtcpNackMessage();
66 uint32 remote_ssrc;
67 std::list<uint16> nack_list;
69 DISALLOW_COPY_AND_ASSIGN(RtcpNackMessage);
72 struct RtcpReceiverReferenceTimeReport {
73 RtcpReceiverReferenceTimeReport();
74 ~RtcpReceiverReferenceTimeReport();
76 uint32 remote_ssrc;
77 uint32 ntp_seconds;
78 uint32 ntp_fraction;
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;
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();
95 CastLoggingEvent type;
97 // Time of event logged.
98 base::TimeTicks timestamp;
100 // Render/playout delay. Only set for FRAME_PLAYOUT events.
101 base::TimeDelta delay_delta;
103 // Only set for packet events.
104 uint16 packet_id;
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;
112 // TODO(hubbe): Document members of this struct.
113 struct RtpReceiverStatistics {
114 RtpReceiverStatistics();
115 uint8 fraction_lost;
116 uint32 cumulative_lost; // 24 bits valid.
117 uint32 extended_high_sequence_number;
118 uint32 jitter;
121 // These are intended to only be created using Rtcp::ConvertToNTPAndSave.
122 struct RtcpTimeData {
123 uint32 ntp_seconds;
124 uint32 ntp_fraction;
125 base::TimeTicks timestamp;
128 // This struct is used to encapsulate all the parameters of the
129 // SendRtcpFromRtpReceiver for IPC transportation.
130 struct SendRtcpFromRtpReceiver_Params {
131 SendRtcpFromRtpReceiver_Params();
132 ~SendRtcpFromRtpReceiver_Params();
133 uint32 ssrc;
134 uint32 sender_ssrc;
135 RtcpTimeData time_data;
136 scoped_ptr<RtcpCastMessage> cast_message;
137 base::TimeDelta target_delay;
138 scoped_ptr<std::vector<std::pair<RtpTimestamp, RtcpEvent> > > rtcp_events;
139 scoped_ptr<RtpReceiverStatistics> rtp_receiver_statistics;
143 } // namespace cast
144 } // namespace media
146 #endif // MEDIA_CAST_RTCP_RTCP_DEFINES_H_