OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/callback.h" | 6 #include "base/callback.h" |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 DCHECK(demuxer_); | 66 DCHECK(demuxer_); |
67 | 67 |
68 // Determine our media format. | 68 // Determine our media format. |
69 switch (stream->codec->codec_type) { | 69 switch (stream->codec->codec_type) { |
70 case AVMEDIA_TYPE_AUDIO: | 70 case AVMEDIA_TYPE_AUDIO: |
71 type_ = AUDIO; | 71 type_ = AUDIO; |
72 AVCodecContextToAudioDecoderConfig(stream->codec, &audio_config_); | 72 AVCodecContextToAudioDecoderConfig(stream->codec, &audio_config_); |
73 break; | 73 break; |
74 case AVMEDIA_TYPE_VIDEO: | 74 case AVMEDIA_TYPE_VIDEO: |
75 type_ = VIDEO; | 75 type_ = VIDEO; |
| 76 AVCodecContextToVideoDecoderConfig(stream->codec, |
| 77 stream->r_frame_rate, |
| 78 GetAspectRatio(stream), |
| 79 &video_config_); |
76 break; | 80 break; |
77 default: | 81 default: |
78 NOTREACHED(); | 82 NOTREACHED(); |
79 break; | 83 break; |
80 } | 84 } |
81 | 85 |
82 // Calculate the duration. | 86 // Calculate the duration. |
83 duration_ = ConvertStreamTimestamp(stream->time_base, stream->duration); | 87 duration_ = ConvertStreamTimestamp(stream->time_base, stream->duration); |
84 } | 88 } |
85 | 89 |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
247 filter_name = "vc1_asftoannexg"; | 251 filter_name = "vc1_asftoannexg"; |
248 } | 252 } |
249 | 253 |
250 if (filter_name) { | 254 if (filter_name) { |
251 bitstream_converter_.reset( | 255 bitstream_converter_.reset( |
252 new FFmpegBitstreamConverter(filter_name, stream_->codec)); | 256 new FFmpegBitstreamConverter(filter_name, stream_->codec)); |
253 CHECK(bitstream_converter_->Initialize()); | 257 CHECK(bitstream_converter_->Initialize()); |
254 } | 258 } |
255 } | 259 } |
256 | 260 |
257 AVStream* FFmpegDemuxerStream::GetAVStream() { | |
258 return stream_; | |
259 } | |
260 | |
261 const AudioDecoderConfig& FFmpegDemuxerStream::audio_decoder_config() { | 261 const AudioDecoderConfig& FFmpegDemuxerStream::audio_decoder_config() { |
262 CHECK_EQ(type_, AUDIO); | 262 CHECK_EQ(type_, AUDIO); |
263 return audio_config_; | 263 return audio_config_; |
264 } | 264 } |
265 | 265 |
| 266 const VideoDecoderConfig& FFmpegDemuxerStream::video_decoder_config() { |
| 267 CHECK_EQ(type_, VIDEO); |
| 268 return video_config_; |
| 269 } |
| 270 |
266 // static | 271 // static |
267 base::TimeDelta FFmpegDemuxerStream::ConvertStreamTimestamp( | 272 base::TimeDelta FFmpegDemuxerStream::ConvertStreamTimestamp( |
268 const AVRational& time_base, int64 timestamp) { | 273 const AVRational& time_base, int64 timestamp) { |
269 if (timestamp == static_cast<int64>(AV_NOPTS_VALUE)) | 274 if (timestamp == static_cast<int64>(AV_NOPTS_VALUE)) |
270 return kNoTimestamp; | 275 return kNoTimestamp; |
271 | 276 |
272 return ConvertFromTimeBase(time_base, timestamp); | 277 return ConvertFromTimeBase(time_base, timestamp); |
273 } | 278 } |
274 | 279 |
275 // | 280 // |
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
677 DCHECK_EQ(MessageLoop::current(), message_loop_); | 682 DCHECK_EQ(MessageLoop::current(), message_loop_); |
678 | 683 |
679 StreamVector::iterator iter; | 684 StreamVector::iterator iter; |
680 for (size_t i = 0; i < packet_streams_.size(); ++i) { | 685 for (size_t i = 0; i < packet_streams_.size(); ++i) { |
681 if (!packet_streams_[i]) | 686 if (!packet_streams_[i]) |
682 continue; | 687 continue; |
683 | 688 |
684 // If the codec type is audio, remove the reference. DemuxTask() will | 689 // If the codec type is audio, remove the reference. DemuxTask() will |
685 // look for such reference, and this will result in deleting the | 690 // look for such reference, and this will result in deleting the |
686 // audio packets after they are demuxed. | 691 // audio packets after they are demuxed. |
687 if (packet_streams_[i]->GetAVStream()->codec->codec_type == | 692 if (packet_streams_[i]->type() == DemuxerStream::AUDIO) { |
688 AVMEDIA_TYPE_AUDIO) { | |
689 packet_streams_[i] = NULL; | 693 packet_streams_[i] = NULL; |
690 } | 694 } |
691 } | 695 } |
692 } | 696 } |
693 | 697 |
694 bool FFmpegDemuxer::StreamsHavePendingReads() { | 698 bool FFmpegDemuxer::StreamsHavePendingReads() { |
695 DCHECK_EQ(MessageLoop::current(), message_loop_); | 699 DCHECK_EQ(MessageLoop::current(), message_loop_); |
696 StreamVector::iterator iter; | 700 StreamVector::iterator iter; |
697 for (iter = streams_.begin(); iter != streams_.end(); ++iter) { | 701 for (iter = streams_.begin(); iter != streams_.end(); ++iter) { |
698 if (*iter && (*iter)->HasPendingReads()) { | 702 if (*iter && (*iter)->HasPendingReads()) { |
(...skipping 23 matching lines...) Expand all Loading... |
722 read_event_.Wait(); | 726 read_event_.Wait(); |
723 return last_read_bytes_; | 727 return last_read_bytes_; |
724 } | 728 } |
725 | 729 |
726 void FFmpegDemuxer::SignalReadCompleted(size_t size) { | 730 void FFmpegDemuxer::SignalReadCompleted(size_t size) { |
727 last_read_bytes_ = size; | 731 last_read_bytes_ = size; |
728 read_event_.Signal(); | 732 read_event_.Signal(); |
729 } | 733 } |
730 | 734 |
731 } // namespace media | 735 } // namespace media |
OLD | NEW |