status_t MediaCodecList::getCodecCapabilities(
        size_t index, const char *type,
        Vector<ProfileLevel> *profileLevels,
        Vector<uint32_t> *colorFormats,
        uint32_t *flags) const {
    profileLevels->clear();
    colorFormats->clear();

    if (index >= mCodecInfos.size()) {
        return -ERANGE;
    }

    const CodecInfo &info = mCodecInfos.itemAt(index);

    OMXClient client;
    status_t err = client.connect();
    if (err != OK) {
        return err;
    }

    CodecCapabilities caps;
    err = QueryCodec(
            client.interface(),
            info.mName.c_str(), type, info.mIsEncoder, &caps);

    if (err != OK) {
        return err;
    }

    for (size_t i = 0; i < caps.mProfileLevels.size(); ++i) {
        const CodecProfileLevel &src = caps.mProfileLevels.itemAt(i);

        ProfileLevel profileLevel;
        profileLevel.mProfile = src.mProfile;
        profileLevel.mLevel = src.mLevel;
        profileLevels->push(profileLevel);
    }

    for (size_t i = 0; i < caps.mColorFormats.size(); ++i) {
        colorFormats->push(caps.mColorFormats.itemAt(i));
    }

    *flags = caps.mFlags;

    return OK;
}
示例#2
0
status_t MediaCodecList::initializeCapabilities(const char *type) {
    if (type == NULL) {
        return OK;
    }

    ALOGV("initializeCapabilities %s:%s",
            mCurrentInfo->mName.c_str(), type);

    CodecCapabilities caps;
    status_t err = QueryCodec(
            mOMX,
            mCurrentInfo->mName.c_str(),
            type,
            mCurrentInfo->mIsEncoder,
            &caps);
    if (err != OK) {
        return err;
    }

    return mCurrentInfo->initializeCapabilities(caps);
}
status_t MediaCodecList::getCodecCapabilities(
        size_t index, const char *type,
        Vector<ProfileLevel> *profileLevels,
        Vector<uint32_t> *colorFormats,
        uint32_t *flags) const {
    profileLevels->clear();
    colorFormats->clear();

#ifndef ANDROID_DEFAULT_CODE
	ALOGI("[%s][ index=%d, mCodecInfos.size()=%d] ",__FUNCTION__,index,mCodecInfos.size() );
#endif	

    if (index >= mCodecInfos.size()) {
        return -ERANGE;
    }

    const CodecInfo &info = mCodecInfos.itemAt(index);

    OMXClient client;
    status_t err = client.connect();
    if (err != OK) {
#ifndef ANDROID_DEFAULT_CODE
	ALOGI("[%s][ err1=%d  ] ",__FUNCTION__,err );
#endif			
        return err;
    }

#ifndef ANDROID_DEFAULT_CODE
	ALOGI("[%s][ connect OK ] ",__FUNCTION__ );
#endif

    CodecCapabilities caps;
    err = QueryCodec(
            client.interface(),
            info.mName.c_str(), type, info.mIsEncoder, &caps);

    if (err != OK) {
#ifndef ANDROID_DEFAULT_CODE
    ALOGI("[%s][ err2=%d ] ",__FUNCTION__,err );
#endif
        return err;
    }

#ifndef ANDROID_DEFAULT_CODE
    ALOGI("[%s][ QueryCodec OK ] ",__FUNCTION__ );
    int memTotalBytes = sysconf(_SC_PHYS_PAGES) * PAGE_SIZE;
    ALOGD("native_get_videoeditor_profile: mIsEncoder %d, memTotalBytes %d bytes", info.mIsEncoder, memTotalBytes);
#endif //ANDROID_DEFAULT_CODE

    for (size_t i = 0; i < caps.mProfileLevels.size(); ++i) {
        const CodecProfileLevel &src = caps.mProfileLevels.itemAt(i);

        ProfileLevel profileLevel;
        profileLevel.mProfile = src.mProfile;
        profileLevel.mLevel = src.mLevel;
#ifndef ANDROID_DEFAULT_CODE
        ALOGD("mProfile %d mLevel %d", src.mProfile, src.mLevel);
        //for CTS case "EncodeVirtualDisplayWithCompositionTest "
        // Limit max recording resolution to 1280x720, if phone's ram <= 512MB
        if (memTotalBytes <= (512*1024*1024)) {
            if( (1==info.mIsEncoder)&& (OMX_VIDEO_AVCLevel4<=src.mLevel) )
            {
                ALOGD("skip once, memory may no be enough during large size video recording", src.mProfile, src.mLevel);
                continue;
            }
        }
#endif //ANDROID_DEFAULT_CODE
        profileLevels->push(profileLevel);
    }

    for (size_t i = 0; i < caps.mColorFormats.size(); ++i) {
#ifndef ANDROID_DEFAULT_CODE
    //for CTS case "com.android.cts.videoperf.VideoEncoderDecoderTest "
    //push one more format(YUV420) if there is under the decoding and with MTKBLK or MTKYV12 format
    if( (0==info.mIsEncoder)&&( OMX_COLOR_FormatVendorMTKYUV==caps.mColorFormats.itemAt(i) || 
        OMX_MTK_COLOR_FormatYV12==caps.mColorFormats.itemAt(i) || OMX_COLOR_FormatVendorMTKYUV_FCM==caps.mColorFormats.itemAt(i) ) )
    {
        colorFormats->push(OMX_COLOR_FormatYUV420Planar);
        ALOGI("itemAt(i) %x, isEncoder %d ", caps.mColorFormats.itemAt(i), info.mIsEncoder );
    }
#endif //ANDROID_DEFAULT_CODE
        colorFormats->push(caps.mColorFormats.itemAt(i));
    }

    *flags = caps.mFlags;
#ifndef ANDROID_DEFAULT_CODE
    ALOGI("[%s][ OK ] ",__FUNCTION__  );
#endif
    return OK;
}