| 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 24 matching lines...) Expand all Loading... |
| 35 #include "media/base/timestamp_constants.h" | 35 #include "media/base/timestamp_constants.h" |
| 36 #include "media/base/video_codecs.h" | 36 #include "media/base/video_codecs.h" |
| 37 #include "media/ffmpeg/ffmpeg_common.h" | 37 #include "media/ffmpeg/ffmpeg_common.h" |
| 38 #include "media/filters/ffmpeg_aac_bitstream_converter.h" | 38 #include "media/filters/ffmpeg_aac_bitstream_converter.h" |
| 39 #include "media/filters/ffmpeg_bitstream_converter.h" | 39 #include "media/filters/ffmpeg_bitstream_converter.h" |
| 40 #include "media/filters/ffmpeg_glue.h" | 40 #include "media/filters/ffmpeg_glue.h" |
| 41 #include "media/filters/ffmpeg_h264_to_annex_b_bitstream_converter.h" | 41 #include "media/filters/ffmpeg_h264_to_annex_b_bitstream_converter.h" |
| 42 #include "media/filters/webvtt_util.h" | 42 #include "media/filters/webvtt_util.h" |
| 43 #include "media/formats/webm/webm_crypto_helpers.h" | 43 #include "media/formats/webm/webm_crypto_helpers.h" |
| 44 #include "media/media_features.h" | 44 #include "media/media_features.h" |
| 45 #include "third_party/ffmpeg/ffmpeg_features.h" |
| 45 | 46 |
| 46 #if BUILDFLAG(ENABLE_HEVC_DEMUXING) | 47 #if BUILDFLAG(ENABLE_HEVC_DEMUXING) |
| 47 #include "media/filters/ffmpeg_h265_to_annex_b_bitstream_converter.h" | 48 #include "media/filters/ffmpeg_h265_to_annex_b_bitstream_converter.h" |
| 48 #endif | 49 #endif |
| 49 | 50 |
| 50 namespace media { | 51 namespace media { |
| 51 | 52 |
| 52 namespace { | 53 namespace { |
| 53 | 54 |
| 54 void SetAVStreamDiscard(AVStream* stream, AVDiscard discard) { | 55 void SetAVStreamDiscard(AVStream* stream, AVDiscard discard) { |
| (...skipping 1185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1240 // Estimate the start time for each stream by looking through the packets | 1241 // Estimate the start time for each stream by looking through the packets |
| 1241 // buffered during avformat_find_stream_info(). These values will be | 1242 // buffered during avformat_find_stream_info(). These values will be |
| 1242 // considered later when determining the actual stream start time. | 1243 // considered later when determining the actual stream start time. |
| 1243 // | 1244 // |
| 1244 // These packets haven't been completely processed yet, so only look through | 1245 // These packets haven't been completely processed yet, so only look through |
| 1245 // these values if the AVFormatContext has a valid start time. | 1246 // these values if the AVFormatContext has a valid start time. |
| 1246 // | 1247 // |
| 1247 // If no estimate is found, the stream entry will be kInfiniteDuration. | 1248 // If no estimate is found, the stream entry will be kInfiniteDuration. |
| 1248 std::vector<base::TimeDelta> start_time_estimates(format_context->nb_streams, | 1249 std::vector<base::TimeDelta> start_time_estimates(format_context->nb_streams, |
| 1249 kInfiniteDuration); | 1250 kInfiniteDuration); |
| 1250 #if !defined(USE_SYSTEM_FFMPEG) | 1251 #if !BUILDFLAG(USE_SYSTEM_FFMPEG) |
| 1251 const AVFormatInternal* internal = format_context->internal; | 1252 const AVFormatInternal* internal = format_context->internal; |
| 1252 if (internal && internal->packet_buffer && | 1253 if (internal && internal->packet_buffer && |
| 1253 format_context->start_time != static_cast<int64_t>(AV_NOPTS_VALUE)) { | 1254 format_context->start_time != static_cast<int64_t>(AV_NOPTS_VALUE)) { |
| 1254 struct AVPacketList* packet_buffer = internal->packet_buffer; | 1255 struct AVPacketList* packet_buffer = internal->packet_buffer; |
| 1255 while (packet_buffer != internal->packet_buffer_end) { | 1256 while (packet_buffer != internal->packet_buffer_end) { |
| 1256 DCHECK_LT(static_cast<size_t>(packet_buffer->pkt.stream_index), | 1257 DCHECK_LT(static_cast<size_t>(packet_buffer->pkt.stream_index), |
| 1257 start_time_estimates.size()); | 1258 start_time_estimates.size()); |
| 1258 const AVStream* stream = | 1259 const AVStream* stream = |
| 1259 format_context->streams[packet_buffer->pkt.stream_index]; | 1260 format_context->streams[packet_buffer->pkt.stream_index]; |
| 1260 if (packet_buffer->pkt.pts != static_cast<int64_t>(AV_NOPTS_VALUE)) { | 1261 if (packet_buffer->pkt.pts != static_cast<int64_t>(AV_NOPTS_VALUE)) { |
| 1261 const base::TimeDelta packet_pts = | 1262 const base::TimeDelta packet_pts = |
| 1262 ConvertFromTimeBase(stream->time_base, packet_buffer->pkt.pts); | 1263 ConvertFromTimeBase(stream->time_base, packet_buffer->pkt.pts); |
| 1263 // We ignore kNoTimestamp here since -int64_t::min() is possible; see | 1264 // We ignore kNoTimestamp here since -int64_t::min() is possible; see |
| 1264 // https://crbug.com/700501. Technically this is a valid value, but in | 1265 // https://crbug.com/700501. Technically this is a valid value, but in |
| 1265 // practice shouldn't occur, so just ignore it when estimating. | 1266 // practice shouldn't occur, so just ignore it when estimating. |
| 1266 if (packet_pts != kNoTimestamp && packet_pts != kInfiniteDuration && | 1267 if (packet_pts != kNoTimestamp && packet_pts != kInfiniteDuration && |
| 1267 packet_pts < start_time_estimates[stream->index]) { | 1268 packet_pts < start_time_estimates[stream->index]) { |
| 1268 start_time_estimates[stream->index] = packet_pts; | 1269 start_time_estimates[stream->index] = packet_pts; |
| 1269 } | 1270 } |
| 1270 } | 1271 } |
| 1271 packet_buffer = packet_buffer->next; | 1272 packet_buffer = packet_buffer->next; |
| 1272 } | 1273 } |
| 1273 } | 1274 } |
| 1274 #endif // !defined(USE_SYSTEM_FFMPEG) | 1275 #endif // !BUILDFLAG(USE_SYSTEM_FFMPEG) |
| 1275 | 1276 |
| 1276 std::unique_ptr<MediaTracks> media_tracks(new MediaTracks()); | 1277 std::unique_ptr<MediaTracks> media_tracks(new MediaTracks()); |
| 1277 | 1278 |
| 1278 DCHECK(track_id_to_demux_stream_map_.empty()); | 1279 DCHECK(track_id_to_demux_stream_map_.empty()); |
| 1279 | 1280 |
| 1280 // If available, |start_time_| will be set to the lowest stream start time. | 1281 // If available, |start_time_| will be set to the lowest stream start time. |
| 1281 start_time_ = kInfiniteDuration; | 1282 start_time_ = kInfiniteDuration; |
| 1282 | 1283 |
| 1283 base::TimeDelta max_duration; | 1284 base::TimeDelta max_duration; |
| 1284 int detected_audio_track_count = 0; | 1285 int detected_audio_track_count = 0; |
| (...skipping 610 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1895 | 1896 |
| 1896 void FFmpegDemuxer::SetLiveness(DemuxerStream::Liveness liveness) { | 1897 void FFmpegDemuxer::SetLiveness(DemuxerStream::Liveness liveness) { |
| 1897 DCHECK(task_runner_->BelongsToCurrentThread()); | 1898 DCHECK(task_runner_->BelongsToCurrentThread()); |
| 1898 for (const auto& stream : streams_) { | 1899 for (const auto& stream : streams_) { |
| 1899 if (stream) | 1900 if (stream) |
| 1900 stream->SetLiveness(liveness); | 1901 stream->SetLiveness(liveness); |
| 1901 } | 1902 } |
| 1902 } | 1903 } |
| 1903 | 1904 |
| 1904 } // namespace media | 1905 } // namespace media |
| OLD | NEW |