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 Section from broadcast signal. 25 */ 26 public final class SectionRequest extends BroadcastInfoRequest implements Parcelable { 27 private static final @TvInputManager.BroadcastInfoType int REQUEST_TYPE = 28 TvInputManager.BROADCAST_INFO_TYPE_SECTION; 29 30 public static final @NonNull Parcelable.Creator<SectionRequest> CREATOR = 31 new Parcelable.Creator<SectionRequest>() { 32 @Override 33 public SectionRequest createFromParcel(Parcel source) { 34 source.readInt(); 35 return createFromParcelBody(source); 36 } 37 38 @Override 39 public SectionRequest[] newArray(int size) { 40 return new SectionRequest[size]; 41 } 42 }; 43 44 private final int mTsPid; 45 private final int mTableId; 46 private final int mVersion; 47 createFromParcelBody(Parcel in)48 static SectionRequest createFromParcelBody(Parcel in) { 49 return new SectionRequest(in); 50 } 51 SectionRequest(int requestId, @RequestOption int option, int tsPid, int tableId, int version)52 public SectionRequest(int requestId, @RequestOption int option, int tsPid, int tableId, 53 int version) { 54 super(REQUEST_TYPE, requestId, option); 55 mTsPid = tsPid; 56 mTableId = tableId; 57 mVersion = version; 58 } 59 SectionRequest(Parcel source)60 SectionRequest(Parcel source) { 61 super(REQUEST_TYPE, source); 62 mTsPid = source.readInt(); 63 mTableId = source.readInt(); 64 mVersion = source.readInt(); 65 } 66 67 /** 68 * Gets the packet identifier (PID) of the TS (transport stream). 69 */ getTsPid()70 public int getTsPid() { 71 return mTsPid; 72 } 73 74 /** 75 * Gets the ID of the requested table. 76 */ getTableId()77 public int getTableId() { 78 return mTableId; 79 } 80 81 /** 82 * Gets the version number of requested session. If it is null, value will be -1. 83 * <p>The consistency of version numbers between request and response depends on 84 * {@link BroadcastInfoRequest.RequestOption}. If the request has RequestOption value 85 * REQUEST_OPTION_AUTO_UPDATE, then the response may be set to the latest version which may be 86 * different from the version of the request. Otherwise, response with a different version from 87 * its request will be considered invalid. 88 */ getVersion()89 public int getVersion() { 90 return mVersion; 91 } 92 93 @Override describeContents()94 public int describeContents() { 95 return 0; 96 } 97 98 @Override writeToParcel(@onNull Parcel dest, int flags)99 public void writeToParcel(@NonNull Parcel dest, int flags) { 100 super.writeToParcel(dest, flags); 101 dest.writeInt(mTsPid); 102 dest.writeInt(mTableId); 103 dest.writeInt(mVersion); 104 } 105 } 106