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

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

Issue 280993002: [Cast] Repair receiver playout time calculations and frame skip logic. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added playout_time smoothness checks in End2EndTest. Created 6 years, 7 months 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 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 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 #ifndef MEDIA_CAST_RTCP_RTCP_H_ 5 #ifndef MEDIA_CAST_RTCP_RTCP_H_
6 #define MEDIA_CAST_RTCP_RTCP_H_ 6 #define MEDIA_CAST_RTCP_RTCP_H_
7 7
8 #include <list>
9 #include <map> 8 #include <map>
10 #include <queue> 9 #include <queue>
11 #include <set>
12 #include <string> 10 #include <string>
13 11
14 #include "base/basictypes.h" 12 #include "base/basictypes.h"
15 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
16 #include "base/time/tick_clock.h" 14 #include "base/time/tick_clock.h"
17 #include "base/time/time.h" 15 #include "base/time/time.h"
16 #include "media/cast/base/clock_drift_smoother.h"
18 #include "media/cast/cast_config.h" 17 #include "media/cast/cast_config.h"
19 #include "media/cast/cast_defines.h" 18 #include "media/cast/cast_defines.h"
20 #include "media/cast/cast_environment.h" 19 #include "media/cast/cast_environment.h"
21 #include "media/cast/rtcp/receiver_rtcp_event_subscriber.h" 20 #include "media/cast/rtcp/receiver_rtcp_event_subscriber.h"
22 #include "media/cast/rtcp/rtcp_defines.h" 21 #include "media/cast/rtcp/rtcp_defines.h"
23 #include "media/cast/transport/cast_transport_defines.h" 22 #include "media/cast/transport/cast_transport_defines.h"
24 #include "media/cast/transport/cast_transport_sender.h" 23 #include "media/cast/transport/cast_transport_sender.h"
25 #include "media/cast/transport/pacing/paced_sender.h" 24 #include "media/cast/transport/pacing/paced_sender.h"
26 25
27 namespace media { 26 namespace media {
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 86
88 // |cast_message| and |rtcp_events| is optional; if |cast_message| is 87 // |cast_message| and |rtcp_events| is optional; if |cast_message| is
89 // provided the RTCP receiver report will append a Cast message containing 88 // provided the RTCP receiver report will append a Cast message containing
90 // Acks and Nacks; if |rtcp_events| is provided the RTCP receiver report 89 // Acks and Nacks; if |rtcp_events| is provided the RTCP receiver report
91 // will append the log messages. 90 // will append the log messages.
92 void SendRtcpFromRtpReceiver( 91 void SendRtcpFromRtpReceiver(
93 const RtcpCastMessage* cast_message, 92 const RtcpCastMessage* cast_message,
94 const ReceiverRtcpEventSubscriber::RtcpEventMultiMap* rtcp_events); 93 const ReceiverRtcpEventSubscriber::RtcpEventMultiMap* rtcp_events);
95 94
96 void IncomingRtcpPacket(const uint8* rtcp_buffer, size_t length); 95 void IncomingRtcpPacket(const uint8* rtcp_buffer, size_t length);
96
97 // TODO(miu): Clean up this method and downstream code: Only VideoSender uses
98 // this (for congestion control), and only the |rtt| and |avg_rtt| values, and
99 // it's not clear that any of the downstream code is doing the right thing
100 // with this data.
97 bool Rtt(base::TimeDelta* rtt, 101 bool Rtt(base::TimeDelta* rtt,
98 base::TimeDelta* avg_rtt, 102 base::TimeDelta* avg_rtt,
99 base::TimeDelta* min_rtt, 103 base::TimeDelta* min_rtt,
100 base::TimeDelta* max_rtt) const; 104 base::TimeDelta* max_rtt) const;
101 bool RtpTimestampInSenderTime(int frequency, 105
102 uint32 rtp_timestamp, 106 // If available, returns true and sets the output arguments to the latest
103 base::TimeTicks* rtp_timestamp_in_ticks) const; 107 // lip-sync timestamps gleaned from the sender reports. While the sender
108 // provides reference NTP times relative to its own wall clock, the
109 // |reference_time| returned here has been translated to the local
110 // CastEnvironment clock.
111 bool GetLatestLipSyncTimes(uint32* rtp_timestamp,
112 base::TimeTicks* reference_time) const;
113
104 114
105 // Set the history size to record Cast receiver events. The event history is 115 // Set the history size to record Cast receiver events. The event history is
106 // used to remove duplicates. The history will store at most |size| events. 116 // used to remove duplicates. The history will store at most |size| events.
107 void SetCastReceiverEventHistorySize(size_t size); 117 void SetCastReceiverEventHistorySize(size_t size);
108 118
109 // Update the target delay. Will be added to every sender report. 119 // Update the target delay. Will be added to every report sent back to the
120 // sender.
121 // TODO(miu): Remove this deprecated functionality. The sender ignores this.
110 void SetTargetDelay(base::TimeDelta target_delay); 122 void SetTargetDelay(base::TimeDelta target_delay);
111 123
112 void OnReceivedReceiverLog(const RtcpReceiverLogMessage& receiver_log); 124 void OnReceivedReceiverLog(const RtcpReceiverLogMessage& receiver_log);
113 125
114 protected: 126 protected:
115 int CheckForWrapAround(uint32 new_timestamp, uint32 old_timestamp) const; 127 void OnReceivedNtp(uint32 ntp_seconds, uint32 ntp_fraction);
116
117 void OnReceivedLipSyncInfo(uint32 rtp_timestamp, 128 void OnReceivedLipSyncInfo(uint32 rtp_timestamp,
118 uint32 ntp_seconds, 129 uint32 ntp_seconds,
119 uint32 ntp_fraction); 130 uint32 ntp_fraction);
120 131
121 private: 132 private:
122 friend class LocalRtcpRttFeedback; 133 friend class LocalRtcpRttFeedback;
123 friend class LocalRtcpReceiverFeedback; 134 friend class LocalRtcpReceiverFeedback;
124 135
125 void SendRtcp(const base::TimeTicks& now,
126 uint32 packet_type_flags,
127 uint32 media_ssrc,
128 const RtcpCastMessage* cast_message);
129
130 void OnReceivedNtp(uint32 ntp_seconds, uint32 ntp_fraction);
131
132 void OnReceivedDelaySinceLastReport(uint32 receivers_ssrc, 136 void OnReceivedDelaySinceLastReport(uint32 receivers_ssrc,
133 uint32 last_report, 137 uint32 last_report,
134 uint32 delay_since_last_report); 138 uint32 delay_since_last_report);
135 139
136 void OnReceivedSendReportRequest(); 140 void OnReceivedSendReportRequest();
137 141
138 void UpdateRtt(const base::TimeDelta& sender_delay, 142 void UpdateRtt(const base::TimeDelta& sender_delay,
139 const base::TimeDelta& receiver_delay); 143 const base::TimeDelta& receiver_delay);
140 144
141 void UpdateNextTimeToSendRtcp(); 145 void UpdateNextTimeToSendRtcp();
(...skipping 14 matching lines...) Expand all
156 RtpReceiverStatistics* const rtp_receiver_statistics_; 160 RtpReceiverStatistics* const rtp_receiver_statistics_;
157 161
158 scoped_ptr<LocalRtcpRttFeedback> rtt_feedback_; 162 scoped_ptr<LocalRtcpRttFeedback> rtt_feedback_;
159 scoped_ptr<LocalRtcpReceiverFeedback> receiver_feedback_; 163 scoped_ptr<LocalRtcpReceiverFeedback> receiver_feedback_;
160 scoped_ptr<RtcpSender> rtcp_sender_; 164 scoped_ptr<RtcpSender> rtcp_sender_;
161 scoped_ptr<RtcpReceiver> rtcp_receiver_; 165 scoped_ptr<RtcpReceiver> rtcp_receiver_;
162 166
163 base::TimeTicks next_time_to_send_rtcp_; 167 base::TimeTicks next_time_to_send_rtcp_;
164 RtcpSendTimeMap last_reports_sent_map_; 168 RtcpSendTimeMap last_reports_sent_map_;
165 RtcpSendTimeQueue last_reports_sent_queue_; 169 RtcpSendTimeQueue last_reports_sent_queue_;
170
171 // The truncated (i.e., 64-->32-bit) NTP timestamp provided in the last report
172 // from the remote peer, along with the local time at which the report was
173 // received. These values are used for ping-pong'ing NTP timestamps between
174 // the peers so that they can estimate the network's round-trip time.
175 uint32 last_report_truncated_ntp_;
166 base::TimeTicks time_last_report_received_; 176 base::TimeTicks time_last_report_received_;
167 uint32 last_report_received_;
168 177
169 uint32 last_received_rtp_timestamp_; 178 // Maintains a smoothed offset between the local clock and the remote clock.
170 uint32 last_received_ntp_seconds_; 179 // Calling this member's Current() method is only valid if
171 uint32 last_received_ntp_fraction_; 180 // |time_last_report_received_| is not "null."
181 ClockDriftSmoother local_clock_ahead_by_;
182
183 // Latest "lip sync" info from the sender. The sender provides the RTP
184 // timestamp of some frame of its choosing and also a corresponding reference
185 // NTP timestamp sampled from a clock common to all media streams. It is
186 // expected that the sender will update this data regularly and in a timely
187 // manner (e.g., about once per second).
188 uint32 lip_sync_rtp_timestamp_;
189 uint64 lip_sync_ntp_timestamp_;
172 190
173 base::TimeDelta rtt_; 191 base::TimeDelta rtt_;
174 base::TimeDelta min_rtt_; 192 base::TimeDelta min_rtt_;
175 base::TimeDelta max_rtt_; 193 base::TimeDelta max_rtt_;
176 int number_of_rtt_in_avg_; 194 int number_of_rtt_in_avg_;
177 float avg_rtt_ms_; 195 double avg_rtt_ms_;
178 uint16 target_delay_ms_; 196 uint16 target_delay_ms_;
179 bool is_audio_; 197 bool is_audio_;
180 198
181 DISALLOW_COPY_AND_ASSIGN(Rtcp); 199 DISALLOW_COPY_AND_ASSIGN(Rtcp);
182 }; 200 };
183 201
184 } // namespace cast 202 } // namespace cast
185 } // namespace media 203 } // namespace media
186 204
187 #endif // MEDIA_CAST_RTCP_RTCP_H_ 205 #endif // MEDIA_CAST_RTCP_RTCP_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698