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.IntRange;
20 import android.annotation.SystemApi;
21 
22 /**
23  * Filter event sent from {@link Filter} objects with download type.
24  *
25  * @hide
26  */
27 @SystemApi
28 public class DownloadEvent extends FilterEvent {
29     private final int mItemId;
30     private final int mDownloadId;
31     private final int mMpuSequenceNumber;
32     private final int mItemFragmentIndex;
33     private final int mLastItemFragmentIndex;
34     private final int mDataLength;
35 
36     // This constructor is used by JNI code only
DownloadEvent(int itemId, int downloadId, int mpuSequenceNumber, int itemFragmentIndex, int lastItemFragmentIndex, int dataLength)37     private DownloadEvent(int itemId, int downloadId, int mpuSequenceNumber, int itemFragmentIndex,
38             int lastItemFragmentIndex, int dataLength) {
39         mItemId = itemId;
40         mDownloadId = downloadId;
41         mMpuSequenceNumber = mpuSequenceNumber;
42         mItemFragmentIndex = itemFragmentIndex;
43         mLastItemFragmentIndex = lastItemFragmentIndex;
44         mDataLength = dataLength;
45     }
46 
47     /**
48      * Gets item ID.
49      */
getItemId()50     public int getItemId() {
51         return mItemId;
52     }
53 
54     /**
55      * Gets download ID.
56      *
57      * <p>This query is only supported in Tuner 2.0 or higher version. Unsupported version will
58      * return {@code -1}.
59      * Use {@link TunerVersionChecker#getTunerVersion()} to get the version information.
60      */
getDownloadId()61     public int getDownloadId() { return mDownloadId; }
62 
63     /**
64      * Gets MPU sequence number of filtered data.
65      */
66     @IntRange(from = 0)
getMpuSequenceNumber()67     public int getMpuSequenceNumber() {
68         return mMpuSequenceNumber;
69     }
70 
71     /**
72      * Gets current index of the current item.
73      *
74      * An item can be stored in different fragments.
75      */
getItemFragmentIndex()76     public int getItemFragmentIndex() {
77         return mItemFragmentIndex;
78     }
79 
80     /**
81      * Gets last index of the current item.
82      */
getLastItemFragmentIndex()83     public int getLastItemFragmentIndex() {
84         return mLastItemFragmentIndex;
85     }
86 
87     /**
88      * Gets data size in bytes of filtered data.
89      */
getDataLength()90     public int getDataLength() {
91         return mDataLength;
92     }
93 }
94