OLD | NEW |
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 Loading... |
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 // TODO(wolenetz): Remove when FFmpeg stops returning negative durations. |
| 286 // https://crbug.com/394418 |
| 287 DVLOG(1) << "FFmpeg returned a buffer with a negative duration! " |
| 288 << packet->duration; |
| 289 buffer->set_duration(kNoTimestamp()); |
| 290 } |
283 | 291 |
284 // Note: If pts is AV_NOPTS_VALUE, stream_timestamp will be kNoTimestamp(). | 292 // Note: If pts is AV_NOPTS_VALUE, stream_timestamp will be kNoTimestamp(). |
285 const base::TimeDelta stream_timestamp = | 293 const base::TimeDelta stream_timestamp = |
286 ConvertStreamTimestamp(stream_->time_base, packet->pts); | 294 ConvertStreamTimestamp(stream_->time_base, packet->pts); |
287 | 295 |
288 if (stream_timestamp != kNoTimestamp()) { | 296 if (stream_timestamp != kNoTimestamp()) { |
289 // If this is an OGG file with negative timestamps don't rebase any other | 297 // If this is an OGG file with negative timestamps don't rebase any other |
290 // stream types against the negative starting time. | 298 // stream types against the negative starting time. |
291 base::TimeDelta start_time = demuxer_->start_time(); | 299 base::TimeDelta start_time = demuxer_->start_time(); |
292 if (fixup_negative_ogg_timestamps_ && type() != AUDIO && | 300 if (fixup_negative_ogg_timestamps_ && type() != AUDIO && |
(...skipping 904 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1197 } | 1205 } |
1198 for (size_t i = 0; i < buffered.size(); ++i) | 1206 for (size_t i = 0; i < buffered.size(); ++i) |
1199 host_->AddBufferedTimeRange(buffered.start(i), buffered.end(i)); | 1207 host_->AddBufferedTimeRange(buffered.start(i), buffered.end(i)); |
1200 } | 1208 } |
1201 | 1209 |
1202 void FFmpegDemuxer::OnDataSourceError() { | 1210 void FFmpegDemuxer::OnDataSourceError() { |
1203 host_->OnDemuxerError(PIPELINE_ERROR_READ); | 1211 host_->OnDemuxerError(PIPELINE_ERROR_READ); |
1204 } | 1212 } |
1205 | 1213 |
1206 } // namespace media | 1214 } // namespace media |
OLD | NEW |