| 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 714 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 725 DCHECK(task_runner_->BelongsToCurrentThread()); | 725 DCHECK(task_runner_->BelongsToCurrentThread()); |
| 726 return is_enabled_; | 726 return is_enabled_; |
| 727 } | 727 } |
| 728 | 728 |
| 729 void FFmpegDemuxerStream::set_enabled(bool enabled, base::TimeDelta timestamp) { | 729 void FFmpegDemuxerStream::set_enabled(bool enabled, base::TimeDelta timestamp) { |
| 730 DCHECK(task_runner_->BelongsToCurrentThread()); | 730 DCHECK(task_runner_->BelongsToCurrentThread()); |
| 731 if (enabled == is_enabled_) | 731 if (enabled == is_enabled_) |
| 732 return; | 732 return; |
| 733 | 733 |
| 734 is_enabled_ = enabled; | 734 is_enabled_ = enabled; |
| 735 av_stream()->discard = enabled ? AVDISCARD_DEFAULT : AVDISCARD_ALL; |
| 735 if (is_enabled_) { | 736 if (is_enabled_) { |
| 736 waiting_for_keyframe_ = true; | 737 waiting_for_keyframe_ = true; |
| 737 } | 738 } |
| 738 if (!is_enabled_ && !read_cb_.is_null()) { | 739 if (!is_enabled_ && !read_cb_.is_null()) { |
| 739 DVLOG(1) << "Read from disabled stream, returning EOS"; | 740 DVLOG(1) << "Read from disabled stream, returning EOS"; |
| 740 base::ResetAndReturn(&read_cb_).Run(kOk, DecoderBuffer::CreateEOSBuffer()); | 741 base::ResetAndReturn(&read_cb_).Run(kOk, DecoderBuffer::CreateEOSBuffer()); |
| 741 return; | 742 return; |
| 742 } | 743 } |
| 743 if (!stream_status_change_cb_.is_null()) | 744 if (!stream_status_change_cb_.is_null()) |
| 744 stream_status_change_cb_.Run(this, is_enabled_, timestamp); | 745 stream_status_change_cb_.Run(this, is_enabled_, timestamp); |
| (...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1280 // when using external decoder (e.g. hardware decoder), so override them | 1281 // when using external decoder (e.g. hardware decoder), so override them |
| 1281 // to make sure this translates into a valid VideoDecoderConfig. Coded | 1282 // to make sure this translates into a valid VideoDecoderConfig. Coded |
| 1282 // size is overridden in AVStreamToVideoDecoderConfig(). | 1283 // size is overridden in AVStreamToVideoDecoderConfig(). |
| 1283 if (stream->codecpar->format == AV_PIX_FMT_NONE) | 1284 if (stream->codecpar->format == AV_PIX_FMT_NONE) |
| 1284 stream->codecpar->format = AV_PIX_FMT_YUV420P; | 1285 stream->codecpar->format = AV_PIX_FMT_YUV420P; |
| 1285 } | 1286 } |
| 1286 #endif | 1287 #endif |
| 1287 } else if (codec_type == AVMEDIA_TYPE_SUBTITLE) { | 1288 } else if (codec_type == AVMEDIA_TYPE_SUBTITLE) { |
| 1288 detected_text_track_count++; | 1289 detected_text_track_count++; |
| 1289 if (codec_id != AV_CODEC_ID_WEBVTT || !text_enabled_) { | 1290 if (codec_id != AV_CODEC_ID_WEBVTT || !text_enabled_) { |
| 1291 stream->discard = AVDISCARD_ALL; |
| 1290 continue; | 1292 continue; |
| 1291 } | 1293 } |
| 1292 } else { | 1294 } else { |
| 1295 stream->discard = AVDISCARD_ALL; |
| 1293 continue; | 1296 continue; |
| 1294 } | 1297 } |
| 1295 | 1298 |
| 1296 // Attempt to create a FFmpegDemuxerStream from the AVStream. This will | 1299 // Attempt to create a FFmpegDemuxerStream from the AVStream. This will |
| 1297 // return nullptr if the AVStream is invalid. Validity checks will verify | 1300 // return nullptr if the AVStream is invalid. Validity checks will verify |
| 1298 // things like: codec, channel layout, sample/pixel format, etc... | 1301 // things like: codec, channel layout, sample/pixel format, etc... |
| 1299 std::unique_ptr<FFmpegDemuxerStream> demuxer_stream = | 1302 std::unique_ptr<FFmpegDemuxerStream> demuxer_stream = |
| 1300 FFmpegDemuxerStream::Create(this, stream, media_log_); | 1303 FFmpegDemuxerStream::Create(this, stream, media_log_); |
| 1301 if (demuxer_stream.get()) { | 1304 if (demuxer_stream.get()) { |
| 1302 streams_[i] = std::move(demuxer_stream); | 1305 streams_[i] = std::move(demuxer_stream); |
| (...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1839 | 1842 |
| 1840 void FFmpegDemuxer::SetLiveness(DemuxerStream::Liveness liveness) { | 1843 void FFmpegDemuxer::SetLiveness(DemuxerStream::Liveness liveness) { |
| 1841 DCHECK(task_runner_->BelongsToCurrentThread()); | 1844 DCHECK(task_runner_->BelongsToCurrentThread()); |
| 1842 for (const auto& stream : streams_) { | 1845 for (const auto& stream : streams_) { |
| 1843 if (stream) | 1846 if (stream) |
| 1844 stream->SetLiveness(liveness); | 1847 stream->SetLiveness(liveness); |
| 1845 } | 1848 } |
| 1846 } | 1849 } |
| 1847 | 1850 |
| 1848 } // namespace media | 1851 } // namespace media |
| OLD | NEW |