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.BytesLong; 20 import android.annotation.SystemApi; 21 22 23 /** 24 * Filter event sent from {@link Filter} objects for TS record data. 25 * 26 * @hide 27 */ 28 @SystemApi 29 public class TsRecordEvent extends FilterEvent { 30 31 private final int mPid; 32 private final int mTsIndexMask; 33 private final int mScIndexMask; 34 private final long mDataLength; 35 private final long mPts; 36 private final int mFirstMbInSlice; 37 38 // This constructor is used by JNI code only TsRecordEvent(int pid, int tsIndexMask, int scIndexMask, long dataLength, long pts, int firstMbInSlice)39 private TsRecordEvent(int pid, int tsIndexMask, int scIndexMask, long dataLength, long pts, 40 int firstMbInSlice) { 41 mPid = pid; 42 mTsIndexMask = tsIndexMask; 43 mScIndexMask = scIndexMask; 44 mDataLength = dataLength; 45 mPts = pts; 46 mFirstMbInSlice = firstMbInSlice; 47 } 48 49 /** 50 * Gets packet ID. 51 */ getPacketId()52 public int getPacketId() { 53 return mPid; 54 } 55 56 /** 57 * Gets TS (transport stream) index mask. 58 */ 59 @RecordSettings.TsIndexMask getTsIndexMask()60 public int getTsIndexMask() { 61 return mTsIndexMask; 62 } 63 /** 64 * Gets SC (Start Code) index mask. 65 * 66 * <p>The index type is SC or SC-HEVC, and is set when configuring the filter. 67 */ 68 @RecordSettings.ScIndexMask getScIndexMask()69 public int getScIndexMask() { 70 return mScIndexMask; 71 } 72 73 /** 74 * Gets the record data offset from the beginning of the record buffer. 75 */ 76 @BytesLong getDataLength()77 public long getDataLength() { 78 return mDataLength; 79 } 80 81 /** 82 * Gets the Presentation Time Stamp(PTS) for the audio or video frame. It is based on 90KHz 83 * and has the same format as the PTS in ISO/IEC 13818-1. 84 * 85 * <p>This field is only supported in Tuner 1.1 or higher version. Unsupported version will 86 * return {@link android.media.tv.tuner.Tuner#INVALID_TIMESTAMP}. Use 87 * {@link android.media.tv.tuner.TunerVersionChecker#getTunerVersion()} to get the version 88 * information. 89 */ getPts()90 public long getPts() { 91 return mPts; 92 } 93 94 /** 95 * Get the address of the first macroblock in the slice defined in ITU-T Rec. H.264. 96 * 97 * <p>This field is only supported in Tuner 1.1 or higher version. Unsupported version will 98 * return {@link android.media.tv.tuner.Tuner#INVALID_FIRST_MACROBLOCK_IN_SLICE}. Use 99 * {@link android.media.tv.tuner.TunerVersionChecker#getTunerVersion()} to get the version 100 * information. 101 */ getFirstMacroblockInSlice()102 public int getFirstMacroblockInSlice() { 103 return mFirstMbInSlice; 104 } 105 } 106