JOMUCOPYOPENMAX intro.docx

上传人:b****3 文档编号:11808091 上传时间:2023-06-02 格式:DOCX 页数:17 大小:31.95KB
下载 相关 举报
JOMUCOPYOPENMAX intro.docx_第1页
第1页 / 共17页
JOMUCOPYOPENMAX intro.docx_第2页
第2页 / 共17页
JOMUCOPYOPENMAX intro.docx_第3页
第3页 / 共17页
JOMUCOPYOPENMAX intro.docx_第4页
第4页 / 共17页
JOMUCOPYOPENMAX intro.docx_第5页
第5页 / 共17页
JOMUCOPYOPENMAX intro.docx_第6页
第6页 / 共17页
JOMUCOPYOPENMAX intro.docx_第7页
第7页 / 共17页
JOMUCOPYOPENMAX intro.docx_第8页
第8页 / 共17页
JOMUCOPYOPENMAX intro.docx_第9页
第9页 / 共17页
JOMUCOPYOPENMAX intro.docx_第10页
第10页 / 共17页
JOMUCOPYOPENMAX intro.docx_第11页
第11页 / 共17页
JOMUCOPYOPENMAX intro.docx_第12页
第12页 / 共17页
JOMUCOPYOPENMAX intro.docx_第13页
第13页 / 共17页
JOMUCOPYOPENMAX intro.docx_第14页
第14页 / 共17页
JOMUCOPYOPENMAX intro.docx_第15页
第15页 / 共17页
JOMUCOPYOPENMAX intro.docx_第16页
第16页 / 共17页
JOMUCOPYOPENMAX intro.docx_第17页
第17页 / 共17页
亲,该文档总共17页,全部预览完了,如果喜欢就下载吧!
下载资源
资源描述

JOMUCOPYOPENMAX intro.docx

《JOMUCOPYOPENMAX intro.docx》由会员分享,可在线阅读,更多相关《JOMUCOPYOPENMAX intro.docx(17页珍藏版)》请在冰点文库上搜索。

JOMUCOPYOPENMAX intro.docx

JOMUCOPYOPENMAXintro

OpenMAXALforAndroid

ThisarticledescribestheAndroidnativemultimediaAPIsbasedontheKhronosGroupOpenMAXAL™1.0.1standard,asofAndroidAPIlevel14(Androidplatformversion4.0)andhigher.

OpenMAXALisacompanionAPItoOpenSLES,butformultimedia(videoandaudio)ratherthanaudioonly.

Android4.0providesadirect,efficientpathforlow-levelstreamingmultimedia.Thenewpathisidealforapplicationsthatneedtomaintaincompletecontrolovermediadatabeforepassingittotheplatformforpresentation.Forexample,mediaapplicationscannowretrievedatafromanysource,applyproprietaryencryption/decryption,andthensendthedatatotheplatformfordisplay.

Applicationscannowsendprocesseddatatotheplatformasamultiplexedstreamofaudio/videocontentinMPEG-2transportstreamformat.Theplatformde-muxes,decodes,andrendersthecontent.Theaudiotrackisrenderedtotheactiveaudiodevice,whilethevideotrackisrenderedtoeitheraSurfaceoraSurfaceTexture.WhenrenderingtoaSurfaceTexture,theapplicationcanapplysubsequentgraphicseffectstoeachframeusingOpenGL.

OpenMAXALprovidesaClanguageinterfacethatisalsocallablefromC++,andexposesfeaturessimilartotheseAndroidAPIscallablefromJavaprogramminglanguagecode:

∙android.media.MediaPlayer

AswithalloftheAndroidNativeDevelopmentKit(NDK),theprimarypurposeofOpenMAXALforAndroidistofacilitatetheimplementationofsharedlibrariestobecalledfromJavaprogramminglanguagecodeviaJavaNativeInterface(JNI).NDKisnotintendedforwritingpureC/C++applications.

Note:

thoughbasedonOpenMAXAL,theAndroidnativemultimediaAPIis not aconformingimplementationofeitherOpenMAXAL1.0.1profile(mediaplayerormediaplayer/recorder).ThisisbecauseAndroiddoesnotimplementallofthefeaturesrequiredbyeitheroftheprofiles.AnyknowncaseswhereAndroidbehavesdifferentlythanthespecificationaredescribedinsection"Androidextensions"below.TheAndroidOpenMAXALimplementationhaslimitedfeatures,andisintendedprimarilyforcertainperformance-sensitivenativestreamingmultimediaapplicationssuchasvideoplayers.

ThemajorfeatureistheabilitytoplayanMPEG-2transportstreamcontainingasingleprogramstreammadeupofoneH.264videoelementarystreamandoneAACaudioelementarystream.TheapplicationprovidesthestreamviaanAndroidbufferqueuedatasource,whichisbasedontheOpenSLESbufferqueueconceptandAndroid-specificextensions.

Thevideosinkisan ANativeWindow* abstracthandle,derivedfroman android.view.Surface ("surface").ASurfacefrom SurfaceHolder.getSurface() shouldbeusedwhendisplayinganunalteredvideowithinafixedSurfaceViewframe.ASurfacefrom newSurface(SurfaceTexture) allowsstreamingthedecodedvideoframestoanOpenGLES2.0texture,wheretheframescanbeusedasinputtoashaderalgorithmintheGraphicsProcessingUnit(GPU).Besureto release() theSurfaceassoonaspossibleaftercalling setSurface orANativeWindow_fromSurface.

Theaudiosinkisalwaysanoutputmix,adevice-independentmixerobjectsimilartothatofOpenSLES.

Gettingstarted

Examplecode

Recommended

Supportedandtestedexamplecode,usableasamodelforyourowncode,islocatedinNDKfolder platforms/android-14/samples/native-media/.

Notrecommended

TheOpenMAXAL1.0.1specificationcontainsexamplecodeintheappendices(seesection"References"belowforthelinktothisspecification).However,theexamplesinAppendixD:

SampleCodeusefeaturesnotsupportedbyAndroid.Someexamplesalsocontaintypographicalerrors,oruseAPIsthatarelikelytochange.Proceedwithcautioninreferringtothese;thoughthecodemaybehelpfulinunderstandingthefullOpenMAXALstandard,itshouldnotbeusedasiswithAndroid.

AddingOpenMAXALtoyourapplicationsourcecode

OpenMAXALisaCAPI,butiscallablefrombothCandC++code.

Addthefollowinglinestoyourcode:

#include

#include

Makefile

ModifyyourAndroid.mkasfollows:

LOCAL_LDLIBS+=libOpenMAXAL

Multimediacontent

TheonlysupportedwaytosupplymultimediacontentisviaanMPEG-2transportstream.

Findingorcreatingusefulmultimediacontentforyourapplicationisbeyondthescopeofthisarticle.

Notethatitisyourresponsibilitytoensurethatyouarelegallypermittedtoplaythecontent.

Debugging

Forrobustness,werecommendthatyouexaminethe XAresult valuewhichisreturnedbymostAPIs.Useof assert vs.moreadvancederrorhandlinglogicisamatterofcodingstyleandtheparticularAPI;seetheWikipediaarticleon assert formoreinformation.Inthesuppliedexample,wehaveused assert for"impossible"conditionswhichwouldindicateacodingerror,andexpliciterrorhandlingforotherswhicharemorelikelytooccurinproduction.

ManyAPIerrorsresultinalogentry,inadditiontothenon-zeroresultcode.TheselogentriesprovideadditionaldetailwhichcanbeespeciallyusefulforthemorecomplexAPIssuchas Engine:

:

CreateMediaPlayer.

Use adblogcat,the EclipseADTplugin LogCatpane,or ddmslogcat toseethelog.

SupportedfeaturesfromOpenMAXAL1.0.1

Thissectionsummarizesavailablefeatures.Insomecases,therearelimitationswhicharedescribedinthenextsub-section.

Globalentrypoints

Supportedglobalentrypoints:

∙xaCreateEngine

∙xaQueryNumSupportedEngineInterfaces

∙xaQuerySupportedEngineInterfaces

Objectsandinterfaces

ThefollowingfigureindicatesobjectsandinterfacessupportedbyAndroid'sOpenMAXALimplementation.Agreencellmeansthefeatureissupported.

Limitations

Thissectiondetailslimitationswithrespecttothesupportedobjectsandinterfacesfromtheprevioussection.

Audio

Theaudiostreamtypecannotbeconfigured;itisalways AudioManager.STREAM_MUSIC.

Effectsarenotsupported.

Dynamicinterfacemanagement

RemoveInterface and ResumeInterface arenotsupported.

Engine

Supported:

∙CreateMediaPlayer

Notsupported:

∙CreateCameraDevice

∙CreateRadioDevice

∙CreateLEDDevice

∙CreateVibraDevice

∙CreateMetadataExtractor

∙CreateExtensionObject

∙GetImplementationInfo

For CreateMediaPlayer,theserestrictionsapply:

∙audiosinkisanoutputmixdatalocator

∙videosinkisanativedisplaydatalocator

∙soundbank,LEDarray,andvibrasinksmustbe NULL

MIMEdataformat

InthecurrentAndroidimplementationofOpenMAXAL,amediaplayerreceivesitssourcedataasanMPEG-2transportstreamviaabufferqueue.

Thesourcedatalocatormustbe XA_DATALOCATOR_ANDROIDBUFFERQUEUE (see"Androidextensions"below).

Thesourcedataformatmustbe XADataFormat_MIME.Initialize mimeType to XA_ANDROID_MIME_MP2TS,and containerType to XA_CONTAINERTYPE_MPEG_TS.

ThecontainedtransportstreammusthaveasingleprogramwithoneH.264videoelementarystreamandoneAACaudioelementarystream.

Object

Resume, RegisterCallback, AbortAsyncOperation, SetPriority, GetPriority,and SetLossOfControlInterfaces arenotsupported.

StreamInformation

UsetheStreamInformationinterfaceonamediaplayerobjecttodiscoverwhenthevideometrics(height/widthoraspectratio)areavailableorchanged,andtothengetthesizes.

Supported:

∙RegisterStreamChangeCallback

∙QueryMediaContainerInformation

∙QueryStreamInformation

∙QueryStreamType

Notsupported:

∙QueryActiveStreams

∙QueryStreamName

∙SetActiveStream

VideoDecoderCapabilities

Thisinterfaceontheengineobjectreportsvideodecodercapabilitieswithoutinterpretation,exactlyasclaimedbytheunderlyingOpenMAXILimplementation.

Thesefieldsin XAVideoCodecDescriptor arefilled:

∙codecId

∙profileSetting

∙levelSetting

Theotherfieldsarenotfilledandshouldbeignored.

Applicationsshouldrelyonthecapabilitiesdocumentedat AndroidSupportedMediaFormats,nottheinformationreportedbythisinterface.

Datastructures

AndroidAPIlevel14supportstheseOpenMAXAL1.0.1datastructures:

∙XADataFormat_MIME

∙XADataLocator_NativeDisplay

∙XADataLocator_OutputMix

∙XADataSink

∙XADataSource

∙XAEngineOption

∙XAInterfaceID

∙XAMediaContainerInformation

∙XANativeHandle

∙XA*StreamInformation

∙XAVideoCodecDescriptor

XADataLocator_NativeDisplay

Thenativedisplaydatalocatorisusedtospecifythevideosink:

typedefstructXADataLocator_NativeDisplay_{

XAuint32locatorType;//XA_DATALOCATOR_NATIVEDISPLAY

XANativeHandlehWindow;//ANativeWindow*

XANativeHandlehDisplay;//NULL

}XADataLocator_NativeDisplay;

Setthe hWindow fieldtoan ANativeWindow* andset hDisplay to NULL.Youcangeta ANativeWindow* handlefroman android.view.Surface,usingthisNDKfunction:

#include

ANativeWindow*ANativeWindow_fromSurface(JNIEnv*env,jobjectsurface);

Don'tforgettofreethishandleinyourshutdowncodewith ANativeWindow_release.

Platformconfiguration

OpenMAXALforAndroidisdesignedformulti-threadedapplications,andisthread-safe.

OpenMAXALforAndroidsupportsasingleengineperapplication,andupto32objects.AvailabledevicememoryandCPUmayfurtherrestricttheusablenumberofobjects.

xaCreateEngine recognizes,butignores,theseengineoptions:

∙XA_ENGINEOPTION_THREADSAFE

∙XA_ENGINEOPTION_LOSSOFCONTROL

OpenMAXALandOpenSLESmaybeusedtogetherinthesameapplication.Inthiscase,thereisinternallyasinglesharedengineobject,andthe32objectlimitissharedbetweenOpenMAXALandOpenSLES.Theapplicationshouldfirstcreatebothengines,thenusebothengines,andfinallydestroybothengines.Theimplementationmaintainsareferencecountonthesharedengine,sothatitiscorrectlydestroyedattheseconddestroy.

Planningforfutur

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 工作范文 > 行政公文

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2