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 <memory> | 8 #include <memory> |
9 #include <set> | 9 #include <set> |
10 #include <utility> | 10 #include <utility> |
(...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
500 // Don't rebase timestamps for positive start times, the HTML Media Spec | 500 // Don't rebase timestamps for positive start times, the HTML Media Spec |
501 // details this in section "4.8.10.6 Offsets into the media resource." We | 501 // details this in section "4.8.10.6 Offsets into the media resource." We |
502 // will still need to rebase timestamps before seeking with FFmpeg though. | 502 // will still need to rebase timestamps before seeking with FFmpeg though. |
503 if (start_time > base::TimeDelta()) | 503 if (start_time > base::TimeDelta()) |
504 start_time = base::TimeDelta(); | 504 start_time = base::TimeDelta(); |
505 | 505 |
506 buffer->set_timestamp(stream_timestamp - start_time); | 506 buffer->set_timestamp(stream_timestamp - start_time); |
507 | 507 |
508 // Only allow negative timestamps past if we know they'll be fixed up by the | 508 // Only allow negative timestamps past if we know they'll be fixed up by the |
509 // code paths below; otherwise they should be treated as a parse error. | 509 // code paths below; otherwise they should be treated as a parse error. |
510 if (!fixup_negative_timestamps_ && buffer->timestamp() < base::TimeDelta()) { | 510 if ((!fixup_negative_timestamps_ || last_packet_timestamp_ == kNoTimestamp) && |
| 511 buffer->timestamp() < base::TimeDelta()) { |
511 MEDIA_LOG(DEBUG, media_log_) | 512 MEDIA_LOG(DEBUG, media_log_) |
512 << "FFmpegDemuxer: unfixable negative timestamp"; | 513 << "FFmpegDemuxer: unfixable negative timestamp"; |
513 demuxer_->NotifyDemuxerError(DEMUXER_ERROR_COULD_NOT_PARSE); | 514 demuxer_->NotifyDemuxerError(DEMUXER_ERROR_COULD_NOT_PARSE); |
514 return; | 515 return; |
515 } | 516 } |
516 | 517 |
517 // If enabled, and no codec delay is present, mark audio packets with negative | 518 // If enabled, and no codec delay is present, mark audio packets with negative |
518 // timestamps for post-decode discard. If codec delay is present, discard is | 519 // timestamps for post-decode discard. If codec delay is present, discard is |
519 // handled by the decoder using that value. | 520 // handled by the decoder using that value. |
520 if (fixup_negative_timestamps_ && is_audio && | 521 if (fixup_negative_timestamps_ && is_audio && |
(...skipping 1346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1867 | 1868 |
1868 void FFmpegDemuxer::SetLiveness(DemuxerStream::Liveness liveness) { | 1869 void FFmpegDemuxer::SetLiveness(DemuxerStream::Liveness liveness) { |
1869 DCHECK(task_runner_->BelongsToCurrentThread()); | 1870 DCHECK(task_runner_->BelongsToCurrentThread()); |
1870 for (const auto& stream : streams_) { | 1871 for (const auto& stream : streams_) { |
1871 if (stream) | 1872 if (stream) |
1872 stream->SetLiveness(liveness); | 1873 stream->SetLiveness(liveness); |
1873 } | 1874 } |
1874 } | 1875 } |
1875 | 1876 |
1876 } // namespace media | 1877 } // namespace media |
OLD | NEW |