1 /*
2  * Copyright (C) 2021 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;
18 
19 import android.annotation.NonNull;
20 import android.os.Parcel;
21 import android.os.Parcelable;
22 
23 /**
24  * A request for TS (transport stream) from broadcast signal.
25  */
26 public final class TsRequest extends BroadcastInfoRequest implements Parcelable {
27     private static final @TvInputManager.BroadcastInfoType int REQUEST_TYPE =
28             TvInputManager.BROADCAST_INFO_TYPE_TS;
29 
30     public static final @NonNull Parcelable.Creator<TsRequest> CREATOR =
31             new Parcelable.Creator<TsRequest>() {
32                 @Override
33                 public TsRequest createFromParcel(Parcel source) {
34                     source.readInt();
35                     return createFromParcelBody(source);
36                 }
37 
38                 @Override
39                 public TsRequest[] newArray(int size) {
40                     return new TsRequest[size];
41                 }
42             };
43 
44     private final int mTsPid;
45 
createFromParcelBody(@onNull Parcel in)46     static @NonNull TsRequest createFromParcelBody(@NonNull Parcel in) {
47         return new TsRequest(in);
48     }
49 
TsRequest(int requestId, @RequestOption int option, int tsPid)50     public TsRequest(int requestId, @RequestOption int option, int tsPid) {
51         super(REQUEST_TYPE, requestId, option);
52         mTsPid = tsPid;
53     }
54 
TsRequest(@onNull Parcel source)55     TsRequest(@NonNull Parcel source) {
56         super(REQUEST_TYPE, source);
57         mTsPid = source.readInt();
58     }
59 
60     /**
61      * Gets the packet identifier (PID) of the TS (transport stream).
62      */
getTsPid()63     public int getTsPid() {
64         return mTsPid;
65     }
66 
67     @Override
describeContents()68     public int describeContents() {
69         return 0;
70     }
71 
72     @Override
writeToParcel(@onNull Parcel dest, int flags)73     public void writeToParcel(@NonNull Parcel dest, int flags) {
74         super.writeToParcel(dest, flags);
75         dest.writeInt(mTsPid);
76     }
77 }
78