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

Side by Side 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, 11 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/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 774 matching lines...) Expand 10 before | Expand all | Expand 10 after
785 void FFmpegDemuxer::OnReadFrameDone(ScopedAVPacket packet, int result) { 785 void FFmpegDemuxer::OnReadFrameDone(ScopedAVPacket packet, int result) {
786 DCHECK(task_runner_->BelongsToCurrentThread()); 786 DCHECK(task_runner_->BelongsToCurrentThread());
787 DCHECK(pending_read_); 787 DCHECK(pending_read_);
788 pending_read_ = false; 788 pending_read_ = false;
789 789
790 if (!blocking_thread_.IsRunning() || pending_seek_) { 790 if (!blocking_thread_.IsRunning() || pending_seek_) {
791 return; 791 return;
792 } 792 }
793 793
794 if (result < 0) { 794 if (result < 0) {
795 // Update the duration based on the audio stream if 795 // Update the duration based on the highest elapsed time across all streams
796 // it was previously unknown http://crbug.com/86830 796 // if it was previously unknown.
797 if (!duration_known_) { 797 if (!duration_known_) {
798 // Search streams for AUDIO one. 798 base::TimeDelta max_duration;
799
799 for (StreamVector::iterator iter = streams_.begin(); 800 for (StreamVector::iterator iter = streams_.begin();
800 iter != streams_.end(); 801 iter != streams_.end();
801 ++iter) { 802 ++iter) {
802 if (*iter && (*iter)->type() == DemuxerStream::AUDIO) { 803 base::TimeDelta duration = (*iter)->GetElapsedTime();
803 base::TimeDelta duration = (*iter)->GetElapsedTime(); 804 if (duration != kNoTimestamp() && duration > max_duration)
xhwang 2014/01/04 01:12:38 nit: the check duration != kNoTimestamp() seems re
804 if (duration != kNoTimestamp() && duration > base::TimeDelta()) { 805 max_duration = duration;
805 host_->SetDuration(duration); 806 }
806 duration_known_ = true; 807
807 } 808 if (max_duration > base::TimeDelta()) {
808 break; 809 host_->SetDuration(max_duration);
809 } 810 duration_known_ = true;
810 } 811 }
811 } 812 }
812 // If we have reached the end of stream, tell the downstream filters about 813 // If we have reached the end of stream, tell the downstream filters about
813 // the event. 814 // the event.
814 StreamHasEnded(); 815 StreamHasEnded();
815 return; 816 return;
816 } 817 }
817 818
818 // Queue the packet with the appropriate stream. 819 // Queue the packet with the appropriate stream.
819 DCHECK_GE(packet->stream_index, 0); 820 DCHECK_GE(packet->stream_index, 0);
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
934 } 935 }
935 for (size_t i = 0; i < buffered.size(); ++i) 936 for (size_t i = 0; i < buffered.size(); ++i)
936 host_->AddBufferedTimeRange(buffered.start(i), buffered.end(i)); 937 host_->AddBufferedTimeRange(buffered.start(i), buffered.end(i));
937 } 938 }
938 939
939 void FFmpegDemuxer::OnDataSourceError() { 940 void FFmpegDemuxer::OnDataSourceError() {
940 host_->OnDemuxerError(PIPELINE_ERROR_READ); 941 host_->OnDemuxerError(PIPELINE_ERROR_READ);
941 } 942 }
942 943
943 } // namespace media 944 } // namespace media
OLDNEW
« 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