Chromium Code Reviews| 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 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 244 } | 244 } |
| 245 | 245 |
| 246 MEDIA_LOG(INFO, media_log) << "FFmpegDemuxer: created video stream, config " | 246 MEDIA_LOG(INFO, media_log) << "FFmpegDemuxer: created video stream, config " |
| 247 << video_config->AsHumanReadableString(); | 247 << video_config->AsHumanReadableString(); |
| 248 } | 248 } |
| 249 | 249 |
| 250 return base::WrapUnique(new FFmpegDemuxerStream( | 250 return base::WrapUnique(new FFmpegDemuxerStream( |
| 251 demuxer, stream, std::move(audio_config), std::move(video_config))); | 251 demuxer, stream, std::move(audio_config), std::move(video_config))); |
| 252 } | 252 } |
| 253 | 253 |
| 254 static void UnmarkEndOfStream(AVFormatContext* format_context) { | 254 static void UnmarkEndOfStream(AVFormatContext* format_context) { |
|
DaleCurtis
2017/03/24 19:13:13
Rename function?
hubbe
2017/03/24 19:39:55
UnmarkEndofStreamAndClearError?
| |
| 255 format_context->pb->eof_reached = 0; | 255 format_context->pb->eof_reached = 0; |
| 256 format_context->pb->error = 0; | |
| 256 } | 257 } |
| 257 | 258 |
| 258 // | 259 // |
| 259 // FFmpegDemuxerStream | 260 // FFmpegDemuxerStream |
| 260 // | 261 // |
| 261 FFmpegDemuxerStream::FFmpegDemuxerStream( | 262 FFmpegDemuxerStream::FFmpegDemuxerStream( |
| 262 FFmpegDemuxer* demuxer, | 263 FFmpegDemuxer* demuxer, |
| 263 AVStream* stream, | 264 AVStream* stream, |
| 264 std::unique_ptr<AudioDecoderConfig> audio_config, | 265 std::unique_ptr<AudioDecoderConfig> audio_config, |
| 265 std::unique_ptr<VideoDecoderConfig> video_config) | 266 std::unique_ptr<VideoDecoderConfig> video_config) |
| (...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 773 } | 774 } |
| 774 } | 775 } |
| 775 | 776 |
| 776 // Have capacity? Ask for more! | 777 // Have capacity? Ask for more! |
| 777 if (HasAvailableCapacity() && !end_of_stream_) { | 778 if (HasAvailableCapacity() && !end_of_stream_) { |
| 778 demuxer_->NotifyCapacityAvailable(); | 779 demuxer_->NotifyCapacityAvailable(); |
| 779 } | 780 } |
| 780 } | 781 } |
| 781 | 782 |
| 782 bool FFmpegDemuxerStream::HasAvailableCapacity() { | 783 bool FFmpegDemuxerStream::HasAvailableCapacity() { |
| 783 // TODO(scherkus): Remove this return and reenable time-based capacity | 784 // Try to have two second's worth of encoded data per stream. |
| 784 // after our data sources support canceling/concurrent reads, see | 785 const base::TimeDelta kCapacity = base::TimeDelta::FromSeconds(2); |
| 785 // http://crbug.com/165762 for details. | |
| 786 #if 1 | |
| 787 return !read_cb_.is_null(); | |
| 788 #else | |
| 789 // Try to have one second's worth of encoded data per stream. | |
| 790 const base::TimeDelta kCapacity = base::TimeDelta::FromSeconds(1); | |
| 791 return buffer_queue_.IsEmpty() || buffer_queue_.Duration() < kCapacity; | 786 return buffer_queue_.IsEmpty() || buffer_queue_.Duration() < kCapacity; |
| 792 #endif | |
| 793 } | 787 } |
| 794 | 788 |
| 795 size_t FFmpegDemuxerStream::MemoryUsage() const { | 789 size_t FFmpegDemuxerStream::MemoryUsage() const { |
| 796 return buffer_queue_.data_size(); | 790 return buffer_queue_.data_size(); |
| 797 } | 791 } |
| 798 | 792 |
| 799 TextKind FFmpegDemuxerStream::GetTextKind() const { | 793 TextKind FFmpegDemuxerStream::GetTextKind() const { |
| 800 DCHECK_EQ(type_, DemuxerStream::TEXT); | 794 DCHECK_EQ(type_, DemuxerStream::TEXT); |
| 801 | 795 |
| 802 if (stream_->disposition & AV_DISPOSITION_CAPTIONS) | 796 if (stream_->disposition & AV_DISPOSITION_CAPTIONS) |
| (...skipping 1036 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1839 | 1833 |
| 1840 void FFmpegDemuxer::SetLiveness(DemuxerStream::Liveness liveness) { | 1834 void FFmpegDemuxer::SetLiveness(DemuxerStream::Liveness liveness) { |
| 1841 DCHECK(task_runner_->BelongsToCurrentThread()); | 1835 DCHECK(task_runner_->BelongsToCurrentThread()); |
| 1842 for (const auto& stream : streams_) { | 1836 for (const auto& stream : streams_) { |
| 1843 if (stream) | 1837 if (stream) |
| 1844 stream->SetLiveness(liveness); | 1838 stream->SetLiveness(liveness); |
| 1845 } | 1839 } |
| 1846 } | 1840 } |
| 1847 | 1841 |
| 1848 } // namespace media | 1842 } // namespace media |
| OLD | NEW |