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.dvr; 18 19 import android.annotation.BytesLong; 20 import android.annotation.IntDef; 21 import android.annotation.NonNull; 22 import android.annotation.SystemApi; 23 import android.hardware.tv.tuner.V1_0.Constants; 24 import android.media.tv.tuner.filter.Filter; 25 26 import java.lang.annotation.Retention; 27 import java.lang.annotation.RetentionPolicy; 28 29 /** 30 * DVR settings used to configure {@link DvrPlayback} and {@link DvrRecorder}. 31 * 32 * @hide 33 */ 34 @SystemApi 35 public class DvrSettings { 36 37 /** @hide */ 38 @IntDef(prefix = "DATA_FORMAT_", 39 value = {DATA_FORMAT_TS, DATA_FORMAT_PES, DATA_FORMAT_ES, DATA_FORMAT_SHV_TLV}) 40 @Retention(RetentionPolicy.SOURCE) 41 public @interface DataFormat {} 42 43 /** 44 * Transport Stream. 45 */ 46 public static final int DATA_FORMAT_TS = Constants.DataFormat.TS; 47 /** 48 * Packetized Elementary Stream. 49 */ 50 public static final int DATA_FORMAT_PES = Constants.DataFormat.PES; 51 /** 52 * Elementary Stream. 53 */ 54 public static final int DATA_FORMAT_ES = Constants.DataFormat.ES; 55 /** 56 * TLV (type-length-value) Stream for SHV 57 */ 58 public static final int DATA_FORMAT_SHV_TLV = Constants.DataFormat.SHV_TLV; 59 60 61 @Filter.Status 62 private final int mStatusMask; 63 @BytesLong 64 private final long mLowThreshold; 65 @BytesLong 66 private final long mHighThreshold; 67 @BytesLong 68 private final long mPacketSize; 69 @DataFormat 70 private final int mDataFormat; 71 DvrSettings(@ilter.Status int statusMask, @BytesLong long lowThreshold, @BytesLong long highThreshold, @BytesLong long packetSize, @DataFormat int dataFormat)72 private DvrSettings(@Filter.Status int statusMask, @BytesLong long lowThreshold, 73 @BytesLong long highThreshold, @BytesLong long packetSize, @DataFormat int dataFormat) { 74 mStatusMask = statusMask; 75 mLowThreshold = lowThreshold; 76 mHighThreshold = highThreshold; 77 mPacketSize = packetSize; 78 mDataFormat = dataFormat; 79 } 80 81 /** 82 * Gets status mask. 83 */ 84 @Filter.Status getStatusMask()85 public int getStatusMask() { 86 return mStatusMask; 87 } 88 89 /** 90 * Gets low threshold in bytes. 91 */ 92 @BytesLong getLowThreshold()93 public long getLowThreshold() { 94 return mLowThreshold; 95 } 96 97 /** 98 * Sets high threshold in bytes. 99 */ 100 @BytesLong getHighThreshold()101 public long getHighThreshold() { 102 return mHighThreshold; 103 } 104 105 /** 106 * Gets packet size in bytes. 107 */ 108 @BytesLong getPacketSize()109 public long getPacketSize() { 110 return mPacketSize; 111 } 112 113 /** 114 * Gets data format. 115 */ 116 @DataFormat getDataFormat()117 public int getDataFormat() { 118 return mDataFormat; 119 } 120 121 /** 122 * Creates a builder for {@link DvrSettings}. 123 */ 124 @NonNull builder()125 public static Builder builder() { 126 return new Builder(); 127 } 128 129 /** 130 * Builder for {@link DvrSettings}. 131 */ 132 public static final class Builder { 133 private int mStatusMask; 134 private long mLowThreshold; 135 private long mHighThreshold; 136 private long mPacketSize; 137 @DataFormat 138 private int mDataFormat; 139 140 /** 141 * Sets status mask. 142 * 143 * <p>Use Filter.STATUS_ for {@link DvrRecorder} and DvrPlayback.STATUS_ for 144 * {@link DvrPlayback}. 145 * <p>If status mask is not set, no status is send to the listener. 146 */ 147 @NonNull setStatusMask(@ilter.Status int statusMask)148 public Builder setStatusMask(@Filter.Status int statusMask) { 149 this.mStatusMask = statusMask; 150 return this; 151 } 152 153 /** 154 * Sets low threshold in bytes. 155 */ 156 @NonNull setLowThreshold(@ytesLong long lowThreshold)157 public Builder setLowThreshold(@BytesLong long lowThreshold) { 158 this.mLowThreshold = lowThreshold; 159 return this; 160 } 161 162 /** 163 * Sets high threshold in bytes. 164 */ 165 @NonNull setHighThreshold(@ytesLong long highThreshold)166 public Builder setHighThreshold(@BytesLong long highThreshold) { 167 this.mHighThreshold = highThreshold; 168 return this; 169 } 170 171 /** 172 * Sets packet size in bytes. 173 */ 174 @NonNull setPacketSize(@ytesLong long packetSize)175 public Builder setPacketSize(@BytesLong long packetSize) { 176 this.mPacketSize = packetSize; 177 return this; 178 } 179 180 /** 181 * Sets data format. 182 */ 183 @NonNull setDataFormat(@ataFormat int dataFormat)184 public Builder setDataFormat(@DataFormat int dataFormat) { 185 this.mDataFormat = dataFormat; 186 return this; 187 } 188 189 /** 190 * Builds a {@link DvrSettings} object. 191 */ 192 @NonNull build()193 public DvrSettings build() { 194 return new DvrSettings( 195 mStatusMask, mLowThreshold, mHighThreshold, mPacketSize, mDataFormat); 196 } 197 } 198 } 199