Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/scoped_ptr.h" | 5 #include "base/scoped_ptr.h" |
| 6 #include "base/string_util.h" | 6 #include "base/string_util.h" |
| 7 #include "base/time.h" | 7 #include "base/time.h" |
| 8 #include "media/base/filter_host.h" | 8 #include "media/base/filter_host.h" |
| 9 #include "media/filters/ffmpeg_common.h" | 9 #include "media/filters/ffmpeg_common.h" |
| 10 #include "media/filters/ffmpeg_demuxer.h" | 10 #include "media/filters/ffmpeg_demuxer.h" |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 53 : demuxer_(demuxer), | 53 : demuxer_(demuxer), |
| 54 av_stream_(stream), | 54 av_stream_(stream), |
| 55 discontinuous_(false) { | 55 discontinuous_(false) { |
| 56 DCHECK(demuxer_); | 56 DCHECK(demuxer_); |
| 57 | 57 |
| 58 // Determine our media format. | 58 // Determine our media format. |
| 59 switch (stream->codec->codec_type) { | 59 switch (stream->codec->codec_type) { |
| 60 case CODEC_TYPE_AUDIO: | 60 case CODEC_TYPE_AUDIO: |
| 61 media_format_.SetAsString(MediaFormat::kMimeType, | 61 media_format_.SetAsString(MediaFormat::kMimeType, |
| 62 mime_type::kFFmpegAudio); | 62 mime_type::kFFmpegAudio); |
| 63 media_format_.SetAsInteger(MediaFormat::kChannels, | |
| 64 stream->codec->channels); | |
|
awong
2009/04/28 23:25:56
do we just not need these values anymore?
scherkus (not reviewing)
2009/04/28 23:31:10
the mime types "audio/x-ffmpeg" and "video/x-ffmpe
| |
| 65 media_format_.SetAsInteger(MediaFormat::kSampleRate, | |
| 66 stream->codec->sample_rate); | |
| 67 media_format_.SetAsInteger(MediaFormat::kSampleBits, | |
| 68 stream->codec->bits_per_raw_sample); | |
| 69 break; | 63 break; |
| 70 case CODEC_TYPE_VIDEO: | 64 case CODEC_TYPE_VIDEO: |
| 71 media_format_.SetAsString(MediaFormat::kMimeType, | 65 media_format_.SetAsString(MediaFormat::kMimeType, |
| 72 mime_type::kFFmpegVideo); | 66 mime_type::kFFmpegVideo); |
| 73 media_format_.SetAsInteger(MediaFormat::kHeight, | |
| 74 stream->codec->height); | |
| 75 media_format_.SetAsInteger(MediaFormat::kWidth, | |
| 76 stream->codec->width); | |
| 77 break; | 67 break; |
| 78 default: | 68 default: |
| 79 NOTREACHED(); | 69 NOTREACHED(); |
| 80 break; | 70 break; |
| 81 } | 71 } |
| 82 int codec_id = static_cast<int>(stream->codec->codec_id); | |
| 83 media_format_.SetAsInteger(kFFmpegCodecID, codec_id); | |
| 84 | 72 |
| 85 // Calculate the time base and duration in microseconds. | 73 // Calculate the time base and duration in microseconds. |
| 86 int64 time_base_us = static_cast<int64>(av_q2d(stream->time_base) * | 74 int64 time_base_us = static_cast<int64>(av_q2d(stream->time_base) * |
| 87 base::Time::kMicrosecondsPerSecond); | 75 base::Time::kMicrosecondsPerSecond); |
| 88 int64 duration_us = static_cast<int64>(time_base_us * stream->duration); | 76 int64 duration_us = static_cast<int64>(time_base_us * stream->duration); |
| 89 time_base_ = base::TimeDelta::FromMicroseconds(time_base_us); | 77 time_base_ = base::TimeDelta::FromMicroseconds(time_base_us); |
| 90 duration_ = base::TimeDelta::FromMicroseconds(duration_us); | 78 duration_ = base::TimeDelta::FromMicroseconds(duration_us); |
| 91 } | 79 } |
| 92 | 80 |
| 93 FFmpegDemuxerStream::~FFmpegDemuxerStream() { | 81 FFmpegDemuxerStream::~FFmpegDemuxerStream() { |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 354 StreamVector::iterator iter; | 342 StreamVector::iterator iter; |
| 355 for (iter = streams_.begin(); iter != streams_.end(); ++iter) { | 343 for (iter = streams_.begin(); iter != streams_.end(); ++iter) { |
| 356 if ((*iter)->HasPendingReads()) { | 344 if ((*iter)->HasPendingReads()) { |
| 357 return true; | 345 return true; |
| 358 } | 346 } |
| 359 } | 347 } |
| 360 return false; | 348 return false; |
| 361 } | 349 } |
| 362 | 350 |
| 363 } // namespace media | 351 } // namespace media |
| OLD | NEW |