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.SystemApi; 21 import android.media.tv.tuner.TunerUtils; 22 23 /** 24 * Filter Settings for a PES Data. 25 * 26 * @hide 27 */ 28 @SystemApi 29 public class PesSettings extends Settings { 30 private final int mStreamId; 31 private final boolean mIsRaw; 32 PesSettings(@ilter.Type int mainType, int streamId, boolean isRaw)33 private PesSettings(@Filter.Type int mainType, int streamId, boolean isRaw) { 34 super(TunerUtils.getFilterSubtype(mainType, Filter.SUBTYPE_PES)); 35 mStreamId = streamId; 36 mIsRaw = isRaw; 37 } 38 39 /** 40 * Gets stream ID. 41 */ getStreamId()42 public int getStreamId() { 43 return mStreamId; 44 } 45 46 /** 47 * Returns whether the data is raw. 48 * 49 * @return {@code true} if the data is raw. Filter sends onFilterStatus callback 50 * instead of onFilterEvent for raw data. {@code false} otherwise. 51 */ isRaw()52 public boolean isRaw() { 53 return mIsRaw; 54 } 55 56 /** 57 * Creates a builder for {@link PesSettings}. 58 * 59 * @param mainType the filter main type of the settings. 60 */ 61 @NonNull builder(@ilter.Type int mainType)62 public static Builder builder(@Filter.Type int mainType) { 63 return new Builder(mainType); 64 } 65 66 /** 67 * Builder for {@link PesSettings}. 68 */ 69 public static class Builder { 70 private final int mMainType; 71 private int mStreamId; 72 private boolean mIsRaw; 73 Builder(int mainType)74 private Builder(int mainType) { 75 mMainType = mainType; 76 } 77 78 /** 79 * Sets stream ID. 80 * 81 * @param streamId the stream ID. 82 */ 83 @NonNull setStreamId(int streamId)84 public Builder setStreamId(int streamId) { 85 mStreamId = streamId; 86 return this; 87 } 88 89 /** 90 * Sets whether the data is raw. 91 * 92 * @param isRaw {@code true} if the data is raw. Filter sends onFilterStatus callback 93 * instead of onFilterEvent for raw data. {@code false} otherwise. 94 */ 95 @NonNull setRaw(boolean isRaw)96 public Builder setRaw(boolean isRaw) { 97 mIsRaw = isRaw; 98 return this; 99 } 100 101 /** 102 * Builds a {@link PesSettings} object. 103 */ 104 @NonNull build()105 public PesSettings build() { 106 return new PesSettings(mMainType, mStreamId, mIsRaw); 107 } 108 } 109 } 110