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

Commit c5486deb authored by sadiqsada's avatar sadiqsada
Browse files

Add IptvFrontendCapabilities API, fix JNI typo

Test: atest TunerTest.java#testFrontendStatus,
testFrontendStatusReadiness,testRequestFrontendThenTune,
testMultiTuning
Bug: 266967059

Change-Id: I275238f9235b4ae2f2c114b1d52b954ea2f3846f
parent dbe67576
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -8910,8 +8910,11 @@ package android.media.tv.tuner.frontend {
    field public static final int FRONTEND_STATUS_READINESS_UNSUPPORTED = 4; // 0x4
  }
  public class IptvFrontendCapabilities extends android.media.tv.tuner.frontend.FrontendCapabilities {
    method public int getProtocolCapability();
  }
  public class IptvFrontendSettings extends android.media.tv.tuner.frontend.FrontendSettings {
    ctor public IptvFrontendSettings(@NonNull byte[], @NonNull byte[], int, int, @NonNull android.media.tv.tuner.frontend.IptvFrontendSettingsFec, int, int, long, @NonNull String);
    method @NonNull public static android.media.tv.tuner.frontend.IptvFrontendSettings.Builder builder();
    method @IntRange(from=0) public long getBitrate();
    method @NonNull public String getContentUrl();
@@ -8946,7 +8949,6 @@ package android.media.tv.tuner.frontend {
  }
  public class IptvFrontendSettingsFec {
    ctor public IptvFrontendSettingsFec(int, int, int);
    method @NonNull public static android.media.tv.tuner.frontend.IptvFrontendSettingsFec.Builder builder();
    method @IntRange(from=0) public int getFecColNum();
    method @IntRange(from=0) public int getFecRowNum();
+42 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2023 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.media.tv.tuner.frontend;

import android.annotation.SystemApi;

/**
 * IPTV Capabilities.
 *
 * @hide
 */
@SystemApi
public class IptvFrontendCapabilities extends FrontendCapabilities {
    private final int mProtocolCap;

    // Used by native code
    private IptvFrontendCapabilities(int protocolCap) {
        mProtocolCap = protocolCap;
    }

    /**
     * Gets the protocols of IPTV transmission (UDP/RTP) defined in
     * {@link IptvFrontendSettings}.
     */
    public int getProtocolCapability() {
        return mProtocolCap;
    }
}
+35 −16
Original line number Diff line number Diff line
@@ -1591,6 +1591,15 @@ jobject JTuner::getDtmbFrontendCaps(JNIEnv *env, FrontendCapabilities &caps) {
            interleaveModeCap, codeRateCap, bandwidthCap);
}

jobject JTuner::getIptvFrontendCaps(JNIEnv *env, FrontendCapabilities &caps) {
    jclass clazz = env->FindClass("android/media/tv/tuner/frontend/IptvFrontendCapabilities");
    jmethodID capsInit = env->GetMethodID(clazz, "<init>", "(I)V");

    jint protocolCap = caps.get<FrontendCapabilities::Tag::iptvCaps>()->protocolCap;

    return env->NewObject(clazz, capsInit, protocolCap);
}

jobject JTuner::getFrontendInfo(int id) {
    shared_ptr<FrontendInfo> feInfo;
    feInfo = sTunerClient->getFrontendInfo(id);
@@ -1669,6 +1678,11 @@ jobject JTuner::getFrontendInfo(int id) {
                jcaps = getDtmbFrontendCaps(env, caps);
            }
            break;
        case FrontendType::IPTV:
            if (FrontendCapabilities::Tag::iptvCaps == caps.getTag()) {
                jcaps = getIptvFrontendCaps(env, caps);
            }
            break;
        default:
            break;
    }
@@ -3492,17 +3506,18 @@ static DemuxIpAddress getDemuxIpAddress(JNIEnv *env, const jobject& config, cons

static FrontendIptvSettingsFec getIptvFrontendSettingsFec(JNIEnv *env, const jobject &settings) {
    jclass clazz = env->FindClass("android/media/tv/tuner/frontend/IptvFrontendSettings");
    jobject fec = env->GetObjectField(settings, env->GetFieldID(clazz, "mFec",
            "[Landroid/media/tv/tuner/frontend/IptvFrontendSettingsFec;"));
    jclass fecClazz = env->FindClass("android/media/tv/tuner/frontend/IptvFrontendSettingsFec");
    FrontendIptvSettingsFecType fecType =
    jobject fec = env->GetObjectField(settings, env->GetFieldID(clazz, "mFec",
            "Landroid/media/tv/tuner/frontend/IptvFrontendSettingsFec;"));

    FrontendIptvSettingsFecType type =
            static_cast<FrontendIptvSettingsFecType>(
                    env->GetIntField(fec, env->GetFieldID(fecClazz, "mFec", "I")));
                    env->GetIntField(fec, env->GetFieldID(fecClazz, "mFecType", "I")));
    int32_t fecColNum = env->GetIntField(fec, env->GetFieldID(fecClazz, "mFecColNum", "I"));
    int32_t fecRowNum = env->GetIntField(fec, env->GetFieldID(fecClazz, "mFecRowNum", "I"));

    FrontendIptvSettingsFec frontendIptvSettingsFec {
        .type = fecType,
    FrontendIptvSettingsFec frontendIptvSettingsFec = {
        .type = type,
        .fecColNum = fecColNum,
        .fecRowNum = fecRowNum,
    };
@@ -3512,31 +3527,36 @@ static FrontendIptvSettingsFec getIptvFrontendSettingsFec(JNIEnv *env, const job

static FrontendSettings getIptvFrontendSettings(JNIEnv *env, const jobject &settings) {
    FrontendSettings frontendSettings;
    const char *clazzName = "android/media/tv/tuner/frontend/IptvFrontendSettings";
    jclass clazz = env->FindClass(clazzName);
    const char *className = "android/media/tv/tuner/frontend/IptvFrontendSettings";
    jclass clazz = env->FindClass(className);
    FrontendIptvSettingsProtocol protocol =
            static_cast<FrontendIptvSettingsProtocol>(
                    env->GetIntField(settings, env->GetFieldID(clazz, "mProtocol", "I")));
    FrontendIptvSettingsIgmp igmp =
            static_cast<FrontendIptvSettingsIgmp>(
                    env->GetIntField(settings, env->GetFieldID(clazz, "mIgmp", "I")));
    FrontendIptvSettingsFec fec = getIptvFrontendSettingsFec(env, settings);
    int64_t bitrate = env->GetIntField(settings, env->GetFieldID(clazz, "mBitrate", "J"));
    jstring contentUrlJString = (jstring) env->GetObjectField(settings, env->GetFieldID(
                                clazz, "mContentUrl",
                                "[Landroid/media/tv/tuner/frontend/IptvFrontendSettings;"));
    const char *contentUrl = env->GetStringUTFChars(contentUrlJString, 0);
    DemuxIpAddress ipAddr = getDemuxIpAddress(env, settings, clazzName);
    jstring jContentUrl = (jstring) env->GetObjectField(settings, env->GetFieldID(
                                clazz, "mContentUrl", "Ljava/lang/String;"));
    const char *contentUrl = env->GetStringUTFChars(jContentUrl, 0);
    DemuxIpAddress ipAddr = getDemuxIpAddress(env, settings, className);

    FrontendIptvSettings frontendIptvSettings{
            .protocol = protocol,
            .fec = fec,
            .igmp = igmp,
            .bitrate = bitrate,
            .ipAddr = ipAddr,
            .contentUrl = contentUrl,
    };

    jobject jFec = env->GetObjectField(settings, env->GetFieldID(clazz, "mFec",
            "Landroid/media/tv/tuner/frontend/IptvFrontendSettingsFec;"));
    if (jFec != nullptr) {
        frontendIptvSettings.fec = getIptvFrontendSettingsFec(env, settings);
    }

    frontendSettings.set<FrontendSettings::Tag::iptv>(frontendIptvSettings);
    env->ReleaseStringUTFChars(jContentUrl, contentUrl);
    return frontendSettings;
}

@@ -3853,7 +3873,6 @@ static jobject android_media_tv_Tuner_open_lnb_by_name(JNIEnv *env, jobject thiz
    return tuner->openLnbByName(name);
}


static jobject android_media_tv_Tuner_open_filter(
        JNIEnv *env, jobject thiz, jint type, jint subType, jlong bufferSize) {
    sp<JTuner> tuner = getTuner(env, thiz);
+1 −0
Original line number Diff line number Diff line
@@ -236,6 +236,7 @@ private:
    static jobject getIsdbsFrontendCaps(JNIEnv* env, FrontendCapabilities& caps);
    static jobject getIsdbtFrontendCaps(JNIEnv* env, FrontendCapabilities& caps);
    static jobject getDtmbFrontendCaps(JNIEnv* env, FrontendCapabilities& caps);
    static jobject getIptvFrontendCaps(JNIEnv* env, FrontendCapabilities& caps);
};

class C2DataIdInfo : public C2Param {