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.IntRange; 21 import android.annotation.SystemApi; 22 import android.media.tv.tuner.filter.RecordSettings.ScHevcIndex; 23 24 /** 25 * Filter event sent from {@link Filter} objects with MPEG media Transport Protocol(MMTP) type. 26 * 27 * @hide 28 */ 29 @SystemApi 30 public class MmtpRecordEvent extends FilterEvent { 31 private final int mScHevcIndexMask; 32 private final long mDataLength; 33 private final int mMpuSequenceNumber; 34 private final long mPts; 35 private final int mFirstMbInSlice; 36 private final int mTsIndexMask; 37 38 // This constructor is used by JNI code only MmtpRecordEvent(int scHevcIndexMask, long dataLength, int mpuSequenceNumber, long pts, int firstMbInSlice, int tsIndexMask)39 private MmtpRecordEvent(int scHevcIndexMask, long dataLength, int mpuSequenceNumber, long pts, 40 int firstMbInSlice, int tsIndexMask) { 41 mScHevcIndexMask = scHevcIndexMask; 42 mDataLength = dataLength; 43 mMpuSequenceNumber = mpuSequenceNumber; 44 mPts = pts; 45 mFirstMbInSlice = firstMbInSlice; 46 mTsIndexMask = tsIndexMask; 47 } 48 49 /** 50 * Gets indexes which can be tagged by NAL unit group in HEVC according to ISO/IEC 23008-2. 51 */ 52 @ScHevcIndex getScHevcIndexMask()53 public int getScHevcIndexMask() { 54 return mScHevcIndexMask; 55 } 56 57 /** 58 * Gets the record data offset from the beginning of the record buffer. 59 */ 60 @BytesLong getDataLength()61 public long getDataLength() { 62 return mDataLength; 63 } 64 65 /** 66 * Get the MPU sequence number of the filtered data. 67 * 68 * <p>This field is only supported in Tuner 1.1 or higher version. Unsupported version will 69 * return {@link android.media.tv.tuner.Tuner#INVALID_MMTP_RECORD_EVENT_MPT_SEQUENCE_NUM}. Use 70 * {@link android.media.tv.tuner.TunerVersionChecker#getTunerVersion()} to get the version 71 * information. 72 */ 73 @IntRange(from = 0) getMpuSequenceNumber()74 public int getMpuSequenceNumber() { 75 return mMpuSequenceNumber; 76 } 77 78 /** 79 * Get the Presentation Time Stamp(PTS) for the audio or video frame. It is based on 90KHz 80 * and has the same format as the PTS in ISO/IEC 13818-1. 81 * 82 * <p>This field is only supported in Tuner 1.1 or higher version. Unsupported version will 83 * return {@link android.media.tv.tuner.Tuner#INVALID_TIMESTAMP}. Use 84 * {@link android.media.tv.tuner.TunerVersionChecker#getTunerVersion()} to get the version 85 * information. 86 */ getPts()87 public long getPts() { 88 return mPts; 89 } 90 91 /** 92 * Get the address of the first macroblock in the slice defined in ITU-T Rec. H.264. 93 * 94 * <p>This field is only supported in Tuner 1.1 or higher version. Unsupported version will 95 * return {@link android.media.tv.tuner.Tuner#INVALID_FIRST_MACROBLOCK_IN_SLICE}. Use 96 * {@link android.media.tv.tuner.TunerVersionChecker#getTunerVersion()} to get the version 97 * information. 98 */ getFirstMacroblockInSlice()99 public int getFirstMacroblockInSlice() { 100 return mFirstMbInSlice; 101 } 102 103 /** 104 * Get the offset of the recorded keyframe from MMT Packet Table. 105 * 106 * <p>This field is only supported in Tuner 1.1 or higher version. Unsupported version will 107 * return {@link RecordSettings#TS_INDEX_INVALID}. Use 108 * {@link android.media.tv.tuner.TunerVersionChecker#getTunerVersion()} to get the 109 * version information. 110 */ 111 @RecordSettings.TsIndexMask getTsIndexMask()112 public int getTsIndexMask() { 113 return mTsIndexMask; 114 } 115 } 116