Index: media/cast/rtcp/rtcp.h |
diff --git a/media/cast/rtcp/rtcp.h b/media/cast/rtcp/rtcp.h |
index 52c9178acfadf18f4f7f76aefd749bbbfaf98b20..6170c79acb84774d44e18fbd5e069096361da887 100644 |
--- a/media/cast/rtcp/rtcp.h |
+++ b/media/cast/rtcp/rtcp.h |
@@ -5,10 +5,8 @@ |
#ifndef MEDIA_CAST_RTCP_RTCP_H_ |
#define MEDIA_CAST_RTCP_RTCP_H_ |
-#include <list> |
#include <map> |
#include <queue> |
-#include <set> |
#include <string> |
#include "base/basictypes.h" |
@@ -101,22 +99,45 @@ class Rtcp { |
base::TimeDelta* avg_rtt, |
base::TimeDelta* min_rtt, |
base::TimeDelta* max_rtt) const; |
- bool RtpTimestampInSenderTime(int frequency, |
- uint32 rtp_timestamp, |
- base::TimeTicks* rtp_timestamp_in_ticks) const; |
+ |
+ // Uses recent reports from the remote to translate remote-provided NTP |
+ // timestamps into TimeTicks values relative to the local clock. Returns a |
+ // null TimeTicks value to indicate a usable report has not yet been received. |
+ // |
+ // Note: The values returned are not guaranteed to be monotonically increasing |
+ // for monotonically increasing NTP timestamps. In fact, it's possible that |
+ // calling this method more than once with the same arguments will return |
+ // different results. |
+ base::TimeTicks ToApproximateLocalTime(uint32 remote_ntp_seconds, |
hubbe
2014/05/14 23:12:23
Can this be made private?
miu
2014/05/16 22:45:47
Done.
|
+ uint32 remote_ntp_fraction) const; |
+ |
+ // Maps a frame's |rtp_timestamp| to its approximate capture time, based on |
+ // the latest "lip sync" info gleaned from the sender reports. The returned |
+ // TimeTicks value is relative to the local CastEnvironment clock. Returns a |
+ // null TimeTicks value to indicate no lip sync info was available. |
+ // |rtp_timebase| is the number of units of |rtp_timestamp| that elapse per |
+ // one second (e.g., for audio, this is usually the sampling frequency). |
+ // |
+ // Note: The values returned are not guaranteed to be monotonically increasing |
+ // for monotonically increasing rtp_timestamps. In fact, it's possible that |
+ // calling this method more than once with the same arguments will return |
+ // different results. |
+ base::TimeTicks ToApproximateCaptureTime(uint32 rtp_timestamp, |
+ int rtp_timebase) const; |
// Set the history size to record Cast receiver events. The event history is |
// used to remove duplicates. The history will store at most |size| events. |
void SetCastReceiverEventHistorySize(size_t size); |
- // Update the target delay. Will be added to every sender report. |
+ // Update the target delay. Will be added to every report sent back to the |
+ // sender. |
+ // TODO(miu): Remove this deprecated functionality. The sender ignores this. |
void SetTargetDelay(base::TimeDelta target_delay); |
void OnReceivedReceiverLog(const RtcpReceiverLogMessage& receiver_log); |
protected: |
- int CheckForWrapAround(uint32 new_timestamp, uint32 old_timestamp) const; |
- |
+ void OnReceivedNtp(uint32 ntp_seconds, uint32 ntp_fraction); |
void OnReceivedLipSyncInfo(uint32 rtp_timestamp, |
uint32 ntp_seconds, |
uint32 ntp_fraction); |
@@ -130,8 +151,6 @@ class Rtcp { |
uint32 media_ssrc, |
const RtcpCastMessage* cast_message); |
- void OnReceivedNtp(uint32 ntp_seconds, uint32 ntp_fraction); |
- |
void OnReceivedDelaySinceLastReport(uint32 receivers_ssrc, |
uint32 last_report, |
uint32 delay_since_last_report); |
@@ -147,6 +166,10 @@ class Rtcp { |
uint32 last_ntp_seconds, |
uint32 last_ntp_fraction); |
+ // Returns a truncated 16+16-bit NTP timestamp, computed from the full |
+ // 32+32-bit NTP timestamp in |last_report_ntp_time_|. |
+ uint32 GetTruncatedLastNtpReportTime() const; |
hubbe
2014/05/14 23:12:23
Where is the inverse of this function?
miu
2014/05/16 22:45:47
Not implemented. It appears to be parsed and deli
|
+ |
scoped_refptr<CastEnvironment> cast_environment_; |
transport::CastTransportSender* const transport_sender_; |
const base::TimeDelta rtcp_interval_; |
@@ -166,18 +189,27 @@ class Rtcp { |
base::TimeTicks next_time_to_send_rtcp_; |
RtcpSendTimeMap last_reports_sent_map_; |
RtcpSendTimeQueue last_reports_sent_queue_; |
+ |
+ // The NTP timestamp provided in the last report from the remote peer, along |
+ // with the local time at which the report was received. These two values are |
+ // used both for: 1) ping-pong'ing NTP timestamps between the peers; and 2) |
+ // computing the local clock's offset from the remote clock. |
+ uint64 last_report_ntp_time_; |
hubbe
2014/05/14 23:12:23
Don't we need some sort of min() calculation for t
miu
2014/05/16 22:45:47
Nope. These are just snapshots from the latest se
hubbe
2014/05/19 17:52:20
Hmm, maybe I'm missing something. Isn't this used
miu
2014/05/23 03:09:00
Done. Created a ClockDriftSmoother, and incorpora
|
base::TimeTicks time_last_report_received_; |
- uint32 last_report_received_; |
- uint32 last_received_rtp_timestamp_; |
- uint32 last_received_ntp_seconds_; |
- uint32 last_received_ntp_fraction_; |
+ // Latest "lip sync" info from the sender. The sender provides the RTP |
+ // timestamp of some frame of its choosing and also the frame's capture time. |
+ // This allows the receiver to approximate the capture times of other frames |
+ // based on their RTP timestamp. It is expected that the sender will update |
+ // this data regularly and in a timely manner (i.e., about once per second). |
hubbe
2014/05/14 23:12:23
i.e. -> e.g.
miu
2014/05/16 22:45:47
Done.
|
+ uint32 lip_sync_rtp_timestamp_; |
+ base::TimeTicks lip_sync_capture_time_; |
base::TimeDelta rtt_; |
base::TimeDelta min_rtt_; |
base::TimeDelta max_rtt_; |
int number_of_rtt_in_avg_; |
- float avg_rtt_ms_; |
+ double avg_rtt_ms_; |
uint16 target_delay_ms_; |
bool is_audio_; |