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

Side by Side Diff: media/filters/chunk_demuxer.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 Created 8 years, 5 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 | « media/base/pipeline.cc ('k') | webkit/media/webmediaplayer_impl.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/filters/chunk_demuxer.h" 5 #include "media/filters/chunk_demuxer.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback_helpers.h" 8 #include "base/callback_helpers.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
(...skipping 743 matching lines...) Expand 10 before | Expand all | Expand 10 after
754 754
755 if (audio_ && !video_) { 755 if (audio_ && !video_) {
756 ranges = audio_->GetBufferedRanges(); 756 ranges = audio_->GetBufferedRanges();
757 } else if (!audio_ && video_) { 757 } else if (!audio_ && video_) {
758 ranges = video_->GetBufferedRanges(); 758 ranges = video_->GetBufferedRanges();
759 } else { 759 } else {
760 ranges = ComputeIntersection(); 760 ranges = ComputeIntersection();
761 } 761 }
762 } 762 }
763 763
764 if (ranges.size() > 0) {
765 base::TimeDelta last_timestamp_buffered = ranges.end(ranges.size() - 1);
766 if (last_timestamp_buffered > duration_) {
767 duration_ = last_timestamp_buffered;
768 host_->SetDuration(last_timestamp_buffered);
769 }
770 }
771
764 for (size_t i = 0; i < ranges.size(); ++i) 772 for (size_t i = 0; i < ranges.size(); ++i)
765 host_->AddBufferedTimeRange(ranges.start(i), ranges.end(i)); 773 host_->AddBufferedTimeRange(ranges.start(i), ranges.end(i));
766 774
767 if (!cb.is_null()) 775 if (!cb.is_null())
768 cb.Run(PIPELINE_OK); 776 cb.Run(PIPELINE_OK);
769 777
770 return true; 778 return true;
771 } 779 }
772 780
773 void ChunkDemuxer::Abort(const std::string& id) { 781 void ChunkDemuxer::Abort(const std::string& id) {
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
933 } 941 }
934 942
935 if (duration > duration_) 943 if (duration > duration_)
936 duration_ = duration; 944 duration_ = duration;
937 945
938 // Wait until all streams have initialized. 946 // Wait until all streams have initialized.
939 if ((!source_id_audio_.empty() && !audio_) || 947 if ((!source_id_audio_.empty() && !audio_) ||
940 (!source_id_video_.empty() && !video_)) 948 (!source_id_video_.empty() && !video_))
941 return; 949 return;
942 950
943 host_->SetDuration(duration_);
acolwell GONE FROM CHROMIUM 2012/07/20 21:18:36 This isn't needed anymore because of the code in O
vrk (LEFT CHROMIUM) 2012/07/26 22:27:26 Yes. My thought was, I was moving this line to hap
944
945 ChangeState_Locked(WAITING_FOR_START_TIME); 951 ChangeState_Locked(WAITING_FOR_START_TIME);
946 } 952 }
947 953
948 bool ChunkDemuxer::OnNewConfigs(bool has_audio, bool has_video, 954 bool ChunkDemuxer::OnNewConfigs(bool has_audio, bool has_video,
949 const AudioDecoderConfig& audio_config, 955 const AudioDecoderConfig& audio_config,
950 const VideoDecoderConfig& video_config) { 956 const VideoDecoderConfig& video_config) {
951 DVLOG(1) << "OnNewConfigs(" << has_audio << ", " << has_video 957 DVLOG(1) << "OnNewConfigs(" << has_audio << ", " << has_video
952 << ", " << audio_config.IsValidConfig() 958 << ", " << audio_config.IsValidConfig()
953 << ", " << video_config.IsValidConfig() << ")"; 959 << ", " << video_config.IsValidConfig() << ")";
954 CHECK(audio_config.IsValidConfig() || video_config.IsValidConfig()); 960 CHECK(audio_config.IsValidConfig() || video_config.IsValidConfig());
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
1052 1058
1053 if (audio_) { 1059 if (audio_) {
1054 audio_->SetStartTime(start_time_); 1060 audio_->SetStartTime(start_time_);
1055 audio_->Seek(start_time_); 1061 audio_->Seek(start_time_);
1056 } 1062 }
1057 if (video_) { 1063 if (video_) {
1058 video_->SetStartTime(start_time_); 1064 video_->SetStartTime(start_time_);
1059 video_->Seek(start_time_); 1065 video_->Seek(start_time_);
1060 } 1066 }
1061 1067
1068 duration_ = std::max(duration_, start_time_);
acolwell GONE FROM CHROMIUM 2012/07/20 21:18:36 A couple questions here: - Shouldn't the SetDurati
vrk (LEFT CHROMIUM) 2012/07/26 22:27:26 As I said in my other comment, my thinking was I w
1069 host_->SetDuration(duration_);
1070
1062 // The demuxer is now initialized after the |start_timestamp_| was set. 1071 // The demuxer is now initialized after the |start_timestamp_| was set.
1063 ChangeState_Locked(INITIALIZED); 1072 ChangeState_Locked(INITIALIZED);
1064 base::ResetAndReturn(&init_cb_).Run(PIPELINE_OK); 1073 base::ResetAndReturn(&init_cb_).Run(PIPELINE_OK);
1065 } 1074 }
1066 1075
1067 void ChunkDemuxer::OnEndOfMediaSegment(const std::string& source_id) { 1076 void ChunkDemuxer::OnEndOfMediaSegment(const std::string& source_id) {
1068 DVLOG(2) << "OnEndOfMediaSegment(" << source_id << ")"; 1077 DVLOG(2) << "OnEndOfMediaSegment(" << source_id << ")";
1069 CHECK_GT(stream_info_map_.count(source_id_video_), 0u); 1078 CHECK_GT(stream_info_map_.count(source_id_video_), 0u);
1070 stream_info_map_[source_id_video_].can_update_offset = true; 1079 stream_info_map_[source_id_video_].can_update_offset = true;
1071 } 1080 }
1072 1081
1073 } // namespace media 1082 } // namespace media
OLDNEW
« no previous file with comments | « media/base/pipeline.cc ('k') | webkit/media/webmediaplayer_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698