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

Unified Diff: media/filters/ffmpeg_demuxer.cc

Issue 105503011: Update FFmpegDemuxer unknown duration logic to work for video-only streams. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 12 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
« no previous file with comments | « no previous file | media/filters/ffmpeg_demuxer_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/filters/ffmpeg_demuxer.cc
diff --git a/media/filters/ffmpeg_demuxer.cc b/media/filters/ffmpeg_demuxer.cc
index 5ab7c21f0dbdd2fe1a638e7b6948249367d989d9..ae0d60411be175619d99ec901a71be39e071ab9b 100644
--- a/media/filters/ffmpeg_demuxer.cc
+++ b/media/filters/ffmpeg_demuxer.cc
@@ -792,21 +792,22 @@ void FFmpegDemuxer::OnReadFrameDone(ScopedAVPacket packet, int result) {
}
if (result < 0) {
- // Update the duration based on the audio stream if
- // it was previously unknown http://crbug.com/86830
+ // Update the duration based on the highest elapsed time across all streams
+ // if it was previously unknown.
if (!duration_known_) {
- // Search streams for AUDIO one.
+ base::TimeDelta max_duration;
+
for (StreamVector::iterator iter = streams_.begin();
iter != streams_.end();
++iter) {
- if (*iter && (*iter)->type() == DemuxerStream::AUDIO) {
- base::TimeDelta duration = (*iter)->GetElapsedTime();
- if (duration != kNoTimestamp() && duration > base::TimeDelta()) {
- host_->SetDuration(duration);
- duration_known_ = true;
- }
- break;
- }
+ base::TimeDelta duration = (*iter)->GetElapsedTime();
+ if (duration != kNoTimestamp() && duration > max_duration)
xhwang 2014/01/04 01:12:38 nit: the check duration != kNoTimestamp() seems re
+ max_duration = duration;
+ }
+
+ if (max_duration > base::TimeDelta()) {
+ host_->SetDuration(max_duration);
+ duration_known_ = true;
}
}
// If we have reached the end of stream, tell the downstream filters about
« no previous file with comments | « no previous file | media/filters/ffmpeg_demuxer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698