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

Side by Side Diff: media/base/clock.cc

Issue 10800041: Update media duration if data is appended after the previous duration (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase ToT Created 8 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | media/filters/chunk_demuxer.h » ('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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/base/clock.h" 5 #include "media/base/clock.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "media/base/buffers.h" 10 #include "media/base/buffers.h"
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 73
74 UpdateReferencePoints(); 74 UpdateReferencePoints();
75 max_time_ = ClampToValidTimeRange(max_time); 75 max_time_ = ClampToValidTimeRange(max_time);
76 76
77 underflow_ = media_time_ > max_time_; 77 underflow_ = media_time_ > max_time_;
78 if (underflow_) 78 if (underflow_)
79 media_time_ = max_time_; 79 media_time_ = max_time_;
80 } 80 }
81 81
82 void Clock::SetDuration(base::TimeDelta duration) { 82 void Clock::SetDuration(base::TimeDelta duration) {
83 DCHECK(duration_ == kNoTimestamp() || duration_ == kInfiniteDuration());
84 DCHECK(duration > base::TimeDelta()); 83 DCHECK(duration > base::TimeDelta());
85 duration_ = duration; 84 duration_ = duration;
85
86 media_time_ = ClampToValidTimeRange(media_time_);
87 if (max_time_ != kNoTimestamp())
88 max_time_ = ClampToValidTimeRange(max_time_);
86 } 89 }
87 90
88 base::TimeDelta Clock::ElapsedViaProvidedTime(const base::Time& time) const { 91 base::TimeDelta Clock::ElapsedViaProvidedTime(const base::Time& time) const {
89 // TODO(scherkus): floating point badness scaling time by playback rate. 92 // TODO(scherkus): floating point badness scaling time by playback rate.
90 int64 now_us = (time - reference_).InMicroseconds(); 93 int64 now_us = (time - reference_).InMicroseconds();
91 now_us = static_cast<int64>(now_us * playback_rate_); 94 now_us = static_cast<int64>(now_us * playback_rate_);
92 return media_time_ + base::TimeDelta::FromMicroseconds(now_us); 95 return media_time_ + base::TimeDelta::FromMicroseconds(now_us);
93 } 96 }
94 97
95 base::Time Clock::GetTimeFromProvider() const { 98 base::Time Clock::GetTimeFromProvider() const {
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 playing_ = false; 136 playing_ = false;
134 playback_rate_ = 1.0f; 137 playback_rate_ = 1.0f;
135 max_time_ = kNoTimestamp(); 138 max_time_ = kNoTimestamp();
136 duration_ = kNoTimestamp(); 139 duration_ = kNoTimestamp();
137 media_time_ = base::TimeDelta(); 140 media_time_ = base::TimeDelta();
138 reference_ = base::Time(); 141 reference_ = base::Time();
139 underflow_ = false; 142 underflow_ = false;
140 } 143 }
141 144
142 } // namespace media 145 } // namespace media
OLDNEW
« no previous file with comments | « no previous file | media/filters/chunk_demuxer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698