Chromium Code Reviews| Index: media/filters/ffmpeg_demuxer.cc |
| diff --git a/media/filters/ffmpeg_demuxer.cc b/media/filters/ffmpeg_demuxer.cc |
| index 0c532d0edb1a84a026487497e29bdc7a5f10bb93..23de0e26c92d2ad9d604e251c3cbfff028248439 100644 |
| --- a/media/filters/ffmpeg_demuxer.cc |
| +++ b/media/filters/ffmpeg_demuxer.cc |
| @@ -276,7 +276,8 @@ FFmpegDemuxerStream::FFmpegDemuxerStream( |
| is_enabled_(true), |
| waiting_for_keyframe_(false), |
| aborted_(false), |
| - fixup_negative_timestamps_(false) { |
| + fixup_negative_timestamps_(false), |
| + warned_about_missing_timestamps_(false) { |
| DCHECK(demuxer_); |
| bool is_encrypted = false; |
| @@ -527,7 +528,12 @@ void FFmpegDemuxerStream::EnqueuePacket(ScopedAVPacket packet) { |
| } |
| } else { |
| // If this happens on the first packet, decoders will throw an error. |
| - buffer->set_timestamp(kNoTimestamp); |
| + // Just try zero. crbug.com/665305 . |
| + if (!warned_about_missing_timestamps_) { |
| + LOG(WARNING) << "No timestamp provided for initial buffer"; |
| + warned_about_missing_timestamps_ = true; |
| + } |
| + buffer->set_timestamp(base::TimeDelta()); |
| } |
| if (last_packet_timestamp_ != kNoTimestamp) { |
| @@ -544,18 +550,27 @@ void FFmpegDemuxerStream::EnqueuePacket(ScopedAVPacket packet) { |
| // Fixing chained ogg is non-trivial, so for now just reuse the last good |
| // timestamp. The decoder will rewrite the timestamps to be sample accurate |
| // later. See http://crbug.com/396864. |
| - if (fixup_negative_timestamps_ && |
| - (buffer->timestamp() == kNoTimestamp || |
| + // |
| + // Whether we're fixing up timestamps or not, if we have no timestamp, then |
| + // use the last timestamp instead. This can happen if bad media causes |
| + // ffmpeg to fail to provide a timestamp. crbug.com/665305 |
| + if (buffer->timestamp() == kNoTimestamp || |
| + (fixup_negative_timestamps_ && |
| buffer->timestamp() < last_packet_timestamp_)) { |
| + if (!fixup_negative_timestamps_ && !warned_about_missing_timestamps_) { |
|
liberato (no reviews please)
2016/12/12 22:24:48
"!fixup..." to prevent a warning when we wouldn't
|
| + LOG(WARNING) << "No timestamp provided for buffer"; |
| + warned_about_missing_timestamps_ = true; |
| + } |
| buffer->set_timestamp(last_packet_timestamp_ + |
| (last_packet_duration_ != kNoTimestamp |
| ? last_packet_duration_ |
| : base::TimeDelta::FromMicroseconds(1))); |
| } |
| - // The demuxer should always output positive timestamps. |
| - DCHECK(buffer->timestamp() >= base::TimeDelta()); |
| + // The demuxer should always output non-negative timestamps. If it output |
| + // no timestamp, then we should have already fixed that up. |
| DCHECK(buffer->timestamp() != kNoTimestamp); |
| + DCHECK(buffer->timestamp() >= base::TimeDelta()); |
| if (last_packet_timestamp_ < buffer->timestamp()) { |
| buffered_ranges_.Add(last_packet_timestamp_, buffer->timestamp()); |