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

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

Issue 2563183002: Fix up missing timestamps in FFmpegDemuxer. (Closed)
Patch Set: added demuxer status to media log Created 4 years 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
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 <memory> 8 #include <memory>
9 #include <set> 9 #include <set>
10 #include <utility> 10 #include <utility>
(...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after
546 // later. See http://crbug.com/396864. 546 // later. See http://crbug.com/396864.
547 if (fixup_negative_timestamps_ && 547 if (fixup_negative_timestamps_ &&
548 (buffer->timestamp() == kNoTimestamp || 548 (buffer->timestamp() == kNoTimestamp ||
549 buffer->timestamp() < last_packet_timestamp_)) { 549 buffer->timestamp() < last_packet_timestamp_)) {
550 buffer->set_timestamp(last_packet_timestamp_ + 550 buffer->set_timestamp(last_packet_timestamp_ +
551 (last_packet_duration_ != kNoTimestamp 551 (last_packet_duration_ != kNoTimestamp
552 ? last_packet_duration_ 552 ? last_packet_duration_
553 : base::TimeDelta::FromMicroseconds(1))); 553 : base::TimeDelta::FromMicroseconds(1)));
554 } 554 }
555 555
556 if (buffer->timestamp() == kNoTimestamp) {
557 // If we didn't get a valid timestamp and didn't fix it up, then fail.
558 demuxer_->NotifyDemuxerError(DEMUXER_ERROR_COULD_NOT_PARSE);
559 return;
560 }
561
556 // The demuxer should always output positive timestamps. 562 // The demuxer should always output positive timestamps.
557 DCHECK(buffer->timestamp() >= base::TimeDelta()); 563 DCHECK(buffer->timestamp() >= base::TimeDelta());
558 DCHECK(buffer->timestamp() != kNoTimestamp);
559 564
560 if (last_packet_timestamp_ < buffer->timestamp()) { 565 if (last_packet_timestamp_ < buffer->timestamp()) {
561 buffered_ranges_.Add(last_packet_timestamp_, buffer->timestamp()); 566 buffered_ranges_.Add(last_packet_timestamp_, buffer->timestamp());
562 demuxer_->NotifyBufferingChanged(); 567 demuxer_->NotifyBufferingChanged();
563 } 568 }
564 } 569 }
565 570
566 if (packet.get()->flags & AV_PKT_FLAG_KEY) 571 if (packet.get()->flags & AV_PKT_FLAG_KEY)
567 buffer->set_is_key_frame(true); 572 buffer->set_is_key_frame(true);
568 573
(...skipping 1226 matching lines...) Expand 10 before | Expand all | Expand 10 after
1795 if (stream) 1800 if (stream)
1796 stream->SetEndOfStream(); 1801 stream->SetEndOfStream();
1797 } 1802 }
1798 } 1803 }
1799 1804
1800 void FFmpegDemuxer::OnDataSourceError() { 1805 void FFmpegDemuxer::OnDataSourceError() {
1801 MEDIA_LOG(ERROR, media_log_) << GetDisplayName() << ": data source error"; 1806 MEDIA_LOG(ERROR, media_log_) << GetDisplayName() << ": data source error";
1802 host_->OnDemuxerError(PIPELINE_ERROR_READ); 1807 host_->OnDemuxerError(PIPELINE_ERROR_READ);
1803 } 1808 }
1804 1809
1810 void FFmpegDemuxer::NotifyDemuxerError(PipelineStatus status) {
1811 MEDIA_LOG(ERROR, media_log_) << GetDisplayName()
1812 << ": demuxer error: " << status;
1813 host_->OnDemuxerError(status);
1814 }
1815
1805 void FFmpegDemuxer::SetLiveness(DemuxerStream::Liveness liveness) { 1816 void FFmpegDemuxer::SetLiveness(DemuxerStream::Liveness liveness) {
1806 DCHECK(task_runner_->BelongsToCurrentThread()); 1817 DCHECK(task_runner_->BelongsToCurrentThread());
1807 for (const auto& stream : streams_) { 1818 for (const auto& stream : streams_) {
1808 if (stream) 1819 if (stream)
1809 stream->SetLiveness(liveness); 1820 stream->SetLiveness(liveness);
1810 } 1821 }
1811 } 1822 }
1812 1823
1813 } // namespace media 1824 } // namespace media
OLDNEW
« media/filters/ffmpeg_demuxer.h ('K') | « media/filters/ffmpeg_demuxer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698