Add IPTV Support

Test: atest android.media.tv.tuner.cts
Bug: 263504906
Change-Id: I600935bf42e172def958227ee6e3c0e14ecb3a0c
This commit is contained in:
sadiqsada
2022-12-12 12:14:58 -08:00
parent 41b5bcc326
commit 39ea91b6b0
5 changed files with 539 additions and 2 deletions

View File

@@ -8574,6 +8574,7 @@ package android.media.tv.tuner.frontend {
field public static final int TYPE_DVBC = 4; // 0x4
field public static final int TYPE_DVBS = 5; // 0x5
field public static final int TYPE_DVBT = 6; // 0x6
field public static final int TYPE_IPTV = 11; // 0xb
field public static final int TYPE_ISDBS = 7; // 0x7
field public static final int TYPE_ISDBS3 = 8; // 0x8
field public static final int TYPE_ISDBT = 9; // 0x9
@@ -8684,6 +8685,60 @@ package android.media.tv.tuner.frontend {
field public static final int FRONTEND_STATUS_READINESS_UNSUPPORTED = 4; // 0x4
}
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();
method @NonNull @Size(min=4, max=16) public byte[] getDstIpAddress();
method public int getDstPort();
method @Nullable public android.media.tv.tuner.frontend.IptvFrontendSettingsFec getFec();
method public int getIgmp();
method public int getProtocol();
method @NonNull @Size(min=4, max=16) public byte[] getSrcIpAddress();
method public int getSrcPort();
method public int getType();
field public static final int IGMP_UNDEFINED = 0; // 0x0
field public static final int IGMP_V1 = 1; // 0x1
field public static final int IGMP_V2 = 2; // 0x2
field public static final int IGMP_V3 = 4; // 0x4
field public static final int PROTOCOL_RTP = 2; // 0x2
field public static final int PROTOCOL_UDP = 1; // 0x1
field public static final int PROTOCOL_UNDEFINED = 0; // 0x0
}
public static final class IptvFrontendSettings.Builder {
method @NonNull public android.media.tv.tuner.frontend.IptvFrontendSettings build();
method @NonNull public android.media.tv.tuner.frontend.IptvFrontendSettings.Builder setBitrate(@IntRange(from=0) long);
method @NonNull public android.media.tv.tuner.frontend.IptvFrontendSettings.Builder setContentUrl(@NonNull String);
method @NonNull public android.media.tv.tuner.frontend.IptvFrontendSettings.Builder setDstIpAddress(@NonNull byte[]);
method @NonNull public android.media.tv.tuner.frontend.IptvFrontendSettings.Builder setDstPort(int);
method @NonNull public android.media.tv.tuner.frontend.IptvFrontendSettings.Builder setFec(@Nullable android.media.tv.tuner.frontend.IptvFrontendSettingsFec);
method @NonNull public android.media.tv.tuner.frontend.IptvFrontendSettings.Builder setIgmp(int);
method @NonNull public android.media.tv.tuner.frontend.IptvFrontendSettings.Builder setProtocol(int);
method @NonNull public android.media.tv.tuner.frontend.IptvFrontendSettings.Builder setSrcIpAddress(@NonNull byte[]);
method @NonNull public android.media.tv.tuner.frontend.IptvFrontendSettings.Builder setSrcPort(int);
}
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();
method public int getFecType();
field public static final int FEC_TYPE_COLUMN = 1; // 0x1
field public static final int FEC_TYPE_COLUMN_ROW = 4; // 0x4
field public static final int FEC_TYPE_ROW = 2; // 0x2
field public static final int FEC_TYPE_UNDEFINED = 0; // 0x0
}
public static final class IptvFrontendSettingsFec.Builder {
method @NonNull public android.media.tv.tuner.frontend.IptvFrontendSettingsFec build();
method @NonNull public android.media.tv.tuner.frontend.IptvFrontendSettingsFec.Builder setFecColNum(@IntRange(from=0) int);
method @NonNull public android.media.tv.tuner.frontend.IptvFrontendSettingsFec.Builder setFecRowNum(@IntRange(from=0) int);
method @NonNull public android.media.tv.tuner.frontend.IptvFrontendSettingsFec.Builder setFecType(int);
}
public class Isdbs3FrontendCapabilities extends android.media.tv.tuner.frontend.FrontendCapabilities {
method public int getCodeRateCapability();
method public int getModulationCapability();

View File

@@ -1160,6 +1160,11 @@ public class Tuner implements AutoCloseable {
* in Tuner 2.0 or higher version. Unsupported version will cause no-op. Use {@link
* TunerVersionChecker#getTunerVersion()} to get the version information.
*
* <p>Tuning with {@link
* android.media.tv.tuner.frontend.IptvFrontendSettings} is only supported
* in Tuner 3.0 or higher version. Unsupported version will cause no-op. Use {@link
* TunerVersionChecker#getTunerVersion()} to get the version information.
*
* @param settings Signal delivery information the frontend uses to
* search and lock the signal.
* @return result status of tune operation.
@@ -1188,6 +1193,12 @@ public class Tuner implements AutoCloseable {
return RESULT_UNAVAILABLE;
}
}
if (mFrontendType == FrontendSettings.TYPE_IPTV) {
if (!TunerVersionChecker.checkHigherOrEqualVersionTo(
TunerVersionChecker.TUNER_VERSION_3_0, "Tuner with IPTV Frontend")) {
return RESULT_UNAVAILABLE;
}
}
if (checkResource(TunerResourceManager.TUNER_RESOURCE_TYPE_FRONTEND, mFrontendLock)) {
mFrontendInfo = null;

View File

@@ -38,7 +38,7 @@ public abstract class FrontendSettings {
/** @hide */
@IntDef(prefix = "TYPE_",
value = {TYPE_UNDEFINED, TYPE_ANALOG, TYPE_ATSC, TYPE_ATSC3, TYPE_DVBC, TYPE_DVBS,
TYPE_DVBT, TYPE_ISDBS, TYPE_ISDBS3, TYPE_ISDBT, TYPE_DTMB})
TYPE_DVBT, TYPE_ISDBS, TYPE_ISDBS3, TYPE_ISDBT, TYPE_DTMB, TYPE_IPTV})
@Retention(RetentionPolicy.SOURCE)
public @interface Type {}
@@ -86,7 +86,10 @@ public abstract class FrontendSettings {
* Digital Terrestrial Multimedia Broadcast standard (DTMB) frontend type.
*/
public static final int TYPE_DTMB = FrontendType.DTMB;
/**
* Internet Protocol (IPTV) frontend type.
*/
public static final int TYPE_IPTV = FrontendType.IPTV;
/** @hide */
@LongDef(prefix = "FEC_",

View File

@@ -0,0 +1,321 @@
/*
* Copyright 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.IntDef;
import android.annotation.IntRange;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.Size;
import android.annotation.SystemApi;
import android.hardware.tv.tuner.FrontendIptvSettingsIgmp;
import android.hardware.tv.tuner.FrontendIptvSettingsProtocol;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
/**
* Frontend settings for IPTV.
*
* @hide
*/
@SystemApi
public class IptvFrontendSettings extends FrontendSettings {
/** @hide */
@IntDef(prefix = "PROTOCOL_",
value = {PROTOCOL_UNDEFINED, PROTOCOL_UDP, PROTOCOL_RTP})
@Retention(RetentionPolicy.SOURCE)
public @interface Protocol {}
/**
* IP protocol type UNDEFINED.
*/
public static final int PROTOCOL_UNDEFINED = FrontendIptvSettingsProtocol.UNDEFINED;
/**
* IP protocol type UDP (User Datagram Protocol).
*/
public static final int PROTOCOL_UDP = FrontendIptvSettingsProtocol.UDP;
/**
* IP protocol type RTP (Real-time Transport Protocol).
*/
public static final int PROTOCOL_RTP = FrontendIptvSettingsProtocol.RTP;
/** @hide */
@IntDef(prefix = "IGMP_",
value = {IGMP_UNDEFINED, IGMP_V1, IGMP_V2, IGMP_V3})
@Retention(RetentionPolicy.SOURCE)
public @interface Igmp {}
/**
* IGMP (Internet Group Management Protocol) UNDEFINED.
*/
public static final int IGMP_UNDEFINED = FrontendIptvSettingsIgmp.UNDEFINED;
/**
* IGMP (Internet Group Management Protocol) V1.
*/
public static final int IGMP_V1 = FrontendIptvSettingsIgmp.V1;
/**
* IGMP (Internet Group Management Protocol) V2.
*/
public static final int IGMP_V2 = FrontendIptvSettingsIgmp.V2;
/**
* IGMP (Internet Group Management Protocol) V3.
*/
public static final int IGMP_V3 = FrontendIptvSettingsIgmp.V3;
private final byte[] mSrcIpAddress;
private final byte[] mDstIpAddress;
private final int mSrcPort;
private final int mDstPort;
private final IptvFrontendSettingsFec mFec;
private final int mProtocol;
private final int mIgmp;
private final long mBitrate;
private final String mContentUrl;
public IptvFrontendSettings(@NonNull byte[] srcIpAddress, @NonNull byte[] dstIpAddress,
int srcPort, int dstPort, @NonNull IptvFrontendSettingsFec fec, int protocol, int igmp,
long bitrate, @NonNull String contentUrl) {
super(0);
mSrcIpAddress = srcIpAddress;
mDstIpAddress = dstIpAddress;
mSrcPort = srcPort;
mDstPort = dstPort;
mFec = fec;
mProtocol = protocol;
mIgmp = igmp;
mBitrate = bitrate;
mContentUrl = contentUrl;
}
/**
* Gets the source IP address.
*/
@Size(min = 4, max = 16)
@NonNull
public byte[] getSrcIpAddress() {
return mSrcIpAddress;
}
/**
* Gets the destination IP address.
*/
@Size(min = 4, max = 16)
@NonNull
public byte[] getDstIpAddress() {
return mDstIpAddress;
}
/**
* Gets the source port.
*/
public int getSrcPort() {
return mSrcPort;
}
/**
* Gets the destination port.
*/
public int getDstPort() {
return mDstPort;
}
/**
* Gets FEC (Forward Error Correction).
*/
@Nullable
public IptvFrontendSettingsFec getFec() {
return mFec;
}
/**
* Gets the protocol.
*/
@Protocol
public int getProtocol() {
return mProtocol;
}
/**
* Gets the IGMP (Internet Group Management Protocol).
*/
@Igmp
public int getIgmp() {
return mIgmp;
}
/**
* Gets the bitrate.
*/
@IntRange(from = 0)
public long getBitrate() {
return mBitrate;
}
/**
* Gets the contentUrl
* contentUrl is a source URL in the format protocol://ip:port containing data
*/
@NonNull
public String getContentUrl() {
return mContentUrl;
}
/**
* Creates a builder for {@link IptvFrontendSettings}.
*/
@NonNull
public static Builder builder() {
return new Builder();
}
/**
* Builder for {@link IptvFrontendSettings}.
*/
public static final class Builder {
private byte[] mSrcIpAddress = {0, 0, 0, 0};
private byte[] mDstIpAddress = {0, 0, 0, 0};
private int mSrcPort = 0;
private int mDstPort = 0;
private IptvFrontendSettingsFec mFec = null;
private int mProtocol = FrontendIptvSettingsProtocol.UNDEFINED;
private int mIgmp = FrontendIptvSettingsIgmp.UNDEFINED;
private long mBitrate = 0;
private String mContentUrl = "";
private Builder() {
}
/**
* Sets the source IP address.
*
* <p>Default value is 0.0.0.0, an invalid IP address.
*/
@NonNull
public Builder setSrcIpAddress(@NonNull byte[] srcIpAddress) {
mSrcIpAddress = srcIpAddress;
return this;
}
/**
* Sets the destination IP address.
*
* <p>Default value is 0.0.0.0, an invalid IP address.
*/
@NonNull
public Builder setDstIpAddress(@NonNull byte[] dstIpAddress) {
mDstIpAddress = dstIpAddress;
return this;
}
/**
* Sets the source IP port.
*
* <p>Default value is 0.
*/
@NonNull
public Builder setSrcPort(int srcPort) {
mSrcPort = srcPort;
return this;
}
/**
* Sets the destination IP port.
*
* <p>Default value is 0.
*/
@NonNull
public Builder setDstPort(int dstPort) {
mDstPort = dstPort;
return this;
}
/**
* Sets the FEC (Forward Error Correction).
*
* <p>Default value is {@code null}.
*/
@NonNull
public Builder setFec(@Nullable IptvFrontendSettingsFec fec) {
mFec = fec;
return this;
}
/**
* Sets the protocol.
*
* <p>Default value is {@link #PROTOCOL_UNDEFINED}.
*/
@NonNull
public Builder setProtocol(@Protocol int protocol) {
mProtocol = protocol;
return this;
}
/**
* Sets the IGMP (Internet Group Management Protocol).
*
* <p>Default value is {@link #IGMP_UNDEFINED}.
*/
@NonNull
public Builder setIgmp(@Igmp int igmp) {
mIgmp = igmp;
return this;
}
/**
* Sets the bitrate.
*
* <p>Default value is 0.
*/
@NonNull
public Builder setBitrate(@IntRange(from = 0) long bitrate) {
mBitrate = bitrate;
return this;
}
/**
* Sets the contentUrl.
*
* <p>Default value is "".
*/
@NonNull
public Builder setContentUrl(@NonNull String contentUrl) {
mContentUrl = contentUrl;
return this;
}
/**
* Builds a {@link IptvFrontendSettings} object.
*/
@NonNull
public IptvFrontendSettings build() {
return new IptvFrontendSettings(mSrcIpAddress, mDstIpAddress, mSrcPort,
mDstPort, mFec, mProtocol, mIgmp, mBitrate, mContentUrl);
}
}
@Override
public int getType() {
return FrontendSettings.TYPE_IPTV;
}
}

View File

@@ -0,0 +1,147 @@
/*
* Copyright 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.IntDef;
import android.annotation.IntRange;
import android.annotation.NonNull;
import android.annotation.SystemApi;
import android.hardware.tv.tuner.FrontendIptvSettingsFecType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
/**
* FEC (Forward Error Correction) for IPTV.
*
* @hide
*/
@SystemApi
public class IptvFrontendSettingsFec {
/** @hide */
@IntDef(prefix = "FEC_TYPE_",
value = {FEC_TYPE_UNDEFINED, FEC_TYPE_COLUMN, FEC_TYPE_ROW, FEC_TYPE_COLUMN_ROW})
@Retention(RetentionPolicy.SOURCE)
public @interface FecType {}
/**
* FEC (Forward Error Correction) type UNDEFINED.
*/
public static final int FEC_TYPE_UNDEFINED = FrontendIptvSettingsFecType.UNDEFINED;
/**
* FEC (Forward Error Correction) type Column.
*/
public static final int FEC_TYPE_COLUMN = FrontendIptvSettingsFecType.COLUMN;
/**
* FEC (Forward Error Correction) type ROW.
*/
public static final int FEC_TYPE_ROW = FrontendIptvSettingsFecType.ROW;
/**
* FEC (Forward Error Correction) type Column Row.
*/
public static final int FEC_TYPE_COLUMN_ROW = FrontendIptvSettingsFecType.COLUMN_ROW;
private final int mFecType;
private final int mFecRowNum;
private final int mFecColNum;
public IptvFrontendSettingsFec(@FecType int fecType, int fecRowNum, int fecColNum) {
mFecType = fecType;
mFecRowNum = fecRowNum;
mFecColNum = fecColNum;
}
/**
* Gets the FEC (Forward Error Correction) type.
*/
@FecType
public int getFecType() {
return mFecType;
}
/**
* Get the FEC (Forward Error Correction) row number.
*/
@IntRange(from = 0)
public int getFecRowNum() {
return mFecRowNum;
}
/**
* Gets the FEC (Forward Error Correction) column number.
*/
@IntRange(from = 0)
public int getFecColNum() {
return mFecColNum;
}
/**
* Creates a builder for {@link IptvFrontendSettingsFec}.
*/
@NonNull
public static Builder builder() {
return new Builder();
}
/**
* Builder for {@link IptvFrontendSettingsFec}.
*/
public static final class Builder {
private int mFecType;
private int mFecRowNum;
private int mFecColNum;
private Builder() {
}
/**
* Sets the FEC (Forward Error Correction) type
*/
@NonNull
public Builder setFecType(@FecType int fecType) {
mFecType = fecType;
return this;
}
/**
* Sets the FEC (Forward Error Correction) row number.
*/
@NonNull
public Builder setFecRowNum(@IntRange(from = 0) int fecRowNum) {
mFecRowNum = fecRowNum;
return this;
}
/**
* Sets the FEC (Forward Error Correction) column number.
*/
@NonNull
public Builder setFecColNum(@IntRange(from = 0) int fecColNum) {
mFecColNum = fecColNum;
return this;
}
/**
* Builds a {@link IptvFrontendSettingsFec} object.
*/
@NonNull
public IptvFrontendSettingsFec build() {
return new IptvFrontendSettingsFec(mFecType, mFecRowNum, mFecColNum);
}
}
}