带着三个问题学习这个部分:
问题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" /> </