aboutsummaryrefslogtreecommitdiff
path: root/tuner/src/com/android/tv/tuner/api/Tuner.java
blob: 02df3ca1a30a8ee7363a56246da6a151051a913f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
/*
 * Copyright (C) 2018 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 com.android.tv.tuner.api;

import android.support.annotation.IntDef;
import android.support.annotation.StringDef;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;

/** A interface a hardware tuner device. */
public interface Tuner extends AutoCloseable {

    int FILTER_TYPE_OTHER = 0;
    int FILTER_TYPE_AUDIO = 1;
    int FILTER_TYPE_VIDEO = 2;
    int FILTER_TYPE_PCR = 3;
    String MODULATION_8VSB = "8VSB";
    String MODULATION_QAM16 = "QAM16";
    String MODULATION_QAM64 = "QAM64";
    String MODULATION_QAM256 = "QAM256";
    int DELIVERY_SYSTEM_UNDEFINED = 0;
    int DELIVERY_SYSTEM_ATSC = 1;
    int DELIVERY_SYSTEM_DVBC = 2;
    int DELIVERY_SYSTEM_DVBS = 3;
    int DELIVERY_SYSTEM_DVBS2 = 4;
    int DELIVERY_SYSTEM_DVBT = 5;
    int DELIVERY_SYSTEM_DVBT2 = 6;
    int TUNER_TYPE_BUILT_IN = 1;
    int TUNER_TYPE_USB = 2;
    int TUNER_TYPE_NETWORK = 3;
    int BUILT_IN_TUNER_TYPE_LINUX_DVB = 1;
    int BUILT_IN_TUNER_TYPE_ARCHER = 100;

    /** Check a delivery system is for DVB or not. */
    static boolean isDvbDeliverySystem(@DeliverySystemType int deliverySystemType) {
        return deliverySystemType == DELIVERY_SYSTEM_DVBC
                || deliverySystemType == DELIVERY_SYSTEM_DVBS
                || deliverySystemType == DELIVERY_SYSTEM_DVBS2
                || deliverySystemType == DELIVERY_SYSTEM_DVBT
                || deliverySystemType == DELIVERY_SYSTEM_DVBT2;
    }

    boolean isReusable();

    /**
     * Acquires the first available tuner device. If there is a tuner device that is available, the
     * tuner device will be locked to the current instance.
     *
     * @return {@code true} if the operation was successful, {@code false} otherwise
     */
    boolean openFirstAvailable();

    boolean isDeviceOpen();

    long getDeviceId();

    boolean tune(int frequency, @ModulationType String modulation, String channelNumber);

    default boolean tune(@DeliverySystemType int deliverySystemType, int frequency,
                 @ModulationType String modulation, String channelNumber) {
      return tune(frequency, modulation, channelNumber);
    }

    boolean addPidFilter(int pid, @FilterType int filterType);

    void stopTune();

    void setHasPendingTune(boolean hasPendingTune);

    int getDeliverySystemType();
    default int[] getDeliverySystemTypes() {
      int[] deliverySystemTypes = {DELIVERY_SYSTEM_UNDEFINED};
      return deliverySystemTypes;
    };

    int readTsStream(byte[] javaBuffer, int javaBufferSize);

    int getSignalStrength();

    /** Filter type */
    @IntDef({FILTER_TYPE_OTHER, FILTER_TYPE_AUDIO, FILTER_TYPE_VIDEO, FILTER_TYPE_PCR})
    @Retention(RetentionPolicy.SOURCE)
    public @interface FilterType {}

    /** Modulation Type */
    @StringDef({MODULATION_8VSB, MODULATION_QAM256, MODULATION_QAM16, MODULATION_QAM64})
    @Retention(RetentionPolicy.SOURCE)
    public @interface ModulationType {}

    /** Delivery System Type */
    @IntDef({
        DELIVERY_SYSTEM_UNDEFINED,
        DELIVERY_SYSTEM_ATSC,
        DELIVERY_SYSTEM_DVBC,
        DELIVERY_SYSTEM_DVBS,
        DELIVERY_SYSTEM_DVBS2,
        DELIVERY_SYSTEM_DVBT,
        DELIVERY_SYSTEM_DVBT2
    })
    @Retention(RetentionPolicy.SOURCE)
    public @interface DeliverySystemType {}

    /** Tuner Type */
    @IntDef({TUNER_TYPE_BUILT_IN, TUNER_TYPE_USB, TUNER_TYPE_NETWORK})
    @Retention(RetentionPolicy.SOURCE)
    public @interface TunerType {}

    /** Built in tuner type */
    @IntDef({
        BUILT_IN_TUNER_TYPE_ARCHER,
        BUILT_IN_TUNER_TYPE_LINUX_DVB
    })
    @Retention(RetentionPolicy.SOURCE)
    public @interface BuiltInTunerType {}
}