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 <string> | 8 #include <string> |
9 | 9 |
10 #include "base/base64.h" | 10 #include "base/base64.h" |
(...skipping 820 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
831 // Estimate the start time for each stream by looking through the packets | 831 // Estimate the start time for each stream by looking through the packets |
832 // buffered during avformat_find_stream_info(). These values will be | 832 // buffered during avformat_find_stream_info(). These values will be |
833 // considered later when determining the actual stream start time. | 833 // considered later when determining the actual stream start time. |
834 // | 834 // |
835 // These packets haven't been completely processed yet, so only look through | 835 // These packets haven't been completely processed yet, so only look through |
836 // these values if the AVFormatContext has a valid start time. | 836 // these values if the AVFormatContext has a valid start time. |
837 // | 837 // |
838 // If no estimate is found, the stream entry will be kInfiniteDuration(). | 838 // If no estimate is found, the stream entry will be kInfiniteDuration(). |
839 std::vector<base::TimeDelta> start_time_estimates(format_context->nb_streams, | 839 std::vector<base::TimeDelta> start_time_estimates(format_context->nb_streams, |
840 kInfiniteDuration()); | 840 kInfiniteDuration()); |
841 if (format_context->packet_buffer && | 841 const AVFormatInternal* internal = format_context->internal; |
| 842 if (internal && internal->packet_buffer && |
842 format_context->start_time != static_cast<int64>(AV_NOPTS_VALUE)) { | 843 format_context->start_time != static_cast<int64>(AV_NOPTS_VALUE)) { |
843 struct AVPacketList* packet_buffer = format_context->packet_buffer; | 844 struct AVPacketList* packet_buffer = internal->packet_buffer; |
844 while (packet_buffer != format_context->packet_buffer_end) { | 845 while (packet_buffer != internal->packet_buffer_end) { |
845 DCHECK_LT(static_cast<size_t>(packet_buffer->pkt.stream_index), | 846 DCHECK_LT(static_cast<size_t>(packet_buffer->pkt.stream_index), |
846 start_time_estimates.size()); | 847 start_time_estimates.size()); |
847 const AVStream* stream = | 848 const AVStream* stream = |
848 format_context->streams[packet_buffer->pkt.stream_index]; | 849 format_context->streams[packet_buffer->pkt.stream_index]; |
849 if (packet_buffer->pkt.pts != static_cast<int64>(AV_NOPTS_VALUE)) { | 850 if (packet_buffer->pkt.pts != static_cast<int64>(AV_NOPTS_VALUE)) { |
850 const base::TimeDelta packet_pts = | 851 const base::TimeDelta packet_pts = |
851 ConvertFromTimeBase(stream->time_base, packet_buffer->pkt.pts); | 852 ConvertFromTimeBase(stream->time_base, packet_buffer->pkt.pts); |
852 if (packet_pts < start_time_estimates[stream->index]) | 853 if (packet_pts < start_time_estimates[stream->index]) |
853 start_time_estimates[stream->index] = packet_pts; | 854 start_time_estimates[stream->index] = packet_pts; |
854 } | 855 } |
(...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1293 | 1294 |
1294 void FFmpegDemuxer::SetLiveness(DemuxerStream::Liveness liveness) { | 1295 void FFmpegDemuxer::SetLiveness(DemuxerStream::Liveness liveness) { |
1295 DCHECK(task_runner_->BelongsToCurrentThread()); | 1296 DCHECK(task_runner_->BelongsToCurrentThread()); |
1296 for (const auto& stream : streams_) { // |stream| is a ref to a pointer. | 1297 for (const auto& stream : streams_) { // |stream| is a ref to a pointer. |
1297 if (stream) | 1298 if (stream) |
1298 stream->SetLiveness(liveness); | 1299 stream->SetLiveness(liveness); |
1299 } | 1300 } |
1300 } | 1301 } |
1301 | 1302 |
1302 } // namespace media | 1303 } // namespace media |
OLD | NEW |