본문 바로가기
OldStory/Android

OpenMAX AL for ffmpeg

by Alnilam 2012. 5. 4.

OpenMAX AL



  • OpenMAX Application Layer

  • Application-level multimedia playback and recording API for mobile embedded devices.

  • Device independent

  • Cross-platform interface for applications to access a devices audio, video and imaging capabilities.

  • OpenMAX AL 를 사용하면 디바이스에 독립적으로 media player/recorder를 만들 수 있다.


 

NativeMedia Sample



  • ndk/samples/nativemedia 풀더에 OpenMAX AL를 사용하여 MPEG TS 파일을 재생하는 예제가 있다.

  • 이 예제는 android.media.MediaPlayer java class 를 이용하는 방법과 native api를 사용하는 방법

  • 그리고 video sink를 일반surface를 사용하는 법과 opengl GLSurfaceview를 사용하는 예제가 들어 있다.

  • 예제를 실행하기 위해서는 풀더에 포함된 NatieMedia.ts 파일을 /sdcard/NativeMedia.ts 에 저장 되어 있어야 한다.

  • ffmpeg를 사용하여 플레이어를 만들기 위해서는 native 방법을 사용해야 한다.


 

주요 native 함수



  • createEngine() - create the engine and output mix objects

  • createStreamingMediaPlayer(String filename) - crate streaming media player

    • TS file를 open

    • image video sink 와 data source에 대한 format를 정의 하고 media player를 생성

    • 필요한 인터페이스들을 얻는다.



  • setSurface(Surface surface) - set the surface

    • ANativeWindwo_fromSurface 함수 이용 surface와 video sink를 연결



  • setPlayingStreamingMediaPlayer(boolean isPlaying) - set the playing state for the streaming media player

  • shutdown() - shut down the native media system

  • rewindStramingMediaPlayer() - rewind th streaming media player


 

XDataFormat_XXX



  • 예제에서는 XDataFormat_MIME를 사용하여 버퍼에 ts 파일을 직접 밀어 넣어 재생하였다.

  • ffmpeg에서 적용하려면 XDataFormat_RawImage를 사용하여 ffmpeg에서 디코딩한 raw 데이터를 밀어 넣으면 되지 않을까?

  • raw 데이터 처리가 된다면 OpenMAX IL 까지 보지 않아도 될것 같다.!!

  • XADataFormat_RawImage ( OpenMAX AL 1.0 SPEC Chapter 9.1.9 )
    typedef struct XADataFormat_RawImage_ {
    XAuint32 formatType;
    XAuint32 colorFormat;
    XAuint32 height;
    XAuint32 width;
    XAuint32 stride;
    } XADataFormat_RawImage;


    • Structure used to describe the raw image data:




























      FieldDescription
      formatTypeThe format type, which must always be XA_DATAFORMAT_RAWIMAGE for this structure.
      colorFormatRaw image color format. Refer to XA_COLORFORMAT macros.
      heightFrame height (vertical) resolution.
      widthFrame width (horizontal) resolution.
      strideNumber of bytes in a line of the image.




    • formatType
      #define XA_DATAFORMAT_MIME              ((XAuint32) 0x00000001)
      #define XA_DATAFORMAT_PCM ((XAuint32) 0x00000002)
      #define XA_DATAFORMAT_RAWIMAGE ((XAuint32) 0x00000003)


    • colorFormat
      #define XA_COLORFORMAT_UNUSED                   ((XAuint32) 0x00000000)
      #define XA_COLORFORMAT_MONOCHROME ((XAuint32) 0x00000001)
      #define XA_COLORFORMAT_8BITRGB332 ((XAuint32) 0x00000002)
      #define XA_COLORFORMAT_12BITRGB444 ((XAuint32) 0x00000003)
      #define XA_COLORFORMAT_16BITARGB4444 ((XAuint32) 0x00000004)
      #define XA_COLORFORMAT_16BITARGB1555 ((XAuint32) 0x00000005)
      #define XA_COLORFORMAT_16BITRGB565 ((XAuint32) 0x00000006)
      #define XA_COLORFORMAT_16BITBGR565 ((XAuint32) 0x00000007)
      #define XA_COLORFORMAT_18BITRGB666 ((XAuint32) 0x00000008)
      #define XA_COLORFORMAT_18BITARGB1665 ((XAuint32) 0x00000009)
      #define XA_COLORFORMAT_19BITARGB1666 ((XAuint32) 0x0000000A)
      #define XA_COLORFORMAT_24BITRGB888 ((XAuint32) 0x0000000B)
      #define XA_COLORFORMAT_24BITBGR888 ((XAuint32) 0x0000000C)
      #define XA_COLORFORMAT_24BITARGB1887 ((XAuint32) 0x0000000D)
      #define XA_COLORFORMAT_25BITARGB1888 ((XAuint32) 0x0000000E)
      #define XA_COLORFORMAT_32BITBGRA8888 ((XAuint32) 0x0000000F)
      #define XA_COLORFORMAT_32BITARGB8888 ((XAuint32) 0x00000010)
      #define XA_COLORFORMAT_YUV411PLANAR ((XAuint32) 0x00000011)
      #define XA_COLORFORMAT_YUV420PLANAR ((XAuint32) 0x00000013)
      #define XA_COLORFORMAT_YUV420SEMIPLANAR ((XAuint32) 0x00000015)
      #define XA_COLORFORMAT_YUV422PLANAR ((XAuint32) 0x00000016)
      #define XA_COLORFORMAT_YUV422SEMIPLANAR ((XAuint32) 0x00000018)
      #define XA_COLORFORMAT_YCBYCR ((XAuint32) 0x00000019)
      #define XA_COLORFORMAT_YCRYCB ((XAuint32) 0x0000001A)
      #define XA_COLORFORMAT_CBYCRY ((XAuint32) 0x0000001B)
      #define XA_COLORFORMAT_CRYCBY ((XAuint32) 0x0000001C)
      #define XA_COLORFORMAT_YUV444INTERLEAVED ((XAuint32) 0x0000001D)
      #define XA_COLORFORMAT_RAWBAYER8BIT ((XAuint32) 0x0000001E)
      #define XA_COLORFORMAT_RAWBAYER10BIT ((XAuint32) 0x0000001F)
      #define XA_COLORFORMAT_RAWBAYER8BITCOMPRESSED ((XAuint32) 0x00000020)
      #define XA_COLORFORMAT_L2 ((XAuint32) 0x00000021)
      #define XA_COLORFORMAT_L4 ((XAuint32) 0x00000022)
      #define XA_COLORFORMAT_L8 ((XAuint32) 0x00000023)
      #define XA_COLORFORMAT_L16 ((XAuint32) 0x00000024)
      #define XA_COLORFORMAT_L24 ((XAuint32) 0x00000025)
      #define XA_COLORFORMAT_L32 ((XAuint32) 0x00000026)
      #define XA_COLORFORMAT_18BITBGR666 ((XAuint32) 0x00000029)
      #define XA_COLORFORMAT_24BITARGB6666 ((XAuint32) 0x0000002A)
      #define XA_COLORFORMAT_24BITABGR6666 ((XAuint32) 0x0000002B)





 

Wiki : http://howto.homelinux.com/wiki/AndroidFFMPEG#OpenMAXAL

'OldStory > Android' 카테고리의 다른 글

OpenMP  (0) 2012.06.22
android toolchain build  (0) 2012.06.19
OpenSL ES for ffmpeg  (0) 2012.05.03
Unity  (0) 2012.03.16
캘럭시 S2 아이스크림 샌드위치 업그레이드 완료  (0) 2012.03.13