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 import android.media.tv.tuner.Tuner;
23 
24 /**
25  * Filter configuration for a MMTP filter.
26  *
27  * @hide
28  */
29 @SystemApi
30 public final class MmtpFilterConfiguration extends FilterConfiguration {
31     private final int mMmtpPid;
32 
MmtpFilterConfiguration(Settings settings, int mmtpPid)33     private MmtpFilterConfiguration(Settings settings, int mmtpPid) {
34         super(settings);
35         mMmtpPid = mmtpPid;
36     }
37 
38     @Override
getType()39     public int getType() {
40         return Filter.TYPE_MMTP;
41     }
42 
43     /**
44      * Gets MMTP Packet ID.
45      *
46      * <p>Packet ID is used to specify packets in MMTP.
47      */
getMmtpPacketId()48     public int getMmtpPacketId() {
49         return mMmtpPid;
50     }
51 
52     /**
53      * Creates a builder for {@link MmtpFilterConfiguration}.
54      */
55     @NonNull
builder()56     public static Builder builder() {
57         return new Builder();
58     }
59 
60     /**
61      * Builder for {@link MmtpFilterConfiguration}.
62      */
63     public static final class Builder {
64         private int mMmtpPid = Tuner.INVALID_TS_PID;
65         private Settings mSettings;
66 
Builder()67         private Builder() {
68         }
69 
70         /**
71          * Sets MMTP Packet ID.
72          *
73          * <p>Default value is {@link Tuner#INVALID_TS_PID}.
74          */
75         @NonNull
setMmtpPacketId(int mmtpPid)76         public Builder setMmtpPacketId(int mmtpPid) {
77             mMmtpPid = mmtpPid;
78             return this;
79         }
80 
81         /**
82          * Sets filter settings.
83          */
84         @NonNull
setSettings(@ullable Settings settings)85         public Builder setSettings(@Nullable Settings settings) {
86             mSettings = settings;
87             return this;
88         }
89 
90         /**
91          * Builds a {@link IpFilterConfiguration} object.
92          */
93         @NonNull
build()94         public MmtpFilterConfiguration build() {
95             return new MmtpFilterConfiguration(mSettings, mMmtpPid);
96         }
97     }
98 }
99