| OLD | NEW |
| 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 |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 base::TimeDelta target_delay, | 81 base::TimeDelta target_delay, |
| 82 const ReceiverRtcpEventSubscriber::RtcpEventMultiMap* rtcp_events, | 82 const ReceiverRtcpEventSubscriber::RtcpEventMultiMap* rtcp_events, |
| 83 RtpReceiverStatistics* rtp_receiver_statistics); | 83 RtpReceiverStatistics* rtp_receiver_statistics); |
| 84 | 84 |
| 85 // Submit a received packet to this object. The packet will be parsed | 85 // Submit a received packet to this object. The packet will be parsed |
| 86 // and used to maintain a RTCP session. | 86 // and used to maintain a RTCP session. |
| 87 // Returns false if this is not a RTCP packet or it is not directed to | 87 // Returns false if this is not a RTCP packet or it is not directed to |
| 88 // this session, e.g. SSRC doesn't match. | 88 // this session, e.g. SSRC doesn't match. |
| 89 bool IncomingRtcpPacket(const uint8* data, size_t length); | 89 bool IncomingRtcpPacket(const uint8* data, size_t length); |
| 90 | 90 |
| 91 // TODO(miu): Clean up this method and downstream code: Only VideoSender uses | |
| 92 // this (for congestion control), and only the |rtt| and |avg_rtt| values, and | |
| 93 // it's not clear that any of the downstream code is doing the right thing | |
| 94 // with this data. | |
| 95 bool Rtt(base::TimeDelta* rtt, | |
| 96 base::TimeDelta* avg_rtt, | |
| 97 base::TimeDelta* min_rtt, | |
| 98 base::TimeDelta* max_rtt) const; | |
| 99 | |
| 100 // If available, returns true and sets the output arguments to the latest | 91 // If available, returns true and sets the output arguments to the latest |
| 101 // lip-sync timestamps gleaned from the sender reports. While the sender | 92 // lip-sync timestamps gleaned from the sender reports. While the sender |
| 102 // provides reference NTP times relative to its own wall clock, the | 93 // provides reference NTP times relative to its own wall clock, the |
| 103 // |reference_time| returned here has been translated to the local | 94 // |reference_time| returned here has been translated to the local |
| 104 // CastEnvironment clock. | 95 // CastEnvironment clock. |
| 105 bool GetLatestLipSyncTimes(uint32* rtp_timestamp, | 96 bool GetLatestLipSyncTimes(uint32* rtp_timestamp, |
| 106 base::TimeTicks* reference_time) const; | 97 base::TimeTicks* reference_time) const; |
| 107 | 98 |
| 108 void OnReceivedReceiverLog(const RtcpReceiverLogMessage& receiver_log); | 99 void OnReceivedReceiverLog(const RtcpReceiverLogMessage& receiver_log); |
| 109 | 100 |
| 101 // If greater than zero, this is the last measured network round trip time. |
| 102 base::TimeDelta current_round_trip_time() const { |
| 103 return current_round_trip_time_; |
| 104 } |
| 105 |
| 110 static bool IsRtcpPacket(const uint8* packet, size_t length); | 106 static bool IsRtcpPacket(const uint8* packet, size_t length); |
| 111 static uint32 GetSsrcOfSender(const uint8* rtcp_buffer, size_t length); | 107 static uint32 GetSsrcOfSender(const uint8* rtcp_buffer, size_t length); |
| 112 const base::TimeDelta& rtt() const { return rtt_; } | |
| 113 | 108 |
| 114 protected: | 109 protected: |
| 115 void OnReceivedNtp(uint32 ntp_seconds, uint32 ntp_fraction); | 110 void OnReceivedNtp(uint32 ntp_seconds, uint32 ntp_fraction); |
| 116 void OnReceivedLipSyncInfo(uint32 rtp_timestamp, | 111 void OnReceivedLipSyncInfo(uint32 rtp_timestamp, |
| 117 uint32 ntp_seconds, | 112 uint32 ntp_seconds, |
| 118 uint32 ntp_fraction); | 113 uint32 ntp_fraction); |
| 119 | 114 |
| 120 private: | 115 private: |
| 121 void OnReceivedDelaySinceLastReport(uint32 last_report, | 116 void OnReceivedDelaySinceLastReport(uint32 last_report, |
| 122 uint32 delay_since_last_report); | 117 uint32 delay_since_last_report); |
| 123 | 118 |
| 124 void OnReceivedCastFeedback(const RtcpCastMessage& cast_message); | 119 void OnReceivedCastFeedback(const RtcpCastMessage& cast_message); |
| 125 | 120 |
| 126 void UpdateRtt(const base::TimeDelta& sender_delay, | |
| 127 const base::TimeDelta& receiver_delay); | |
| 128 | |
| 129 void SaveLastSentNtpTime(const base::TimeTicks& now, | 121 void SaveLastSentNtpTime(const base::TimeTicks& now, |
| 130 uint32 last_ntp_seconds, | 122 uint32 last_ntp_seconds, |
| 131 uint32 last_ntp_fraction); | 123 uint32 last_ntp_fraction); |
| 132 | 124 |
| 133 // Remove duplicate events in |receiver_log|. | 125 // Remove duplicate events in |receiver_log|. |
| 134 // Returns true if any events remain. | 126 // Returns true if any events remain. |
| 135 bool DedupeReceiverLog(RtcpReceiverLogMessage* receiver_log); | 127 bool DedupeReceiverLog(RtcpReceiverLogMessage* receiver_log); |
| 136 | 128 |
| 137 const RtcpCastMessageCallback cast_callback_; | 129 const RtcpCastMessageCallback cast_callback_; |
| 138 const RtcpRttCallback rtt_callback_; | 130 const RtcpRttCallback rtt_callback_; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 158 ClockDriftSmoother local_clock_ahead_by_; | 150 ClockDriftSmoother local_clock_ahead_by_; |
| 159 | 151 |
| 160 // Latest "lip sync" info from the sender. The sender provides the RTP | 152 // Latest "lip sync" info from the sender. The sender provides the RTP |
| 161 // timestamp of some frame of its choosing and also a corresponding reference | 153 // timestamp of some frame of its choosing and also a corresponding reference |
| 162 // NTP timestamp sampled from a clock common to all media streams. It is | 154 // NTP timestamp sampled from a clock common to all media streams. It is |
| 163 // expected that the sender will update this data regularly and in a timely | 155 // expected that the sender will update this data regularly and in a timely |
| 164 // manner (e.g., about once per second). | 156 // manner (e.g., about once per second). |
| 165 uint32 lip_sync_rtp_timestamp_; | 157 uint32 lip_sync_rtp_timestamp_; |
| 166 uint64 lip_sync_ntp_timestamp_; | 158 uint64 lip_sync_ntp_timestamp_; |
| 167 | 159 |
| 168 base::TimeDelta rtt_; | 160 // The last measured network round trip time. This is updated with each |
| 169 base::TimeDelta min_rtt_; | 161 // sender report --> receiver report round trip. If this is zero, then the |
| 170 base::TimeDelta max_rtt_; | 162 // round trip time has not been measured yet. |
| 171 int number_of_rtt_in_avg_; | 163 base::TimeDelta current_round_trip_time_; |
| 172 base::TimeDelta avg_rtt_; | |
| 173 | 164 |
| 174 base::TimeTicks largest_seen_timestamp_; | 165 base::TimeTicks largest_seen_timestamp_; |
| 175 | 166 |
| 176 // For extending received ACK frame IDs from 8-bit to 32-bit. | 167 // For extending received ACK frame IDs from 8-bit to 32-bit. |
| 177 FrameIdWrapHelper ack_frame_id_wrap_helper_; | 168 FrameIdWrapHelper ack_frame_id_wrap_helper_; |
| 178 | 169 |
| 179 // Maintains a history of receiver events. | 170 // Maintains a history of receiver events. |
| 180 typedef std::pair<uint64, uint64> ReceiverEventKey; | 171 typedef std::pair<uint64, uint64> ReceiverEventKey; |
| 181 base::hash_set<ReceiverEventKey> receiver_event_key_set_; | 172 base::hash_set<ReceiverEventKey> receiver_event_key_set_; |
| 182 std::queue<ReceiverEventKey> receiver_event_key_queue_; | 173 std::queue<ReceiverEventKey> receiver_event_key_queue_; |
| 183 | 174 |
| 184 DISALLOW_COPY_AND_ASSIGN(Rtcp); | 175 DISALLOW_COPY_AND_ASSIGN(Rtcp); |
| 185 }; | 176 }; |
| 186 | 177 |
| 187 } // namespace cast | 178 } // namespace cast |
| 188 } // namespace media | 179 } // namespace media |
| 189 | 180 |
| 190 #endif // MEDIA_CAST_RTCP_RTCP_H_ | 181 #endif // MEDIA_CAST_RTCP_RTCP_H_ |
| OLD | NEW |