Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 354d1b5d authored by Arun Johnson's avatar Arun Johnson
Browse files

Returning camcoder profiles for advanced codecs

 - Advanced codecs are returned only upon "advance" request,
   which is gated by the Target SDK version.

   if "advanced" codecs are requested, the return will contain both
   advanced and non-advanced codecs.
   If "advanced" codecs are not requested, the return will contain only
   non-advanced codecs.

Bug: 223439995
Change-Id: Ib85dc0e5ebb29e9dba7b7efb69c38429a2c9fa9f
parent 43ac9617
Loading
Loading
Loading
Loading
+19 −12
Original line number Original line Diff line number Diff line
@@ -255,21 +255,21 @@ android_media_MediaProfiles_native_get_camcorder_profiles(JNIEnv *env, jobject /
    jmethodID audioProfileConstructorMethodID =
    jmethodID audioProfileConstructorMethodID =
        env->GetMethodID(audioProfileClazz, "<init>", "(IIIII)V");
        env->GetMethodID(audioProfileClazz, "<init>", "(IIIII)V");


    jobjectArray videoCodecs = (jobjectArray)env->NewObjectArray(
    jobjectArray videoCodecs = nullptr;
            cp->getVideoCodecs().size(), videoProfileClazz, nullptr);
    {
    {
        int i = 0;
        auto isAdvancedCodec = [](const MediaProfiles::VideoCodec *vc) -> bool {
                                  return ((vc->getBitDepth() != 8
                                        || vc->getChromaSubsampling() != CHROMA_SUBSAMPLING_YUV_420
                                        || vc->getHdrFormat() != HDR_FORMAT_NONE));
                              };
        std::vector<jobject> codecVector;
        for (const MediaProfiles::VideoCodec *vc : cp->getVideoCodecs()) {
        for (const MediaProfiles::VideoCodec *vc : cp->getVideoCodecs()) {
            if (isAdvancedCodec(vc) && !static_cast<bool>(advanced)) {
                continue;
            }
            chroma_subsampling cs = vc->getChromaSubsampling();
            chroma_subsampling cs = vc->getChromaSubsampling();
            int bitDepth = vc->getBitDepth();
            int bitDepth = vc->getBitDepth();
            hdr_format hdr = vc->getHdrFormat();
            hdr_format hdr = vc->getHdrFormat();

            bool isAdvanced =
                (bitDepth != 8 || cs != CHROMA_SUBSAMPLING_YUV_420 || hdr != HDR_FORMAT_NONE);
            if (static_cast<bool>(advanced) && !isAdvanced) {
                continue;
            }

            jobject videoCodec = env->NewObject(videoProfileClazz,
            jobject videoCodec = env->NewObject(videoProfileClazz,
                                                videoProfileConstructorMethodID,
                                                videoProfileConstructorMethodID,
                                                vc->getCodec(),
                                                vc->getCodec(),
@@ -281,10 +281,17 @@ android_media_MediaProfiles_native_get_camcorder_profiles(JNIEnv *env, jobject /
                                                static_cast<int>(cs),
                                                static_cast<int>(cs),
                                                bitDepth,
                                                bitDepth,
                                                static_cast<int>(hdr));
                                                static_cast<int>(hdr));
            env->SetObjectArrayElement(videoCodecs, i++, videoCodec);

        }
            codecVector.push_back(videoCodec);
        }
        }
        videoCodecs = (jobjectArray)env->NewObjectArray(codecVector.size(),
                                                        videoProfileClazz, nullptr);


        int i = 0;
        for (jobject codecObj : codecVector) {
             env->SetObjectArrayElement(videoCodecs, i++, codecObj);
        }
    }
    jobjectArray audioCodecs;
    jobjectArray audioCodecs;
    if (quality >= CAMCORDER_QUALITY_TIME_LAPSE_LIST_START
    if (quality >= CAMCORDER_QUALITY_TIME_LAPSE_LIST_START
            && quality <= CAMCORDER_QUALITY_TIME_LAPSE_LIST_END) {
            && quality <= CAMCORDER_QUALITY_TIME_LAPSE_LIST_END) {