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

Side by Side Diff: media/filters/ffmpeg_demuxer.cc

Issue 575643002: Initialize media timeline correctly for positive start times. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Comments. 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
« no previous file with comments | « media/filters/ffmpeg_demuxer.h ('k') | media/filters/ffmpeg_demuxer_unittest.cc » ('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/filters/ffmpeg_demuxer.h" 5 #include "media/filters/ffmpeg_demuxer.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 9
10 #include "base/base64.h" 10 #include "base/base64.h"
(...skipping 668 matching lines...) Expand 10 before | Expand all | Expand 10 after
679 DemuxerStream::Type type) const { 679 DemuxerStream::Type type) const {
680 StreamVector::const_iterator iter; 680 StreamVector::const_iterator iter;
681 for (iter = streams_.begin(); iter != streams_.end(); ++iter) { 681 for (iter = streams_.begin(); iter != streams_.end(); ++iter) {
682 if (*iter && (*iter)->type() == type) { 682 if (*iter && (*iter)->type() == type) {
683 return *iter; 683 return *iter;
684 } 684 }
685 } 685 }
686 return NULL; 686 return NULL;
687 } 687 }
688 688
689 base::TimeDelta FFmpegDemuxer::GetStartTime() const {
690 return std::max(start_time_, base::TimeDelta());
691 }
692
689 Demuxer::Liveness FFmpegDemuxer::GetLiveness() const { 693 Demuxer::Liveness FFmpegDemuxer::GetLiveness() const {
690 DCHECK(task_runner_->BelongsToCurrentThread()); 694 DCHECK(task_runner_->BelongsToCurrentThread());
691 return liveness_; 695 return liveness_;
692 } 696 }
693 697
694 void FFmpegDemuxer::AddTextStreams() { 698 void FFmpegDemuxer::AddTextStreams() {
695 DCHECK(task_runner_->BelongsToCurrentThread()); 699 DCHECK(task_runner_->BelongsToCurrentThread());
696 700
697 for (StreamVector::size_type idx = 0; idx < streams_.size(); ++idx) { 701 for (StreamVector::size_type idx = 0; idx < streams_.size(); ++idx) {
698 FFmpegDemuxerStream* stream = streams_[idx]; 702 FFmpegDemuxerStream* stream = streams_[idx];
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
952 // generation so we always get timestamps, see http://crbug.com/169570 956 // generation so we always get timestamps, see http://crbug.com/169570
953 if (strcmp(format_context->iformat->name, "avi") == 0) 957 if (strcmp(format_context->iformat->name, "avi") == 0)
954 format_context->flags |= AVFMT_FLAG_GENPTS; 958 format_context->flags |= AVFMT_FLAG_GENPTS;
955 959
956 // For testing purposes, don't overwrite the timeline offset if set already. 960 // For testing purposes, don't overwrite the timeline offset if set already.
957 if (timeline_offset_.is_null()) 961 if (timeline_offset_.is_null())
958 timeline_offset_ = ExtractTimelineOffset(format_context); 962 timeline_offset_ = ExtractTimelineOffset(format_context);
959 963
960 // Since we're shifting the externally visible start time to zero, we need to 964 // Since we're shifting the externally visible start time to zero, we need to
961 // adjust the timeline offset to compensate. 965 // adjust the timeline offset to compensate.
962 if (!timeline_offset_.is_null()) 966 if (!timeline_offset_.is_null() && start_time_ < base::TimeDelta())
963 timeline_offset_ += start_time_; 967 timeline_offset_ += start_time_;
964 968
965 if (max_duration == kInfiniteDuration() && !timeline_offset_.is_null()) { 969 if (max_duration == kInfiniteDuration() && !timeline_offset_.is_null()) {
966 liveness_ = LIVENESS_LIVE; 970 liveness_ = LIVENESS_LIVE;
967 } else if (max_duration != kInfiniteDuration()) { 971 } else if (max_duration != kInfiniteDuration()) {
968 liveness_ = LIVENESS_RECORDED; 972 liveness_ = LIVENESS_RECORDED;
969 } else { 973 } else {
970 liveness_ = LIVENESS_UNKNOWN; 974 liveness_ = LIVENESS_UNKNOWN;
971 } 975 }
972 976
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
1244 } 1248 }
1245 for (size_t i = 0; i < buffered.size(); ++i) 1249 for (size_t i = 0; i < buffered.size(); ++i)
1246 host_->AddBufferedTimeRange(buffered.start(i), buffered.end(i)); 1250 host_->AddBufferedTimeRange(buffered.start(i), buffered.end(i));
1247 } 1251 }
1248 1252
1249 void FFmpegDemuxer::OnDataSourceError() { 1253 void FFmpegDemuxer::OnDataSourceError() {
1250 host_->OnDemuxerError(PIPELINE_ERROR_READ); 1254 host_->OnDemuxerError(PIPELINE_ERROR_READ);
1251 } 1255 }
1252 1256
1253 } // namespace media 1257 } // namespace media
OLDNEW
« no previous file with comments | « media/filters/ffmpeg_demuxer.h ('k') | media/filters/ffmpeg_demuxer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698