• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2019 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package android.media.tv.tuner.frontend;
18 
19 import android.annotation.IntDef;
20 import android.annotation.IntRange;
21 import android.annotation.NonNull;
22 import android.annotation.SystemApi;
23 import android.hardware.tv.tuner.V1_0.Constants;
24 
25 import java.lang.annotation.Retention;
26 import java.lang.annotation.RetentionPolicy;
27 
28 /**
29  * Frontend settings for ATSC.
30  *
31  * @hide
32  */
33 @SystemApi
34 public class AtscFrontendSettings extends FrontendSettings {
35 
36     /** @hide */
37     @IntDef(flag = true,
38             prefix = "MODULATION_",
39             value = {MODULATION_UNDEFINED, MODULATION_AUTO, MODULATION_MOD_8VSB,
40                     MODULATION_MOD_16VSB})
41     @Retention(RetentionPolicy.SOURCE)
42     public @interface Modulation {}
43 
44     /**
45      * Modulation undefined.
46      */
47     public static final int MODULATION_UNDEFINED = Constants.FrontendAtscModulation.UNDEFINED;
48     /**
49      * Hardware is able to detect and set modulation automatically
50      */
51     public static final int MODULATION_AUTO = Constants.FrontendAtscModulation.AUTO;
52     /**
53      * 8VSB Modulation.
54      */
55     public static final int MODULATION_MOD_8VSB = Constants.FrontendAtscModulation.MOD_8VSB;
56     /**
57      * 16VSB Modulation.
58      */
59     public static final int MODULATION_MOD_16VSB = Constants.FrontendAtscModulation.MOD_16VSB;
60 
61 
62     private final int mModulation;
63 
AtscFrontendSettings(int frequency, int modulation)64     private AtscFrontendSettings(int frequency, int modulation) {
65         super(frequency);
66         mModulation = modulation;
67     }
68 
69     /**
70      * Gets Modulation.
71      */
72     @Modulation
getModulation()73     public int getModulation() {
74         return mModulation;
75     }
76 
77     /**
78      * Creates a builder for {@link AtscFrontendSettings}.
79      */
80     @NonNull
builder()81     public static Builder builder() {
82         return new Builder();
83     }
84 
85     /**
86      * Builder for {@link AtscFrontendSettings}.
87      */
88     public static class Builder {
89         private int mFrequency = 0;
90         private int mModulation = MODULATION_UNDEFINED;
91 
Builder()92         private Builder() {
93         }
94 
95         /**
96          * Sets frequency in Hz.
97          *
98          * <p>Default value is 0.
99          */
100         @NonNull
101         @IntRange(from = 1)
setFrequency(int frequency)102         public Builder setFrequency(int frequency) {
103             mFrequency = frequency;
104             return this;
105         }
106 
107         /**
108          * Sets Modulation.
109          *
110          * <p>Default value is {@link #MODULATION_UNDEFINED}.
111          */
112         @NonNull
setModulation(@odulation int modulation)113         public Builder setModulation(@Modulation int modulation) {
114             mModulation = modulation;
115             return this;
116         }
117 
118         /**
119          * Builds a {@link AtscFrontendSettings} object.
120          */
121         @NonNull
build()122         public AtscFrontendSettings build() {
123             return new AtscFrontendSettings(mFrequency, mModulation);
124         }
125     }
126 
127     @Override
getType()128     public int getType() {
129         return FrontendSettings.TYPE_ATSC;
130     }
131 }
132