• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2024 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;
18 
19 import android.annotation.FlaggedApi;
20 import android.annotation.NonNull;
21 import android.media.tv.flags.Flags;
22 import android.os.Parcelable;
23 
24 import java.lang.annotation.Retention;
25 import java.lang.annotation.RetentionPolicy;
26 
27 /**
28  * Describes a metadata object of a {@link SignalingDataResponse}.
29  */
30 @FlaggedApi(Flags.FLAG_TIAF_V_APIS)
31 public final class SignalingDataInfo implements Parcelable {
32     public static final @NonNull Parcelable.Creator<SignalingDataInfo> CREATOR =
33             new Parcelable.Creator<SignalingDataInfo>() {
34                 @Override
35                 public SignalingDataInfo[] newArray(int size) {
36                     return new SignalingDataInfo[size];
37                 }
38 
39                 @Override
40                 public SignalingDataInfo createFromParcel(@NonNull android.os.Parcel in) {
41                     return new SignalingDataInfo(in);
42                 }
43             };
44 
45     private final @NonNull String mTable;
46     private final @NonNull @SignalingDataRequest.SignalingMetadata String mSignalingDataType;
47     private final int mVersion;
48     private final int mGroup;
49     private final @NonNull String mEncoding;
50 
51     /**
52      * This value for {@link #getGroup()} denotes that there's no group associated with this
53      * metadata.
54      */
55     public static final int LLS_NO_GROUP_ID = -1;
56 
57     /**
58      * The encoding of the content is UTF-8. This is the default value.
59      */
60     public static final String CONTENT_ENCODING_UTF_8 = "UTF-8";
61 
62     /**
63      *  A/344:2023-5 9.2.10 compliant string for when the encoding of the content is Base64.
64      */
65     public static final String CONTENT_ENCODING_BASE64 = "Base64";
66 
67     /**
68      * @hide
69      */
70     @android.annotation.StringDef(prefix = "CONTENT_ENCODING_", value = {
71             CONTENT_ENCODING_UTF_8,
72             CONTENT_ENCODING_BASE64
73     })
74     @Retention(RetentionPolicy.SOURCE)
75     public @interface ContentEncoding {}
76 
SignalingDataInfo( @onNull String table, @NonNull String signalingDataType, int version, int group)77     public SignalingDataInfo(
78             @NonNull String table,
79             @NonNull String signalingDataType,
80             int version,
81             int group) {
82         this.mTable = table;
83         com.android.internal.util.AnnotationValidations.validate(NonNull.class, null, mTable);
84         this.mSignalingDataType = signalingDataType;
85         this.mVersion = version;
86         this.mGroup = group;
87         this.mEncoding = CONTENT_ENCODING_UTF_8;
88     }
89 
SignalingDataInfo( @onNull String table, @NonNull String signalingDataType, int version, int group, @NonNull String encoding)90     public SignalingDataInfo(
91             @NonNull String table,
92             @NonNull String signalingDataType,
93             int version,
94             int group,
95             @NonNull String encoding) {
96         this.mTable = table;
97         com.android.internal.util.AnnotationValidations.validate(NonNull.class, null, mTable);
98         this.mSignalingDataType = signalingDataType;
99         this.mVersion = version;
100         this.mGroup = group;
101         this.mEncoding = encoding;
102         com.android.internal.util.AnnotationValidations.validate(NonNull.class, null, mEncoding);
103     }
104 
105     /**
106      * The signaling table data, represented as a XML, JSON or BASE64 string.
107      *
108      * <p> For more details on how this data is formatted refer to the ATSC standard
109      * A/344:2023-5 9.2.10 - Query Signaling Data API.
110      *
111      * @return The signaling table data.
112      */
113     @NonNull
getTable()114     public String getTable() {
115         return mTable;
116     }
117 
118     /**
119      * Gets the signaling data type contained in this metadata object. This may be either a
120      * LLS Metadata Object or a SLS Metadata Object name.
121      *
122      * <p>For more details on each type of metadata that can be requested, refer to the ATSC
123      * standard A/344:2023-5 9.2.10 - Query Signaling Data API.
124      *
125      * @return the type of metadata in this metadata object
126      */
127     @NonNull
getSignalingDataType()128     public @SignalingDataRequest.SignalingMetadata String getSignalingDataType() {
129         return mSignalingDataType;
130     }
131 
132     /**
133      * Gets the version of the signalling element. For LLS, this should be the
134      * LLS_table_version. For SLS Metadata Objects, this should be metadataEnvelope@version.
135      *
136      * For more details on where this version comes from, refer to the ATSC 3.0
137      * standard A/344:2023-5 9.2.10 - Query Signaling Data API.
138      *
139      * @return The version of the signalling element.
140      */
getVersion()141     public int getVersion() {
142         return mVersion;
143     }
144 
145     /**
146      * Gets the LLS group ID. Required for LLS Tables. For SLS Metadata Objects, this should be
147      * {@link #LLS_NO_GROUP_ID}.
148      *
149      * @return the LLS group ID.
150      */
getGroup()151     public int getGroup() {
152         return mGroup;
153     }
154 
155     /**
156      * The content encoding of the data. This value defaults to {@link #CONTENT_ENCODING_UTF_8}.
157      *
158      * <p> Can be either {@link #CONTENT_ENCODING_BASE64} or {@link #CONTENT_ENCODING_UTF_8}.
159      * @return The content encoding of the data.
160      */
161     @NonNull
getEncoding()162     public @ContentEncoding String getEncoding() {
163         return mEncoding;
164     }
165 
166     @Override
writeToParcel(@onNull android.os.Parcel dest, int flags)167     public void writeToParcel(@NonNull android.os.Parcel dest, int flags) {
168         dest.writeString(mTable);
169         dest.writeString(mSignalingDataType);
170         dest.writeInt(mVersion);
171         dest.writeInt(mGroup);
172         dest.writeString(mEncoding);
173     }
174 
175     @Override
describeContents()176     public int describeContents() {
177         return 0;
178     }
179 
SignalingDataInfo(@onNull android.os.Parcel in)180     SignalingDataInfo(@NonNull android.os.Parcel in) {
181         String table = in.readString();
182         String metadataType = in.readString();
183         int version = in.readInt();
184         int group = in.readInt();
185         String encoding = in.readString();
186 
187         this.mTable = table;
188         com.android.internal.util.AnnotationValidations.validate(NonNull.class, null, mTable);
189         this.mSignalingDataType = metadataType;
190         com.android.internal.util.AnnotationValidations
191                 .validate(NonNull.class, null, mSignalingDataType);
192         this.mVersion = version;
193         this.mGroup = group;
194         this.mEncoding = encoding;
195         com.android.internal.util.AnnotationValidations.validate(NonNull.class, null, mEncoding);
196     }
197 }
198