| 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 <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/base64.h" | 10 #include "base/base64.h" |
| (...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 518 // go backwards in time. | 518 // go backwards in time. |
| 519 // | 519 // |
| 520 // If the new link starts with a negative timestamp or a timestamp less than | 520 // If the new link starts with a negative timestamp or a timestamp less than |
| 521 // the original (positive) |start_time|, we will get a negative timestamp | 521 // the original (positive) |start_time|, we will get a negative timestamp |
| 522 // here. It's also possible FFmpeg returns kNoTimestamp() here if it's not | 522 // here. It's also possible FFmpeg returns kNoTimestamp() here if it's not |
| 523 // able to work out a timestamp using the previous link and the next. | 523 // able to work out a timestamp using the previous link and the next. |
| 524 // | 524 // |
| 525 // Fixing chained ogg is non-trivial, so for now just reuse the last good | 525 // Fixing chained ogg is non-trivial, so for now just reuse the last good |
| 526 // timestamp. The decoder will rewrite the timestamps to be sample accurate | 526 // timestamp. The decoder will rewrite the timestamps to be sample accurate |
| 527 // later. See http://crbug.com/396864. | 527 // later. See http://crbug.com/396864. |
| 528 if (fixup_negative_timestamps_ && | 528 // |
| 529 (buffer->timestamp() == kNoTimestamp() || | 529 // TODO(dalecurtis): ffvp9 packet parser generates AV_NOPTS packets when a |
| 530 buffer->timestamp() < last_packet_timestamp_)) { | 530 // superframe is split, so adjust timestamps here... |
| 531 // TODO(chcunningham): It may be that some super frame parts are correct to |
| 532 // have PTS as they aren't intended for rendering. |
| 533 if ((fixup_negative_timestamps_ || buffer->timestamp() == kNoTimestamp()) && |
| 534 (buffer->timestamp() < last_packet_timestamp_)) { |
| 531 buffer->set_timestamp(last_packet_timestamp_ + | 535 buffer->set_timestamp(last_packet_timestamp_ + |
| 532 (last_packet_duration_ != kNoTimestamp() | 536 (last_packet_duration_ != kNoTimestamp() |
| 533 ? last_packet_duration_ | 537 ? last_packet_duration_ |
| 534 : base::TimeDelta::FromMicroseconds(1))); | 538 : base::TimeDelta::FromMicroseconds(1))); |
| 535 } | 539 } |
| 536 | 540 |
| 537 // The demuxer should always output positive timestamps. | 541 // The demuxer should always output positive timestamps. |
| 538 DCHECK(buffer->timestamp() >= base::TimeDelta()); | 542 DCHECK(buffer->timestamp() >= base::TimeDelta()); |
| 539 DCHECK(buffer->timestamp() != kNoTimestamp()); | 543 DCHECK(buffer->timestamp() != kNoTimestamp()); |
| 540 | 544 |
| (...skipping 1048 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1589 | 1593 |
| 1590 void FFmpegDemuxer::SetLiveness(DemuxerStream::Liveness liveness) { | 1594 void FFmpegDemuxer::SetLiveness(DemuxerStream::Liveness liveness) { |
| 1591 DCHECK(task_runner_->BelongsToCurrentThread()); | 1595 DCHECK(task_runner_->BelongsToCurrentThread()); |
| 1592 for (const auto& stream : streams_) { // |stream| is a ref to a pointer. | 1596 for (const auto& stream : streams_) { // |stream| is a ref to a pointer. |
| 1593 if (stream) | 1597 if (stream) |
| 1594 stream->SetLiveness(liveness); | 1598 stream->SetLiveness(liveness); |
| 1595 } | 1599 } |
| 1596 } | 1600 } |
| 1597 | 1601 |
| 1598 } // namespace media | 1602 } // namespace media |
| OLD | NEW |