Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(560)

Side by Side Diff: media/cast/net/rtcp/rtcp.h

Issue 1472083005: Remove kint64min. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@kint5
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // This class maintains a bi-directional RTCP connection with a remote 5 // This class maintains a bi-directional RTCP connection with a remote
6 // peer. 6 // peer.
7 7
8 #ifndef MEDIA_CAST_RTCP_RTCP_H_ 8 #ifndef MEDIA_CAST_RTCP_RTCP_H_
9 #define MEDIA_CAST_RTCP_RTCP_H_ 9 #define MEDIA_CAST_RTCP_RTCP_H_
10 10
11 #include <stdint.h>
12
11 #include <map> 13 #include <map>
12 #include <queue> 14 #include <queue>
13 #include <string> 15 #include <string>
14 16
15 #include "base/basictypes.h" 17 #include "base/macros.h"
16 #include "base/memory/scoped_ptr.h" 18 #include "base/memory/scoped_ptr.h"
17 #include "base/memory/weak_ptr.h" 19 #include "base/memory/weak_ptr.h"
18 #include "base/time/tick_clock.h" 20 #include "base/time/tick_clock.h"
19 #include "base/time/time.h" 21 #include "base/time/time.h"
20 #include "media/cast/cast_config.h" 22 #include "media/cast/cast_config.h"
21 #include "media/cast/cast_defines.h" 23 #include "media/cast/cast_defines.h"
22 #include "media/cast/common/clock_drift_smoother.h" 24 #include "media/cast/common/clock_drift_smoother.h"
23 #include "media/cast/net/cast_transport_defines.h" 25 #include "media/cast/net/cast_transport_defines.h"
24 #include "media/cast/net/cast_transport_sender.h" 26 #include "media/cast/net/cast_transport_sender.h"
25 #include "media/cast/net/rtcp/receiver_rtcp_event_subscriber.h" 27 #include "media/cast/net/rtcp/receiver_rtcp_event_subscriber.h"
26 #include "media/cast/net/rtcp/rtcp_builder.h" 28 #include "media/cast/net/rtcp/rtcp_builder.h"
27 #include "media/cast/net/rtcp/rtcp_defines.h" 29 #include "media/cast/net/rtcp/rtcp_defines.h"
28 30
29 namespace media { 31 namespace media {
30 namespace cast { 32 namespace cast {
31 33
32 class LocalRtcpReceiverFeedback; 34 class LocalRtcpReceiverFeedback;
33 class PacedPacketSender; 35 class PacedPacketSender;
34 class RtcpReceiver; 36 class RtcpReceiver;
35 class RtcpBuilder; 37 class RtcpBuilder;
36 38
37 typedef std::pair<uint32, base::TimeTicks> RtcpSendTimePair; 39 typedef std::pair<uint32_t, base::TimeTicks> RtcpSendTimePair;
38 typedef std::map<uint32, base::TimeTicks> RtcpSendTimeMap; 40 typedef std::map<uint32_t, base::TimeTicks> RtcpSendTimeMap;
39 typedef std::queue<RtcpSendTimePair> RtcpSendTimeQueue; 41 typedef std::queue<RtcpSendTimePair> RtcpSendTimeQueue;
40 42
41 // TODO(hclam): This should be renamed to RtcpSession. 43 // TODO(hclam): This should be renamed to RtcpSession.
42 class Rtcp { 44 class Rtcp {
43 public: 45 public:
44 Rtcp(const RtcpCastMessageCallback& cast_callback, 46 Rtcp(const RtcpCastMessageCallback& cast_callback,
45 const RtcpRttCallback& rtt_callback, 47 const RtcpRttCallback& rtt_callback,
46 const RtcpLogMessageCallback& log_callback, 48 const RtcpLogMessageCallback& log_callback,
47 base::TickClock* clock, // Not owned. 49 base::TickClock* clock, // Not owned.
48 PacedPacketSender* packet_sender, // Not owned. 50 PacedPacketSender* packet_sender, // Not owned.
49 uint32 local_ssrc, 51 uint32_t local_ssrc,
50 uint32 remote_ssrc); 52 uint32_t remote_ssrc);
51 53
52 virtual ~Rtcp(); 54 virtual ~Rtcp();
53 55
54 // Send a RTCP sender report. 56 // Send a RTCP sender report.
55 // |current_time| is the current time reported by a tick clock. 57 // |current_time| is the current time reported by a tick clock.
56 // |current_time_as_rtp_timestamp| is the corresponding RTP timestamp. 58 // |current_time_as_rtp_timestamp| is the corresponding RTP timestamp.
57 // |send_packet_count| is the number of packets sent. 59 // |send_packet_count| is the number of packets sent.
58 // |send_octet_count| is the number of octets sent. 60 // |send_octet_count| is the number of octets sent.
59 void SendRtcpFromRtpSender( 61 void SendRtcpFromRtpSender(base::TimeTicks current_time,
60 base::TimeTicks current_time, 62 uint32_t current_time_as_rtp_timestamp,
61 uint32 current_time_as_rtp_timestamp, 63 uint32_t send_packet_count,
62 uint32 send_packet_count, 64 size_t send_octet_count);
63 size_t send_octet_count);
64 65
65 // This function is meant to be used in conjunction with 66 // This function is meant to be used in conjunction with
66 // SendRtcpFromRtpReceiver. 67 // SendRtcpFromRtpReceiver.
67 // |now| is converted to NTP and saved internally for 68 // |now| is converted to NTP and saved internally for
68 // future round-trip/lip-sync calculations. 69 // future round-trip/lip-sync calculations.
69 // This is done in a separate method so that SendRtcpFromRtpReceiver can 70 // This is done in a separate method so that SendRtcpFromRtpReceiver can
70 // be done on a separate (temporary) RTCP object. 71 // be done on a separate (temporary) RTCP object.
71 RtcpTimeData ConvertToNTPAndSave(base::TimeTicks now); 72 RtcpTimeData ConvertToNTPAndSave(base::TimeTicks now);
72 73
73 // |cast_message|, |rtcp_events| and |rtp_receiver_statistics| are optional; 74 // |cast_message|, |rtcp_events| and |rtp_receiver_statistics| are optional;
(...skipping 12 matching lines...) Expand all
86 // and used to maintain a RTCP session. 87 // and used to maintain a RTCP session.
87 // Returns false if this is not a RTCP packet or it is not directed to 88 // Returns false if this is not a RTCP packet or it is not directed to
88 // this session, e.g. SSRC doesn't match. 89 // this session, e.g. SSRC doesn't match.
89 bool IncomingRtcpPacket(const uint8* data, size_t length); 90 bool IncomingRtcpPacket(const uint8* data, size_t length);
90 91
91 // If available, returns true and sets the output arguments to the latest 92 // If available, returns true and sets the output arguments to the latest
92 // lip-sync timestamps gleaned from the sender reports. While the sender 93 // lip-sync timestamps gleaned from the sender reports. While the sender
93 // provides reference NTP times relative to its own wall clock, the 94 // provides reference NTP times relative to its own wall clock, the
94 // |reference_time| returned here has been translated to the local 95 // |reference_time| returned here has been translated to the local
95 // CastEnvironment clock. 96 // CastEnvironment clock.
96 bool GetLatestLipSyncTimes(uint32* rtp_timestamp, 97 bool GetLatestLipSyncTimes(uint32_t* rtp_timestamp,
97 base::TimeTicks* reference_time) const; 98 base::TimeTicks* reference_time) const;
98 99
99 void OnReceivedReceiverLog(const RtcpReceiverLogMessage& receiver_log); 100 void OnReceivedReceiverLog(const RtcpReceiverLogMessage& receiver_log);
100 101
101 // If greater than zero, this is the last measured network round trip time. 102 // If greater than zero, this is the last measured network round trip time.
102 base::TimeDelta current_round_trip_time() const { 103 base::TimeDelta current_round_trip_time() const {
103 return current_round_trip_time_; 104 return current_round_trip_time_;
104 } 105 }
105 106
106 static bool IsRtcpPacket(const uint8* packet, size_t length); 107 static bool IsRtcpPacket(const uint8* packet, size_t length);
107 static uint32 GetSsrcOfSender(const uint8* rtcp_buffer, size_t length); 108 static uint32_t GetSsrcOfSender(const uint8* rtcp_buffer, size_t length);
108 109
109 uint32 GetLocalSsrc() const { return local_ssrc_; } 110 uint32_t GetLocalSsrc() const { return local_ssrc_; }
110 uint32 GetRemoteSsrc() const { return remote_ssrc_; } 111 uint32_t GetRemoteSsrc() const { return remote_ssrc_; }
111 112
112 protected: 113 protected:
113 void OnReceivedNtp(uint32 ntp_seconds, uint32 ntp_fraction); 114 void OnReceivedNtp(uint32_t ntp_seconds, uint32_t ntp_fraction);
114 void OnReceivedLipSyncInfo(uint32 rtp_timestamp, 115 void OnReceivedLipSyncInfo(uint32_t rtp_timestamp,
115 uint32 ntp_seconds, 116 uint32_t ntp_seconds,
116 uint32 ntp_fraction); 117 uint32_t ntp_fraction);
117 118
118 private: 119 private:
119 void OnReceivedDelaySinceLastReport(uint32 last_report, 120 void OnReceivedDelaySinceLastReport(uint32_t last_report,
120 uint32 delay_since_last_report); 121 uint32_t delay_since_last_report);
121 122
122 void OnReceivedCastFeedback(const RtcpCastMessage& cast_message); 123 void OnReceivedCastFeedback(const RtcpCastMessage& cast_message);
123 124
124 void SaveLastSentNtpTime(const base::TimeTicks& now, 125 void SaveLastSentNtpTime(const base::TimeTicks& now,
125 uint32 last_ntp_seconds, 126 uint32_t last_ntp_seconds,
126 uint32 last_ntp_fraction); 127 uint32_t last_ntp_fraction);
127 128
128 // Remove duplicate events in |receiver_log|. 129 // Remove duplicate events in |receiver_log|.
129 // Returns true if any events remain. 130 // Returns true if any events remain.
130 bool DedupeReceiverLog(RtcpReceiverLogMessage* receiver_log); 131 bool DedupeReceiverLog(RtcpReceiverLogMessage* receiver_log);
131 132
132 const RtcpCastMessageCallback cast_callback_; 133 const RtcpCastMessageCallback cast_callback_;
133 const RtcpRttCallback rtt_callback_; 134 const RtcpRttCallback rtt_callback_;
134 const RtcpLogMessageCallback log_callback_; 135 const RtcpLogMessageCallback log_callback_;
135 base::TickClock* const clock_; // Not owned by this class. 136 base::TickClock* const clock_; // Not owned by this class.
136 RtcpBuilder rtcp_builder_; 137 RtcpBuilder rtcp_builder_;
137 PacedPacketSender* packet_sender_; // Not owned. 138 PacedPacketSender* packet_sender_; // Not owned.
138 const uint32 local_ssrc_; 139 const uint32_t local_ssrc_;
139 const uint32 remote_ssrc_; 140 const uint32_t remote_ssrc_;
140 141
141 RtcpSendTimeMap last_reports_sent_map_; 142 RtcpSendTimeMap last_reports_sent_map_;
142 RtcpSendTimeQueue last_reports_sent_queue_; 143 RtcpSendTimeQueue last_reports_sent_queue_;
143 144
144 // The truncated (i.e., 64-->32-bit) NTP timestamp provided in the last report 145 // The truncated (i.e., 64-->32-bit) NTP timestamp provided in the last report
145 // from the remote peer, along with the local time at which the report was 146 // from the remote peer, along with the local time at which the report was
146 // received. These values are used for ping-pong'ing NTP timestamps between 147 // received. These values are used for ping-pong'ing NTP timestamps between
147 // the peers so that they can estimate the network's round-trip time. 148 // the peers so that they can estimate the network's round-trip time.
148 uint32 last_report_truncated_ntp_; 149 uint32_t last_report_truncated_ntp_;
149 base::TimeTicks time_last_report_received_; 150 base::TimeTicks time_last_report_received_;
150 151
151 // Maintains a smoothed offset between the local clock and the remote clock. 152 // Maintains a smoothed offset between the local clock and the remote clock.
152 // Calling this member's Current() method is only valid if 153 // Calling this member's Current() method is only valid if
153 // |time_last_report_received_| is not "null." 154 // |time_last_report_received_| is not "null."
154 ClockDriftSmoother local_clock_ahead_by_; 155 ClockDriftSmoother local_clock_ahead_by_;
155 156
156 // Latest "lip sync" info from the sender. The sender provides the RTP 157 // Latest "lip sync" info from the sender. The sender provides the RTP
157 // timestamp of some frame of its choosing and also a corresponding reference 158 // timestamp of some frame of its choosing and also a corresponding reference
158 // NTP timestamp sampled from a clock common to all media streams. It is 159 // NTP timestamp sampled from a clock common to all media streams. It is
159 // expected that the sender will update this data regularly and in a timely 160 // expected that the sender will update this data regularly and in a timely
160 // manner (e.g., about once per second). 161 // manner (e.g., about once per second).
161 uint32 lip_sync_rtp_timestamp_; 162 uint32_t lip_sync_rtp_timestamp_;
162 uint64 lip_sync_ntp_timestamp_; 163 uint64_t lip_sync_ntp_timestamp_;
163 164
164 // The last measured network round trip time. This is updated with each 165 // The last measured network round trip time. This is updated with each
165 // sender report --> receiver report round trip. If this is zero, then the 166 // sender report --> receiver report round trip. If this is zero, then the
166 // round trip time has not been measured yet. 167 // round trip time has not been measured yet.
167 base::TimeDelta current_round_trip_time_; 168 base::TimeDelta current_round_trip_time_;
168 169
169 base::TimeTicks largest_seen_timestamp_; 170 base::TimeTicks largest_seen_timestamp_;
170 171
171 // For extending received ACK frame IDs from 8-bit to 32-bit. 172 // For extending received ACK frame IDs from 8-bit to 32-bit.
172 FrameIdWrapHelper ack_frame_id_wrap_helper_; 173 FrameIdWrapHelper ack_frame_id_wrap_helper_;
173 174
174 // Maintains a history of receiver events. 175 // Maintains a history of receiver events.
175 typedef std::pair<uint64, uint64> ReceiverEventKey; 176 typedef std::pair<uint64_t, uint64_t> ReceiverEventKey;
176 base::hash_set<ReceiverEventKey> receiver_event_key_set_; 177 base::hash_set<ReceiverEventKey> receiver_event_key_set_;
177 std::queue<ReceiverEventKey> receiver_event_key_queue_; 178 std::queue<ReceiverEventKey> receiver_event_key_queue_;
178 179
179 DISALLOW_COPY_AND_ASSIGN(Rtcp); 180 DISALLOW_COPY_AND_ASSIGN(Rtcp);
180 }; 181 };
181 182
182 } // namespace cast 183 } // namespace cast
183 } // namespace media 184 } // namespace media
184 185
185 #endif // MEDIA_CAST_RTCP_RTCP_H_ 186 #endif // MEDIA_CAST_RTCP_RTCP_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698