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

Unified Diff: media/cast/sender/rtp_timestamp_helper.cc

Issue 502333002: [Cast] In Audio/VideoSender, drop frames when too-long a duration is in-flight. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Based on TimeDelta rather than RTP delta. Created 6 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: media/cast/sender/rtp_timestamp_helper.cc
diff --git a/media/cast/sender/rtp_timestamp_helper.cc b/media/cast/sender/rtp_timestamp_helper.cc
index ea0c35c66fbf130d3b41d55b69eb4930b0d4bcbf..9367f8d6a79dca6334bdfb60c40ea693f3ec949f 100644
--- a/media/cast/sender/rtp_timestamp_helper.cc
+++ b/media/cast/sender/rtp_timestamp_helper.cc
@@ -4,6 +4,8 @@
#include "media/cast/sender/rtp_timestamp_helper.h"
+#include "media/cast/cast_defines.h"
+
namespace media {
namespace cast {
@@ -15,17 +17,26 @@ RtpTimestampHelper::RtpTimestampHelper(int frequency)
RtpTimestampHelper::~RtpTimestampHelper() {
}
-bool RtpTimestampHelper::GetCurrentTimeAsRtpTimestamp(
- const base::TimeTicks& now, uint32* rtp_timestamp) const {
+bool RtpTimestampHelper::EstimateRtpTimestamp(
+ const base::TimeTicks& t, uint32* rtp_timestamp) const {
if (last_capture_time_.is_null())
return false;
- const base::TimeDelta elapsed_time = now - last_capture_time_;
- const int64 rtp_delta =
- elapsed_time * frequency_ / base::TimeDelta::FromSeconds(1);
+ const base::TimeDelta elapsed_time = t - last_capture_time_;
+ const int64 rtp_delta = TimeDeltaToRtpDelta(elapsed_time, frequency_);
*rtp_timestamp = last_rtp_timestamp_ + static_cast<uint32>(rtp_delta);
return true;
}
+bool RtpTimestampHelper::EstimateTimeTicks(
+ uint32 rtp_timestamp, base::TimeTicks* t) const {
+ if (last_capture_time_.is_null())
+ return false;
+ const int32 rtp_delta =
+ static_cast<int32>(rtp_timestamp - last_rtp_timestamp_);
+ *t = last_capture_time_ + RtpDeltaToTimeDelta(rtp_delta, frequency_);
+ return true;
+}
+
void RtpTimestampHelper::StoreLatestTime(
base::TimeTicks capture_time, uint32 rtp_timestamp) {
last_capture_time_ = capture_time;

Powered by Google App Engine
This is Rietveld 408576698