aboutsummaryrefslogtreecommitdiff
path: root/src/com/android/tv/tuner/TunerHal.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android/tv/tuner/TunerHal.java')
-rw-r--r--src/com/android/tv/tuner/TunerHal.java43
1 files changed, 30 insertions, 13 deletions
diff --git a/src/com/android/tv/tuner/TunerHal.java b/src/com/android/tv/tuner/TunerHal.java
index de19766e..64394ea3 100644
--- a/src/com/android/tv/tuner/TunerHal.java
+++ b/src/com/android/tv/tuner/TunerHal.java
@@ -20,6 +20,9 @@ import android.content.Context;
import android.support.annotation.IntDef;
import android.support.annotation.StringDef;
import android.util.Log;
+import android.util.Pair;
+
+import com.android.tv.Features;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@@ -48,6 +51,7 @@ public abstract class TunerHal implements AutoCloseable {
public static final int TUNER_TYPE_BUILT_IN = 1;
public static final int TUNER_TYPE_USB = 2;
+ public static final int TUNER_TYPE_NETWORK = 3;
protected static final int PID_PAT = 0;
protected static final int PID_ATSC_SI_BASE = 0x1ffb;
@@ -69,31 +73,33 @@ public abstract class TunerHal implements AutoCloseable {
*/
public synchronized static TunerHal createInstance(Context context) {
TunerHal tunerHal = null;
- if (getTunerType(context) == TUNER_TYPE_BUILT_IN) {
+ if (useBuiltInTuner(context)) {
}
- if (tunerHal == null) {
+ if (tunerHal == null && UsbTunerHal.getNumberOfDevices(context) > 0) {
tunerHal = new UsbTunerHal(context);
}
- if (tunerHal.openFirstAvailable()) {
- return tunerHal;
- }
- return null;
+ return tunerHal != null && tunerHal.openFirstAvailable() ? tunerHal : null;
}
/**
* Gets the number of tuner devices currently present.
*/
- public static int getTunerCount(Context context) {
- if (getTunerType(context) == TUNER_TYPE_BUILT_IN) {
+ public static Pair<Integer, Integer> getTunerTypeAndCount(Context context) {
+ if (useBuiltInTuner(context)) {
}
- return UsbTunerHal.getNumberOfDevices(context);
+ int usbTunerCount = UsbTunerHal.getNumberOfDevices(context);
+ if (usbTunerCount > 0) {
+ return new Pair<>(TUNER_TYPE_USB, usbTunerCount);
+ }
+ return new Pair<>(null, 0);
}
/**
- * Gets the type of tuner devices currently used.
+ * Returns if tuner input service would use built-in tuners instead of USB tuners or network
+ * tuners.
*/
- public static int getTunerType(Context context) {
- return TUNER_TYPE_USB;
+ static boolean useBuiltInTuner(Context context) {
+ return false;
}
protected TunerHal(Context context) {
@@ -106,6 +112,14 @@ public abstract class TunerHal implements AutoCloseable {
return mIsStreaming;
}
+ /**
+ * Returns {@code true} if this tuner HAL can be reused to save tuning time between channels
+ * of the same frequency.
+ */
+ public boolean isReusable() {
+ return true;
+ }
+
@Override
protected void finalize() throws Throwable {
super.finalize();
@@ -131,9 +145,12 @@ public abstract class TunerHal implements AutoCloseable {
*
* @param frequency a frequency of the channel to tune to
* @param modulation a modulation method of the channel to tune to
+ * @param channelNumber channel number when channel number is already known. Some tuner HAL
+ * may use channelNumber instead of frequency for tune.
* @return {@code true} if the operation was successful, {@code false} otherwise
*/
- public synchronized boolean tune(int frequency, @ModulationType String modulation) {
+ public synchronized boolean tune(int frequency, @ModulationType String modulation,
+ String channelNumber) {
if (!isDeviceOpen()) {
Log.e(TAG, "There's no available device");
return false;