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.filter;
18 
19 import android.annotation.NonNull;
20 import android.annotation.Nullable;
21 import android.annotation.SystemApi;
22 
23 /**
24  * Filter configuration for a TS filter.
25  *
26  * @hide
27  */
28 @SystemApi
29 public final class TsFilterConfiguration extends FilterConfiguration {
30     private final int mTpid;
31 
TsFilterConfiguration(Settings settings, int tpid)32     private TsFilterConfiguration(Settings settings, int tpid) {
33         super(settings);
34         mTpid = tpid;
35     }
36 
37     @Override
getType()38     public int getType() {
39         return Filter.TYPE_TS;
40     }
41 
42     /**
43      * Gets Tag Protocol ID.
44      */
getTpid()45     public int getTpid() {
46         return mTpid;
47     }
48 
49     /**
50      * Creates a builder for {@link TsFilterConfiguration}.
51      */
52     @NonNull
builder()53     public static Builder builder() {
54         return new Builder();
55     }
56 
57     /**
58      * Builder for {@link TsFilterConfiguration}.
59      */
60     public static final class Builder {
61         private int mTpid = 0;
62         private Settings mSettings;
63 
Builder()64         private Builder() {
65         }
66 
67         /**
68          * Sets Tag Protocol ID.
69          *
70          * <p>Default value is 0.
71          *
72          * @param tpid the Tag Protocol ID.
73          */
74         @NonNull
setTpid(int tpid)75         public Builder setTpid(int tpid) {
76             mTpid = tpid;
77             return this;
78         }
79 
80         /**
81          * Sets filter settings.
82          */
83         @NonNull
setSettings(@ullable Settings settings)84         public Builder setSettings(@Nullable Settings settings) {
85             mSettings = settings;
86             return this;
87         }
88 
89         /**
90          * Builds a {@link TsFilterConfiguration} object.
91          */
92         @NonNull
build()93         public TsFilterConfiguration build() {
94             return new TsFilterConfiguration(mSettings, mTpid);
95         }
96     }
97 }
98