| 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 29 matching lines...) Expand all Loading... |
| 40 #include "media/filters/webvtt_util.h" | 40 #include "media/filters/webvtt_util.h" |
| 41 #include "media/formats/webm/webm_crypto_helpers.h" | 41 #include "media/formats/webm/webm_crypto_helpers.h" |
| 42 #include "media/media_features.h" | 42 #include "media/media_features.h" |
| 43 | 43 |
| 44 #if BUILDFLAG(ENABLE_HEVC_DEMUXING) | 44 #if BUILDFLAG(ENABLE_HEVC_DEMUXING) |
| 45 #include "media/filters/ffmpeg_h265_to_annex_b_bitstream_converter.h" | 45 #include "media/filters/ffmpeg_h265_to_annex_b_bitstream_converter.h" |
| 46 #endif | 46 #endif |
| 47 | 47 |
| 48 namespace media { | 48 namespace media { |
| 49 | 49 |
| 50 namespace { |
| 51 |
| 50 static base::Time ExtractTimelineOffset(AVFormatContext* format_context) { | 52 static base::Time ExtractTimelineOffset(AVFormatContext* format_context) { |
| 51 if (strstr(format_context->iformat->name, "webm") || | 53 if (strstr(format_context->iformat->name, "webm") || |
| 52 strstr(format_context->iformat->name, "matroska")) { | 54 strstr(format_context->iformat->name, "matroska")) { |
| 53 const AVDictionaryEntry* entry = | 55 const AVDictionaryEntry* entry = |
| 54 av_dict_get(format_context->metadata, "creation_time", NULL, 0); | 56 av_dict_get(format_context->metadata, "creation_time", NULL, 0); |
| 55 | 57 |
| 56 base::Time timeline_offset; | 58 base::Time timeline_offset; |
| 57 | 59 |
| 58 // FFmpegDemuxerTests assume base::Time::FromUTCString() is used here. | 60 // FFmpegDemuxerTests assume base::Time::FromUTCString() is used here. |
| 59 if (entry != NULL && entry->value != NULL && | 61 if (entry != NULL && entry->value != NULL && |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 const std::string& key, | 193 const std::string& key, |
| 192 base::TimeDelta value) { | 194 base::TimeDelta value) { |
| 193 if (value == kInfiniteDuration) | 195 if (value == kInfiniteDuration) |
| 194 event->params.SetString(key, "kInfiniteDuration"); | 196 event->params.SetString(key, "kInfiniteDuration"); |
| 195 else if (value == kNoTimestamp) | 197 else if (value == kNoTimestamp) |
| 196 event->params.SetString(key, "kNoTimestamp"); | 198 event->params.SetString(key, "kNoTimestamp"); |
| 197 else | 199 else |
| 198 event->params.SetDouble(key, value.InSecondsF()); | 200 event->params.SetDouble(key, value.InSecondsF()); |
| 199 } | 201 } |
| 200 | 202 |
| 203 static void UnmarkEndOfStream(AVFormatContext* format_context) { |
| 204 format_context->pb->eof_reached = 0; |
| 205 } |
| 206 |
| 207 } // namespace |
| 208 |
| 201 std::unique_ptr<FFmpegDemuxerStream> FFmpegDemuxerStream::Create( | 209 std::unique_ptr<FFmpegDemuxerStream> FFmpegDemuxerStream::Create( |
| 202 FFmpegDemuxer* demuxer, | 210 FFmpegDemuxer* demuxer, |
| 203 AVStream* stream, | 211 AVStream* stream, |
| 204 const scoped_refptr<MediaLog>& media_log) { | 212 const scoped_refptr<MediaLog>& media_log) { |
| 205 if (!demuxer || !stream) | 213 if (!demuxer || !stream) |
| 206 return nullptr; | 214 return nullptr; |
| 207 | 215 |
| 208 std::unique_ptr<FFmpegDemuxerStream> demuxer_stream; | 216 std::unique_ptr<FFmpegDemuxerStream> demuxer_stream; |
| 209 std::unique_ptr<AudioDecoderConfig> audio_config; | 217 std::unique_ptr<AudioDecoderConfig> audio_config; |
| 210 std::unique_ptr<VideoDecoderConfig> video_config; | 218 std::unique_ptr<VideoDecoderConfig> video_config; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 } | 250 } |
| 243 | 251 |
| 244 MEDIA_LOG(INFO, media_log) << "FFmpegDemuxer: created video stream, config " | 252 MEDIA_LOG(INFO, media_log) << "FFmpegDemuxer: created video stream, config " |
| 245 << video_config->AsHumanReadableString(); | 253 << video_config->AsHumanReadableString(); |
| 246 } | 254 } |
| 247 | 255 |
| 248 return base::WrapUnique(new FFmpegDemuxerStream( | 256 return base::WrapUnique(new FFmpegDemuxerStream( |
| 249 demuxer, stream, std::move(audio_config), std::move(video_config))); | 257 demuxer, stream, std::move(audio_config), std::move(video_config))); |
| 250 } | 258 } |
| 251 | 259 |
| 252 static void UnmarkEndOfStream(AVFormatContext* format_context) { | |
| 253 format_context->pb->eof_reached = 0; | |
| 254 } | |
| 255 | |
| 256 // | 260 // |
| 257 // FFmpegDemuxerStream | 261 // FFmpegDemuxerStream |
| 258 // | 262 // |
| 259 FFmpegDemuxerStream::FFmpegDemuxerStream( | 263 FFmpegDemuxerStream::FFmpegDemuxerStream( |
| 260 FFmpegDemuxer* demuxer, | 264 FFmpegDemuxer* demuxer, |
| 261 AVStream* stream, | 265 AVStream* stream, |
| 262 std::unique_ptr<AudioDecoderConfig> audio_config, | 266 std::unique_ptr<AudioDecoderConfig> audio_config, |
| 263 std::unique_ptr<VideoDecoderConfig> video_config) | 267 std::unique_ptr<VideoDecoderConfig> video_config) |
| 264 : demuxer_(demuxer), | 268 : demuxer_(demuxer), |
| 265 task_runner_(base::ThreadTaskRunnerHandle::Get()), | 269 task_runner_(base::ThreadTaskRunnerHandle::Get()), |
| (...skipping 1550 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1816 | 1820 |
| 1817 void FFmpegDemuxer::SetLiveness(DemuxerStream::Liveness liveness) { | 1821 void FFmpegDemuxer::SetLiveness(DemuxerStream::Liveness liveness) { |
| 1818 DCHECK(task_runner_->BelongsToCurrentThread()); | 1822 DCHECK(task_runner_->BelongsToCurrentThread()); |
| 1819 for (const auto& stream : streams_) { | 1823 for (const auto& stream : streams_) { |
| 1820 if (stream) | 1824 if (stream) |
| 1821 stream->SetLiveness(liveness); | 1825 stream->SetLiveness(liveness); |
| 1822 } | 1826 } |
| 1823 } | 1827 } |
| 1824 | 1828 |
| 1825 } // namespace media | 1829 } // namespace media |
| OLD | NEW |