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

Side by Side 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, 3 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
OLDNEW
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 #include "media/cast/sender/rtp_timestamp_helper.h" 5 #include "media/cast/sender/rtp_timestamp_helper.h"
6 6
7 #include "media/cast/cast_defines.h"
8
7 namespace media { 9 namespace media {
8 namespace cast { 10 namespace cast {
9 11
10 RtpTimestampHelper::RtpTimestampHelper(int frequency) 12 RtpTimestampHelper::RtpTimestampHelper(int frequency)
11 : frequency_(frequency), 13 : frequency_(frequency),
12 last_rtp_timestamp_(0) { 14 last_rtp_timestamp_(0) {
13 } 15 }
14 16
15 RtpTimestampHelper::~RtpTimestampHelper() { 17 RtpTimestampHelper::~RtpTimestampHelper() {
16 } 18 }
17 19
18 bool RtpTimestampHelper::GetCurrentTimeAsRtpTimestamp( 20 bool RtpTimestampHelper::EstimateRtpTimestamp(
19 const base::TimeTicks& now, uint32* rtp_timestamp) const { 21 const base::TimeTicks& t, uint32* rtp_timestamp) const {
20 if (last_capture_time_.is_null()) 22 if (last_capture_time_.is_null())
21 return false; 23 return false;
22 const base::TimeDelta elapsed_time = now - last_capture_time_; 24 const base::TimeDelta elapsed_time = t - last_capture_time_;
23 const int64 rtp_delta = 25 const int64 rtp_delta = TimeDeltaToRtpDelta(elapsed_time, frequency_);
24 elapsed_time * frequency_ / base::TimeDelta::FromSeconds(1);
25 *rtp_timestamp = last_rtp_timestamp_ + static_cast<uint32>(rtp_delta); 26 *rtp_timestamp = last_rtp_timestamp_ + static_cast<uint32>(rtp_delta);
26 return true; 27 return true;
27 } 28 }
28 29
30 bool RtpTimestampHelper::EstimateTimeTicks(
31 uint32 rtp_timestamp, base::TimeTicks* t) const {
32 if (last_capture_time_.is_null())
33 return false;
34 const int32 rtp_delta =
35 static_cast<int32>(rtp_timestamp - last_rtp_timestamp_);
36 *t = last_capture_time_ + RtpDeltaToTimeDelta(rtp_delta, frequency_);
37 return true;
38 }
39
29 void RtpTimestampHelper::StoreLatestTime( 40 void RtpTimestampHelper::StoreLatestTime(
30 base::TimeTicks capture_time, uint32 rtp_timestamp) { 41 base::TimeTicks capture_time, uint32 rtp_timestamp) {
31 last_capture_time_ = capture_time; 42 last_capture_time_ = capture_time;
32 last_rtp_timestamp_ = rtp_timestamp; 43 last_rtp_timestamp_ = rtp_timestamp;
33 } 44 }
34 45
35 } // namespace cast 46 } // namespace cast
36 } // namespace media 47 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698