Merge "Add IptvFrontendCapabilities API, fix JNI typo"

This commit is contained in:
Sadiq Sada
2023-02-08 01:08:19 +00:00
committed by Android (Google) Code Review
4 changed files with 82 additions and 16 deletions

View File

@@ -8917,6 +8917,10 @@ 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 {
method @NonNull public static android.media.tv.tuner.frontend.IptvFrontendSettings.Builder builder();
method @IntRange(from=0) public long getBitrate();

View File

@@ -0,0 +1,42 @@
/*
* 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;
}
}

View File

@@ -1617,6 +1617,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);
@@ -1695,6 +1704,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;
}
@@ -3518,17 +3532,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,
};
@@ -3538,31 +3553,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;
}
@@ -3879,7 +3899,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);

View File

@@ -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 {