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

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

Issue 393403002: Update SourceBufferStream and its unit tests to always expect valid durations. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add negative duration guard to avoid crashing when FFmpeg returns negative durations. Created 6 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
« no previous file with comments | « media/base/stream_parser_buffer.cc ('k') | media/filters/source_buffer_stream.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 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 audio_decoder_config().samples_per_second(); 271 audio_decoder_config().samples_per_second();
272 buffer->set_discard_padding(std::make_pair( 272 buffer->set_discard_padding(std::make_pair(
273 FramesToTimeDelta(discard_front_samples, samples_per_second), 273 FramesToTimeDelta(discard_front_samples, samples_per_second),
274 FramesToTimeDelta(discard_end_samples, samples_per_second))); 274 FramesToTimeDelta(discard_end_samples, samples_per_second)));
275 } 275 }
276 276
277 if (decrypt_config) 277 if (decrypt_config)
278 buffer->set_decrypt_config(decrypt_config.Pass()); 278 buffer->set_decrypt_config(decrypt_config.Pass());
279 } 279 }
280 280
281 buffer->set_duration( 281 if (packet->duration >= 0) {
282 ConvertStreamTimestamp(stream_->time_base, packet->duration)); 282 buffer->set_duration(
283 ConvertStreamTimestamp(stream_->time_base, packet->duration));
284 } else {
285 DVLOG(1) << "FFmpeg returned a buffer with a negative duration! "
acolwell GONE FROM CHROMIUM 2014/07/16 18:17:46 Filed https://code.google.com/p/chromium/issues/de
wolenetz 2014/07/16 19:51:03 nit: That bug is irksome. Please add a TODO(wolene
acolwell GONE FROM CHROMIUM 2014/07/16 19:54:55 Done.
286 << packet->duration;
287 buffer->set_duration(kNoTimestamp());
288 }
283 289
284 // Note: If pts is AV_NOPTS_VALUE, stream_timestamp will be kNoTimestamp(). 290 // Note: If pts is AV_NOPTS_VALUE, stream_timestamp will be kNoTimestamp().
285 const base::TimeDelta stream_timestamp = 291 const base::TimeDelta stream_timestamp =
286 ConvertStreamTimestamp(stream_->time_base, packet->pts); 292 ConvertStreamTimestamp(stream_->time_base, packet->pts);
287 293
288 if (stream_timestamp != kNoTimestamp()) { 294 if (stream_timestamp != kNoTimestamp()) {
289 // If this is an OGG file with negative timestamps don't rebase any other 295 // If this is an OGG file with negative timestamps don't rebase any other
290 // stream types against the negative starting time. 296 // stream types against the negative starting time.
291 base::TimeDelta start_time = demuxer_->start_time(); 297 base::TimeDelta start_time = demuxer_->start_time();
292 if (fixup_negative_ogg_timestamps_ && type() != AUDIO && 298 if (fixup_negative_ogg_timestamps_ && type() != AUDIO &&
(...skipping 904 matching lines...) Expand 10 before | Expand all | Expand 10 after
1197 } 1203 }
1198 for (size_t i = 0; i < buffered.size(); ++i) 1204 for (size_t i = 0; i < buffered.size(); ++i)
1199 host_->AddBufferedTimeRange(buffered.start(i), buffered.end(i)); 1205 host_->AddBufferedTimeRange(buffered.start(i), buffered.end(i));
1200 } 1206 }
1201 1207
1202 void FFmpegDemuxer::OnDataSourceError() { 1208 void FFmpegDemuxer::OnDataSourceError() {
1203 host_->OnDemuxerError(PIPELINE_ERROR_READ); 1209 host_->OnDemuxerError(PIPELINE_ERROR_READ);
1204 } 1210 }
1205 1211
1206 } // namespace media 1212 } // namespace media
OLDNEW
« no previous file with comments | « media/base/stream_parser_buffer.cc ('k') | media/filters/source_buffer_stream.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698