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; 18 19 import android.annotation.BytesLong; 20 import android.annotation.IntDef; 21 import android.annotation.NonNull; 22 import android.annotation.Size; 23 import android.annotation.SystemApi; 24 import android.media.tv.tuner.filter.Filter; 25 import android.media.tv.tuner.filter.FilterConfiguration; 26 27 import java.lang.annotation.Retention; 28 import java.lang.annotation.RetentionPolicy; 29 30 /** 31 * Capabilities info for Demux. 32 * 33 * @hide 34 */ 35 @SystemApi 36 public class DemuxCapabilities { 37 38 /** @hide */ 39 @IntDef(flag = true, prefix = { "TYPE_" }, value = { 40 Filter.TYPE_UNDEFINED, 41 Filter.TYPE_TS, 42 Filter.TYPE_MMTP, 43 Filter.TYPE_IP, 44 Filter.TYPE_TLV, 45 Filter.TYPE_ALP, 46 }) 47 @Retention(RetentionPolicy.SOURCE) 48 public @interface FilterCapabilities {} 49 50 private final int mDemuxCount; 51 private final int mRecordCount; 52 private final int mPlaybackCount; 53 private final int mTsFilterCount; 54 private final int mSectionFilterCount; 55 private final int mAudioFilterCount; 56 private final int mVideoFilterCount; 57 private final int mPesFilterCount; 58 private final int mPcrFilterCount; 59 private final long mSectionFilterLength; 60 private final @FilterCapabilities int mFilterCaps; 61 private final @FilterCapabilities int[] mFilterCapsList; 62 private final int[] mLinkCaps; 63 private final boolean mSupportTimeFilter; 64 65 // Used by JNI DemuxCapabilities(int demuxCount, int recordCount, int playbackCount, int tsFilterCount, int sectionFilterCount, int audioFilterCount, int videoFilterCount, int pesFilterCount, int pcrFilterCount, long sectionFilterLength, int filterCaps, @FilterCapabilities int[] filterCapsList, @FilterCapabilities int[] linkCaps, boolean timeFilter)66 private DemuxCapabilities(int demuxCount, int recordCount, int playbackCount, int tsFilterCount, 67 int sectionFilterCount, int audioFilterCount, int videoFilterCount, int pesFilterCount, 68 int pcrFilterCount, long sectionFilterLength, int filterCaps, 69 @FilterCapabilities int[] filterCapsList, @FilterCapabilities int[] linkCaps, 70 boolean timeFilter) { 71 mDemuxCount = demuxCount; 72 mRecordCount = recordCount; 73 mPlaybackCount = playbackCount; 74 mTsFilterCount = tsFilterCount; 75 mSectionFilterCount = sectionFilterCount; 76 mAudioFilterCount = audioFilterCount; 77 mVideoFilterCount = videoFilterCount; 78 mPesFilterCount = pesFilterCount; 79 mPcrFilterCount = pcrFilterCount; 80 mSectionFilterLength = sectionFilterLength; 81 mFilterCaps = filterCaps; 82 mFilterCapsList = filterCapsList; 83 mLinkCaps = linkCaps; 84 mSupportTimeFilter = timeFilter; 85 } 86 87 /** 88 * Gets total number of demuxes. 89 */ getDemuxCount()90 public int getDemuxCount() { 91 return mDemuxCount; 92 } 93 /** 94 * Gets max number of recordings at a time. 95 */ getRecordCount()96 public int getRecordCount() { 97 return mRecordCount; 98 } 99 /** 100 * Gets max number of playbacks at a time. 101 */ getPlaybackCount()102 public int getPlaybackCount() { 103 return mPlaybackCount; 104 } 105 /** 106 * Gets number of TS filters. 107 */ getTsFilterCount()108 public int getTsFilterCount() { 109 return mTsFilterCount; 110 } 111 /** 112 * Gets number of section filters. 113 */ getSectionFilterCount()114 public int getSectionFilterCount() { 115 return mSectionFilterCount; 116 } 117 /** 118 * Gets number of audio filters. 119 */ getAudioFilterCount()120 public int getAudioFilterCount() { 121 return mAudioFilterCount; 122 } 123 /** 124 * Gets number of video filters. 125 */ getVideoFilterCount()126 public int getVideoFilterCount() { 127 return mVideoFilterCount; 128 } 129 /** 130 * Gets number of PES filters. 131 */ getPesFilterCount()132 public int getPesFilterCount() { 133 return mPesFilterCount; 134 } 135 /** 136 * Gets number of PCR filters. 137 */ getPcrFilterCount()138 public int getPcrFilterCount() { 139 return mPcrFilterCount; 140 } 141 /** 142 * Gets number of bytes in the mask of a section filter. 143 */ 144 @BytesLong getSectionFilterLength()145 public long getSectionFilterLength() { 146 return mSectionFilterLength; 147 } 148 /** 149 * Gets filter capabilities in bit field. 150 * 151 * <p>The bits of the returned value is corresponding to the types in 152 * {@link FilterConfiguration}. 153 */ 154 @FilterCapabilities getFilterCapabilities()155 public int getFilterCapabilities() { 156 return mFilterCaps; 157 } 158 159 /** 160 * Gets the list of filter main type capabilities in bit field. 161 * 162 * <p>Each element in the returned array represents the supported filter main types 163 * represented as bitwise OR of the types in {@link FilterConfiguration}. 164 * <p>Whereas getFilterCapabilities() returns the bitwise OR value of all the supported filter 165 * types in the system, this API returns a list of supported filter types in the system with 166 * each entry representing the supported filter types per demux resource. 167 * 168 * @return an array of supported filter main types for the demux resources in the system 169 * an empty array should be returned for devices with Tuner HAL version 2 and below 170 */ 171 @FilterCapabilities 172 @NonNull getFilterTypeCapabilityList()173 public int[] getFilterTypeCapabilityList() { 174 return mFilterCapsList; 175 } 176 177 /** 178 * Gets link capabilities. 179 * 180 * <p>The returned array contains the same elements as the number of types in 181 * {@link FilterConfiguration}. 182 * <p>The ith element represents the filter's capability as the source for the ith type. 183 */ 184 @NonNull 185 @Size(5) getLinkCapabilities()186 public int[] getLinkCapabilities() { 187 return mLinkCaps; 188 } 189 /** 190 * Is {@link android.media.tv.tuner.filter.TimeFilter} supported. 191 */ isTimeFilterSupported()192 public boolean isTimeFilterSupported() { 193 return mSupportTimeFilter; 194 } 195 } 196