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

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: rebase 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
« no previous file with comments | « media/cast/cast_defines.h ('k') | media/cast/rtcp/rtcp.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
105
101 bool is_rtt_available() const { return number_of_rtt_in_avg_ > 0; } 106 bool is_rtt_available() const { return number_of_rtt_in_avg_ > 0; }
102 bool RtpTimestampInSenderTime(int frequency, 107
103 uint32 rtp_timestamp, 108 // If available, returns true and sets the output arguments to the latest
104 base::TimeTicks* rtp_timestamp_in_ticks) const; 109 // lip-sync timestamps gleaned from the sender reports. While the sender
110 // provides reference NTP times relative to its own wall clock, the
111 // |reference_time| returned here has been translated to the local
112 // CastEnvironment clock.
113 bool GetLatestLipSyncTimes(uint32* rtp_timestamp,
114 base::TimeTicks* reference_time) const;
105 115
106 // Set the history size to record Cast receiver events. The event history is 116 // Set the history size to record Cast receiver events. The event history is
107 // used to remove duplicates. The history will store at most |size| events. 117 // used to remove duplicates. The history will store at most |size| events.
108 void SetCastReceiverEventHistorySize(size_t size); 118 void SetCastReceiverEventHistorySize(size_t size);
109 119
110 // Update the target delay. Will be added to every sender report. 120 // Update the target delay. Will be added to every report sent back to the
121 // sender.
122 // TODO(miu): Remove this deprecated functionality. The sender ignores this.
111 void SetTargetDelay(base::TimeDelta target_delay); 123 void SetTargetDelay(base::TimeDelta target_delay);
112 124
113 void OnReceivedReceiverLog(const RtcpReceiverLogMessage& receiver_log); 125 void OnReceivedReceiverLog(const RtcpReceiverLogMessage& receiver_log);
114 126
115 protected: 127 protected:
116 int CheckForWrapAround(uint32 new_timestamp, uint32 old_timestamp) const; 128 void OnReceivedNtp(uint32 ntp_seconds, uint32 ntp_fraction);
117
118 void OnReceivedLipSyncInfo(uint32 rtp_timestamp, 129 void OnReceivedLipSyncInfo(uint32 rtp_timestamp,
119 uint32 ntp_seconds, 130 uint32 ntp_seconds,
120 uint32 ntp_fraction); 131 uint32 ntp_fraction);
121 132
122 private: 133 private:
123 friend class LocalRtcpRttFeedback; 134 friend class LocalRtcpRttFeedback;
124 friend class LocalRtcpReceiverFeedback; 135 friend class LocalRtcpReceiverFeedback;
125 136
126 void SendRtcp(const base::TimeTicks& now,
127 uint32 packet_type_flags,
128 uint32 media_ssrc,
129 const RtcpCastMessage* cast_message);
130
131 void OnReceivedNtp(uint32 ntp_seconds, uint32 ntp_fraction);
132
133 void OnReceivedDelaySinceLastReport(uint32 receivers_ssrc, 137 void OnReceivedDelaySinceLastReport(uint32 receivers_ssrc,
134 uint32 last_report, 138 uint32 last_report,
135 uint32 delay_since_last_report); 139 uint32 delay_since_last_report);
136 140
137 void OnReceivedSendReportRequest(); 141 void OnReceivedSendReportRequest();
138 142
139 void UpdateRtt(const base::TimeDelta& sender_delay, 143 void UpdateRtt(const base::TimeDelta& sender_delay,
140 const base::TimeDelta& receiver_delay); 144 const base::TimeDelta& receiver_delay);
141 145
142 void UpdateNextTimeToSendRtcp(); 146 void UpdateNextTimeToSendRtcp();
(...skipping 14 matching lines...) Expand all
157 RtpReceiverStatistics* const rtp_receiver_statistics_; 161 RtpReceiverStatistics* const rtp_receiver_statistics_;
158 162
159 scoped_ptr<LocalRtcpRttFeedback> rtt_feedback_; 163 scoped_ptr<LocalRtcpRttFeedback> rtt_feedback_;
160 scoped_ptr<LocalRtcpReceiverFeedback> receiver_feedback_; 164 scoped_ptr<LocalRtcpReceiverFeedback> receiver_feedback_;
161 scoped_ptr<RtcpSender> rtcp_sender_; 165 scoped_ptr<RtcpSender> rtcp_sender_;
162 scoped_ptr<RtcpReceiver> rtcp_receiver_; 166 scoped_ptr<RtcpReceiver> rtcp_receiver_;
163 167
164 base::TimeTicks next_time_to_send_rtcp_; 168 base::TimeTicks next_time_to_send_rtcp_;
165 RtcpSendTimeMap last_reports_sent_map_; 169 RtcpSendTimeMap last_reports_sent_map_;
166 RtcpSendTimeQueue last_reports_sent_queue_; 170 RtcpSendTimeQueue last_reports_sent_queue_;
171
172 // The truncated (i.e., 64-->32-bit) NTP timestamp provided in the last report
173 // from the remote peer, along with the local time at which the report was
174 // received. These values are used for ping-pong'ing NTP timestamps between
175 // the peers so that they can estimate the network's round-trip time.
176 uint32 last_report_truncated_ntp_;
167 base::TimeTicks time_last_report_received_; 177 base::TimeTicks time_last_report_received_;
168 uint32 last_report_received_;
169 178
170 uint32 last_received_rtp_timestamp_; 179 // Maintains a smoothed offset between the local clock and the remote clock.
171 uint32 last_received_ntp_seconds_; 180 // Calling this member's Current() method is only valid if
172 uint32 last_received_ntp_fraction_; 181 // |time_last_report_received_| is not "null."
182 ClockDriftSmoother local_clock_ahead_by_;
183
184 // Latest "lip sync" info from the sender. The sender provides the RTP
185 // timestamp of some frame of its choosing and also a corresponding reference
186 // NTP timestamp sampled from a clock common to all media streams. It is
187 // expected that the sender will update this data regularly and in a timely
188 // manner (e.g., about once per second).
189 uint32 lip_sync_rtp_timestamp_;
190 uint64 lip_sync_ntp_timestamp_;
173 191
174 base::TimeDelta rtt_; 192 base::TimeDelta rtt_;
175 base::TimeDelta min_rtt_; 193 base::TimeDelta min_rtt_;
176 base::TimeDelta max_rtt_; 194 base::TimeDelta max_rtt_;
177 int number_of_rtt_in_avg_; 195 int number_of_rtt_in_avg_;
178 float avg_rtt_ms_; 196 double avg_rtt_ms_;
179 uint16 target_delay_ms_; 197 uint16 target_delay_ms_;
180 bool is_audio_; 198 bool is_audio_;
181 199
182 DISALLOW_COPY_AND_ASSIGN(Rtcp); 200 DISALLOW_COPY_AND_ASSIGN(Rtcp);
183 }; 201 };
184 202
185 } // namespace cast 203 } // namespace cast
186 } // namespace media 204 } // namespace media
187 205
188 #endif // MEDIA_CAST_RTCP_RTCP_H_ 206 #endif // MEDIA_CAST_RTCP_RTCP_H_
OLDNEW
« no previous file with comments | « media/cast/cast_defines.h ('k') | media/cast/rtcp/rtcp.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698