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 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
387 const scoped_refptr<MediaLog>& media_log) | 387 const scoped_refptr<MediaLog>& media_log) |
388 : host_(NULL), | 388 : host_(NULL), |
389 task_runner_(task_runner), | 389 task_runner_(task_runner), |
390 blocking_thread_("FFmpegDemuxer"), | 390 blocking_thread_("FFmpegDemuxer"), |
391 pending_read_(false), | 391 pending_read_(false), |
392 pending_seek_(false), | 392 pending_seek_(false), |
393 data_source_(data_source), | 393 data_source_(data_source), |
394 media_log_(media_log), | 394 media_log_(media_log), |
395 bitrate_(0), | 395 bitrate_(0), |
396 start_time_(kNoTimestamp()), | 396 start_time_(kNoTimestamp()), |
397 liveness_(LIVENESS_UNKNOWN), | |
397 audio_disabled_(false), | 398 audio_disabled_(false), |
398 text_enabled_(false), | 399 text_enabled_(false), |
399 duration_known_(false), | 400 duration_known_(false), |
400 need_key_cb_(need_key_cb), | 401 need_key_cb_(need_key_cb), |
401 weak_factory_(this) { | 402 weak_factory_(this) { |
402 DCHECK(task_runner_.get()); | 403 DCHECK(task_runner_.get()); |
403 DCHECK(data_source_); | 404 DCHECK(data_source_); |
404 } | 405 } |
405 | 406 |
406 FFmpegDemuxer::~FFmpegDemuxer() {} | 407 FFmpegDemuxer::~FFmpegDemuxer() {} |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
499 | 500 |
500 base::TimeDelta FFmpegDemuxer::GetStartTime() const { | 501 base::TimeDelta FFmpegDemuxer::GetStartTime() const { |
501 DCHECK(task_runner_->BelongsToCurrentThread()); | 502 DCHECK(task_runner_->BelongsToCurrentThread()); |
502 return start_time_; | 503 return start_time_; |
503 } | 504 } |
504 | 505 |
505 base::Time FFmpegDemuxer::GetTimelineOffset() const { | 506 base::Time FFmpegDemuxer::GetTimelineOffset() const { |
506 return timeline_offset_; | 507 return timeline_offset_; |
507 } | 508 } |
508 | 509 |
510 Demuxer::Liveness FFmpegDemuxer::GetLiveness() const { | |
511 DCHECK(task_runner_->BelongsToCurrentThread()); | |
512 return LIVENESS_UNKNOWN; | |
acolwell GONE FROM CHROMIUM
2014/04/25 23:30:52
nit: Shouldn't this return liveness_?
Sergey Ulanov
2014/04/26 01:51:03
Yes, it should :)
| |
513 } | |
514 | |
509 void FFmpegDemuxer::AddTextStreams() { | 515 void FFmpegDemuxer::AddTextStreams() { |
510 DCHECK(task_runner_->BelongsToCurrentThread()); | 516 DCHECK(task_runner_->BelongsToCurrentThread()); |
511 | 517 |
512 for (StreamVector::size_type idx = 0; idx < streams_.size(); ++idx) { | 518 for (StreamVector::size_type idx = 0; idx < streams_.size(); ++idx) { |
513 FFmpegDemuxerStream* stream = streams_[idx]; | 519 FFmpegDemuxerStream* stream = streams_[idx]; |
514 if (stream == NULL || stream->type() != DemuxerStream::TEXT) | 520 if (stream == NULL || stream->type() != DemuxerStream::TEXT) |
515 continue; | 521 continue; |
516 | 522 |
517 TextKind kind = stream->GetTextKind(); | 523 TextKind kind = stream->GetTextKind(); |
518 std::string title = stream->GetMetadata("title"); | 524 std::string title = stream->GetMetadata("title"); |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
689 if (start_time_ == kNoTimestamp()) | 695 if (start_time_ == kNoTimestamp()) |
690 start_time_ = base::TimeDelta(); | 696 start_time_ = base::TimeDelta(); |
691 | 697 |
692 // MPEG-4 B-frames cause grief for a simple container like AVI. Enable PTS | 698 // MPEG-4 B-frames cause grief for a simple container like AVI. Enable PTS |
693 // generation so we always get timestamps, see http://crbug.com/169570 | 699 // generation so we always get timestamps, see http://crbug.com/169570 |
694 if (strcmp(format_context->iformat->name, "avi") == 0) | 700 if (strcmp(format_context->iformat->name, "avi") == 0) |
695 format_context->flags |= AVFMT_FLAG_GENPTS; | 701 format_context->flags |= AVFMT_FLAG_GENPTS; |
696 | 702 |
697 timeline_offset_ = ExtractTimelineOffset(format_context); | 703 timeline_offset_ = ExtractTimelineOffset(format_context); |
698 | 704 |
705 if (max_duration == kInfiniteDuration() && !timeline_offset_.is_null()) { | |
706 liveness_ = LIVENESS_LIVE; | |
707 } else if (max_duration != kInfiniteDuration()) { | |
708 liveness_ = LIVENESS_RECORDED; | |
709 } else { | |
710 liveness_ = LIVENESS_UNKNOWN; | |
711 } | |
712 | |
699 // Good to go: set the duration and bitrate and notify we're done | 713 // Good to go: set the duration and bitrate and notify we're done |
700 // initializing. | 714 // initializing. |
701 host_->SetDuration(max_duration); | 715 host_->SetDuration(max_duration); |
702 duration_known_ = (max_duration != kInfiniteDuration()); | 716 duration_known_ = (max_duration != kInfiniteDuration()); |
703 | 717 |
704 int64 filesize_in_bytes = 0; | 718 int64 filesize_in_bytes = 0; |
705 url_protocol_->GetSize(&filesize_in_bytes); | 719 url_protocol_->GetSize(&filesize_in_bytes); |
706 bitrate_ = CalculateBitrate(format_context, max_duration, filesize_in_bytes); | 720 bitrate_ = CalculateBitrate(format_context, max_duration, filesize_in_bytes); |
707 if (bitrate_ > 0) | 721 if (bitrate_ > 0) |
708 data_source_->SetBitrate(bitrate_); | 722 data_source_->SetBitrate(bitrate_); |
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1002 } | 1016 } |
1003 for (size_t i = 0; i < buffered.size(); ++i) | 1017 for (size_t i = 0; i < buffered.size(); ++i) |
1004 host_->AddBufferedTimeRange(buffered.start(i), buffered.end(i)); | 1018 host_->AddBufferedTimeRange(buffered.start(i), buffered.end(i)); |
1005 } | 1019 } |
1006 | 1020 |
1007 void FFmpegDemuxer::OnDataSourceError() { | 1021 void FFmpegDemuxer::OnDataSourceError() { |
1008 host_->OnDemuxerError(PIPELINE_ERROR_READ); | 1022 host_->OnDemuxerError(PIPELINE_ERROR_READ); |
1009 } | 1023 } |
1010 | 1024 |
1011 } // namespace media | 1025 } // namespace media |
OLD | NEW |