帶着三個問題學習這個部分:
問題1:Android中間各類編解碼庫的加載與管理?
問題1:Android如何肯定使用那個編解碼器而且初始化?
問題2:Android如何集成一個新的編解碼器,硬件平臺相關/非硬件平臺相關兩種狀況?css
按照OpenMax IL的簡述,編解碼架構中間相當重要的是以下兩點:
1,各個不一樣功能的conponent
2,平臺商實現的「media.resouce_manager」,用來管理conponent須要的資源。從而控制component狀態的變化。node
PS:
本文是基於Android7.0+QCOM8909高通平臺,播放本地視頻的狀況分析代碼,先對架構有一個總體的認識,後面再開始對流媒體以及協議的學習與分析。android
分析類圖:
其中主要包括個模塊
1,nuplay
2,MediaCodec
3,OMXConponent
4,FileSouce數組
二,加載初始化時序圖,以及流程分析bash
一,系統包含的編解碼庫文件的描述文件
「/etc/media_codecs.xml」
「/etc/media_codecs_performance.xml」架構
這兩個文件列舉了這個系統支持的全部音視頻編解碼對應的支持格式,僅僅在開機初始化的時候加載一次
project 編譯文件:app
# media_profiles and media_codecs xmls for msm8909 ifeq ($(TARGET_ENABLE_QC_AV_ENHANCEMENTS), true) PRODUCT_COPY_FILES += device/Project/media/media_profiles_8909.xml:system/etc/media_profiles.xml \ device/Project/media/media_codecs_8909.xml:system/etc/media_codecs.xml \ device/Project/media/media_codecs_performance_8909.xml:system/etc/media_codecs_performance.xml endif
qcom/base.mk編譯文件ide
PRODUCT_COPY_FILES += \ frameworks/av/media/libstagefright/data/media_codecs_google_audio.xml:system/etc/media_codecs_google_audio.xml \ frameworks/av/media/libstagefright/data/media_codecs_google_telephony.xml:system/etc/media_codecs_google_telephony.xml \ frameworks/av/media/libstagefright/data/media_codecs_google_video.xml:system/etc/media_codecs_google_video.xml \ device/qcom/common/media/media_profiles.xml:system/etc/media_profiles.xml \ #覆蓋 device/qcom/common/media/media_codecs.xml:system/etc/media_codecs.xml #覆蓋
相關文件描述函數
//media_codecs.xml(media_codecs_8909.xml)
<CodecList> <Include href="media_codecs_google_audio.xml" /> <Include href="media_codecs_google_telephony.xml" /> <Settings> <Setting name="max-video-encoder-input-buffers" value="9" /> </Settings> <Encoders> <!-- Video Hardware --> <MediaCodec name="OMX.qcom.video.encoder.avc" type="video/avc" > <Quirk name="requires-allocate-on-input-ports" /> <Quirk name="requires-allocate-on-output-ports" /> <Quirk name="requires-loaded-to-idle-after-allocation" /> <Limit name="size" min="96x64" max="1280x720" /> <Limit name="alignment" value="2x2" /> <Limit name="block-size" value="16x16" /> <Limit name="blocks-per-second" min="1" max="108000" /> <Limit name="bitrate" range="1-14000000" /> <Limit name="concurrent-instances" max="8" /> <Feature name="intra-refresh" /> </MediaCodec> </Encoders> <Decoders> <!-- Audio Software --> <MediaCodec name="OMX.qti.audio.decoder.flac" type="audio/flac" > <Limit name="concurrent-instances" max="10" /> </MediaCodec> <!-- Video Hardware --> <MediaCodec name="OMX.qcom.video.decoder.avc" type="video/avc" > <Quirk name="requires-allocate-on-input-ports" /> <Quirk name="requires-allocate-on-output-ports" /> <Quirk name="defers-output-buffer-allocation" /> <Limit name="size" min="64x64" max="1920x1088" /> <Limit name="alignment" value="2x2" /> <Limit name="block-size" value="16x16" /> <Limit name="blocks-per-second" min="1" max="244800" /> <Limit name="bitrate" range="1-20000000" /> <Feature name="adaptive-playback" /> <Limit name="concurrent-instances" max="8" /> </MediaCodec> </Decoders> <Include href="media_codecs_google_video.xml" /> </CodecList> // media_codecs_performance.xml (media_codecs_performance_8909.xml) <MediaCodecs> <Encoders> <MediaCodec name="OMX.qcom.video.encoder.avc" type="video/avc" update="true"> <Limit name="measured-frame-rate-320x240" range="183-183" /> <Limit name="measured-frame-rate-720x480" range="56-56" /> <Limit name="measured-frame-rate-1280x720" range="25-25" /> </MediaCodec> <!--還有不少MediaCodec成員--> </Encoders> <Decoders> <MediaCodec name="OMX.qcom.video.decoder.avc" type="video/avc" update="true"> <Limit name="measured-frame-rate-320x240" range="457-457" /> <Limit name="measured-frame-rate-720x480" range="274-274" /> <Limit name="measured-frame-rate-1280x720" range="168-168" /> <Limit name="measured-frame-rate-1920x1088" range="54-54" /> </