external/stagefright-plugins
リビジョン | 5ab624e1bd993e300a9d4ae03adaeef6013aed35 (tree) |
---|---|
日時 | 2013-11-13 20:45:53 |
作者 | Michael Chen <omxcodec@gmai...> |
コミッター | Michael Chen |
cleanup
@@ -335,10 +335,12 @@ bool FFmpegExtractor::is_codec_supported(enum AVCodecID codec_id) | ||
335 | 335 | return supported; |
336 | 336 | } |
337 | 337 | |
338 | -sp<MetaData> FFmpegExtractor::setVideoFormat(AVCodecContext *avctx) | |
338 | +sp<MetaData> FFmpegExtractor::setVideoFormat(AVStream *stream) | |
339 | 339 | { |
340 | + AVCodecContext *avctx = NULL; | |
340 | 341 | sp<MetaData> meta = NULL; |
341 | 342 | |
343 | + avctx = stream->codec; | |
342 | 344 | CHECK_EQ(avctx->codec_type, AVMEDIA_TYPE_VIDEO); |
343 | 345 | |
344 | 346 | switch(avctx->codec_id) { |
@@ -409,16 +411,19 @@ sp<MetaData> FFmpegExtractor::setVideoFormat(AVCodecContext *avctx) | ||
409 | 411 | meta->setInt32(kKeyHeight, avctx->height); |
410 | 412 | if (avctx->bit_rate > 0) { |
411 | 413 | meta->setInt32(kKeyBitRate, avctx->bit_rate); |
412 | - } | |
414 | + } | |
415 | + setDurationMetaData(stream, meta); | |
413 | 416 | } |
414 | 417 | |
415 | 418 | return meta; |
416 | 419 | } |
417 | 420 | |
418 | -sp<MetaData> FFmpegExtractor::setAudioFormat(AVCodecContext *avctx) | |
421 | +sp<MetaData> FFmpegExtractor::setAudioFormat(AVStream *stream) | |
419 | 422 | { |
423 | + AVCodecContext *avctx = NULL; | |
420 | 424 | sp<MetaData> meta = NULL; |
421 | 425 | |
426 | + avctx = stream->codec; | |
422 | 427 | CHECK_EQ(avctx->codec_type, AVMEDIA_TYPE_AUDIO); |
423 | 428 | |
424 | 429 | switch(avctx->codec_id) { |
@@ -486,12 +491,13 @@ sp<MetaData> FFmpegExtractor::setAudioFormat(AVCodecContext *avctx) | ||
486 | 491 | meta->setInt32(kKeySampleRate, avctx->sample_rate); |
487 | 492 | meta->setInt32(kKeyBlockAlign, avctx->block_align); |
488 | 493 | meta->setInt32(kKeySampleFormat, avctx->sample_fmt); |
494 | + setDurationMetaData(stream, meta); | |
489 | 495 | } |
490 | 496 | |
491 | 497 | return meta; |
492 | 498 | } |
493 | 499 | |
494 | -void FFmpegExtractor::setStreamDurationMeta(AVStream *stream, sp<MetaData> &meta) | |
500 | +void FFmpegExtractor::setDurationMetaData(AVStream *stream, sp<MetaData> &meta) | |
495 | 501 | { |
496 | 502 | AVCodecContext *avctx = stream->codec; |
497 | 503 |
@@ -574,14 +580,12 @@ int FFmpegExtractor::stream_component_open(int stream_index) | ||
574 | 580 | ALOGV("video stream no extradata, but we can ignore it."); |
575 | 581 | } |
576 | 582 | |
577 | - meta = setVideoFormat(avctx); | |
583 | + meta = setVideoFormat(mVideoStream); | |
578 | 584 | if (meta == NULL) { |
579 | 585 | ALOGE("setVideoFormat failed"); |
580 | 586 | return -1; |
581 | 587 | } |
582 | 588 | |
583 | - setStreamDurationMeta(mVideoStream, meta); | |
584 | - | |
585 | 589 | ALOGV("create a video track"); |
586 | 590 | index = mTracks.add( |
587 | 591 | stream_index, new Track(this, meta, mVideoStream, &mVideoQ)); |
@@ -614,14 +618,12 @@ int FFmpegExtractor::stream_component_open(int stream_index) | ||
614 | 618 | ALOGV("audio stream no extradata, but we can ignore it."); |
615 | 619 | } |
616 | 620 | |
617 | - meta = setAudioFormat(avctx); | |
621 | + meta = setAudioFormat(mAudioStream); | |
618 | 622 | if (meta == NULL) { |
619 | 623 | ALOGE("setAudioFormat failed"); |
620 | 624 | return -1; |
621 | 625 | } |
622 | 626 | |
623 | - setStreamDurationMeta(mAudioStream, meta); | |
624 | - | |
625 | 627 | ALOGV("create a audio track"); |
626 | 628 | index = mTracks.add( |
627 | 629 | stream_index, new Track(this, meta, mAudioStream, &mAudioQ)); |
@@ -99,9 +99,9 @@ private: | ||
99 | 99 | void setFFmpegDefaultOpts(); |
100 | 100 | void printTime(int64_t time); |
101 | 101 | bool is_codec_supported(enum AVCodecID codec_id); |
102 | - sp<MetaData> setVideoFormat(AVCodecContext *avctx); | |
103 | - sp<MetaData> setAudioFormat(AVCodecContext *avctx); | |
104 | - void setStreamDurationMeta(AVStream *stream, sp<MetaData> &meta); | |
102 | + sp<MetaData> setVideoFormat(AVStream *stream); | |
103 | + sp<MetaData> setAudioFormat(AVStream *stream); | |
104 | + void setDurationMetaData(AVStream *stream, sp<MetaData> &meta); | |
105 | 105 | int stream_component_open(int stream_index); |
106 | 106 | void stream_component_close(int stream_index); |
107 | 107 | void reachedEOS(enum AVMediaType media_type); |