| 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 675 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 686 // don't use. FFmpeg will only read ID3v1 tags if no other metadata is | 686 // don't use. FFmpeg will only read ID3v1 tags if no other metadata is |
| 687 // available, so add a metadata entry to ensure some is always present. | 687 // available, so add a metadata entry to ensure some is always present. |
| 688 av_dict_set(&format_context->metadata, "skip_id3v1_tags", "", 0); | 688 av_dict_set(&format_context->metadata, "skip_id3v1_tags", "", 0); |
| 689 | 689 |
| 690 // Ensure ffmpeg doesn't give up too early while looking for stream params; | 690 // Ensure ffmpeg doesn't give up too early while looking for stream params; |
| 691 // this does not increase the amount of data downloaded. The default value | 691 // this does not increase the amount of data downloaded. The default value |
| 692 // is 5 AV_TIME_BASE units (1 second each), which prevents some oddly muxed | 692 // is 5 AV_TIME_BASE units (1 second each), which prevents some oddly muxed |
| 693 // streams from being detected properly; this value was chosen arbitrarily. | 693 // streams from being detected properly; this value was chosen arbitrarily. |
| 694 format_context->max_analyze_duration2 = 60 * AV_TIME_BASE; | 694 format_context->max_analyze_duration2 = 60 * AV_TIME_BASE; |
| 695 | 695 |
| 696 // Always post the callback because |this| could be destroyed upon failure. |
| 697 PipelineStatusCB bound_status_cb = BindToCurrentLoop(status_cb); |
| 698 |
| 696 // Open the AVFormatContext using our glue layer. | 699 // Open the AVFormatContext using our glue layer. |
| 697 CHECK(blocking_thread_.Start()); | 700 CHECK(blocking_thread_.Start()); |
| 698 base::PostTaskAndReplyWithResult( | 701 base::PostTaskAndReplyWithResult( |
| 699 blocking_thread_.message_loop_proxy().get(), | 702 blocking_thread_.message_loop_proxy().get(), |
| 700 FROM_HERE, | 703 FROM_HERE, |
| 701 base::Bind(&FFmpegGlue::OpenContext, base::Unretained(glue_.get())), | 704 base::Bind(&FFmpegGlue::OpenContext, base::Unretained(glue_.get())), |
| 702 base::Bind(&FFmpegDemuxer::OnOpenContextDone, | 705 base::Bind(&FFmpegDemuxer::OnOpenContextDone, |
| 703 weak_factory_.GetWeakPtr(), | 706 weak_factory_.GetWeakPtr(), |
| 704 status_cb)); | 707 bound_status_cb)); |
| 705 } | 708 } |
| 706 | 709 |
| 707 base::Time FFmpegDemuxer::GetTimelineOffset() const { | 710 base::Time FFmpegDemuxer::GetTimelineOffset() const { |
| 708 return timeline_offset_; | 711 return timeline_offset_; |
| 709 } | 712 } |
| 710 | 713 |
| 711 DemuxerStream* FFmpegDemuxer::GetStream(DemuxerStream::Type type) { | 714 DemuxerStream* FFmpegDemuxer::GetStream(DemuxerStream::Type type) { |
| 712 DCHECK(task_runner_->BelongsToCurrentThread()); | 715 DCHECK(task_runner_->BelongsToCurrentThread()); |
| 713 return GetFFmpegStream(type); | 716 return GetFFmpegStream(type); |
| 714 } | 717 } |
| (...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1293 | 1296 |
| 1294 void FFmpegDemuxer::SetLiveness(DemuxerStream::Liveness liveness) { | 1297 void FFmpegDemuxer::SetLiveness(DemuxerStream::Liveness liveness) { |
| 1295 DCHECK(task_runner_->BelongsToCurrentThread()); | 1298 DCHECK(task_runner_->BelongsToCurrentThread()); |
| 1296 for (const auto& stream : streams_) { // |stream| is a ref to a pointer. | 1299 for (const auto& stream : streams_) { // |stream| is a ref to a pointer. |
| 1297 if (stream) | 1300 if (stream) |
| 1298 stream->SetLiveness(liveness); | 1301 stream->SetLiveness(liveness); |
| 1299 } | 1302 } |
| 1300 } | 1303 } |
| 1301 | 1304 |
| 1302 } // namespace media | 1305 } // namespace media |
| OLD | NEW |