MediaProfiles的用法

MediaProfiles类主要用于录像和Video Editor,包括设置视频的分辨率,Audio和Video的编解码参数等。

MediaProfiles.h文件中对camcorder质量的定义如下,包括了常见的视频视频分辨率。需要注意的是,下面的定义与CamcorderProfile.java中定义的视频分辨率是对应的,两者需要保持一致。

enum camcorder_quality {
    CAMCORDER_QUALITY_LIST_START = 0,
    CAMCORDER_QUALITY_LOW  = 0,
    CAMCORDER_QUALITY_HIGH = 1,
    CAMCORDER_QUALITY_QCIF = 2,
    CAMCORDER_QUALITY_CIF = 3,
    CAMCORDER_QUALITY_480P = 4,
    CAMCORDER_QUALITY_720P = 5,
    CAMCORDER_QUALITY_1080P = 6,
    CAMCORDER_QUALITY_QVGA = 7,
    CAMCORDER_QUALITY_MIDDLE = 8,
#ifdef CONFIG_CAMERA_SUPPORT_720P
    CAMCORDER_QUALITY_MIDDLE_HIGH = 9,
    CAMCORDER_QUALITY_LIST_END = 9,
#else
    CAMCORDER_QUALITY_LIST_END = 8,
#endif
    CAMCORDER_QUALITY_TIME_LAPSE_LIST_START = 1000,
    CAMCORDER_QUALITY_TIME_LAPSE_LOW  = 1000,
    CAMCORDER_QUALITY_TIME_LAPSE_HIGH = 1001,
    CAMCORDER_QUALITY_TIME_LAPSE_QCIF = 1002,
    CAMCORDER_QUALITY_TIME_LAPSE_CIF = 1003,
    CAMCORDER_QUALITY_TIME_LAPSE_480P = 1004,
    CAMCORDER_QUALITY_TIME_LAPSE_720P = 1005,
    CAMCORDER_QUALITY_TIME_LAPSE_1080P = 1006,
    CAMCORDER_QUALITY_TIME_LAPSE_QVGA = 1007,
    CAMCORDER_QUALITY_TIME_LAPSE_MIDDLE = 1008,
#ifdef CONFIG_CAMERA_SUPPORT_720P
    CAMCORDER_QUALITY_TIME_LAPSE_MIDDLE_HIGH = 1009,
    CAMCORDER_QUALITY_TIME_LAPSE_LIST_END = 1009,
#else
    CAMCORDER_QUALITY_TIME_LAPSE_LIST_END = 1008,
#endif
};

顺便总结一下屏幕分辨率:
Sub-QCIF  128x96
QCIF           176x144
CIF              352x288
4CIF            704x576
QVGA          240×320
HVGA          480*320
VGA             640X480
SVGA          800X600
XGA            1024X768
SXGA          1280X1024
SXGA+       1400X1050
UXGA         1600X1200
WXGA        1280X800
WXGA+      1400X900
WSXGA     1600X1024
WSXGA+   1680X1050
WUXGA     1920X1200
WQXGA     2560X1600

目前只有在StagefrightRecorder中用到了MediaProfiles,用于初始化录像参数;其他代码中还没有用到MediaProfiles。

调用流程如下:

StagefrightRecorder::start() -> startMPEG4Recording() -> setupMPEG4Recording -> setupMediaSource -> setupCameraSource -> checkVideoEncoderCapabilities ->

在checkVideoEncoderCapabilities()函数中调用了以下五个函数设置录像参数,每个函数分别调用MediaProfiles的相关函数取得参数后设置给录像参数。

        clipVideoBitRate();
        clipVideoFrameRate();
        clipVideoFrameWidth();
        clipVideoFrameHeight();
        setDefaultProfileIfNecessary();

你可能感兴趣的:(MediaProfiles的用法)