-
Notifications
You must be signed in to change notification settings - Fork 257
/
MediaFile.java
361 lines (295 loc) · 7.91 KB
/
MediaFile.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
/**
* Copyright 2015-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0/
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package com.amazon.android.ads.vast.model.vast;
import com.amazon.android.ads.vast.model.vmap.VmapHelper;
import com.amazon.dynamicparser.impl.XmlParser;
import java.math.BigInteger;
import java.util.Map;
/**
* A representation of the MediaFile element of a VAST response.
*/
public class MediaFile {
/**
* Key to get the maintain aspect ratio attribute.
*/
private static final String MAINTAIN_ASPECT_RATIO_KEY = "maintainAspectRatio";
/**
* Key to get the height attribute.
*/
private static final String HEIGHT_KEY = "height";
/**
* Key to get the width attribute.
*/
private static final String WIDTH_KEY = "width";
/**
* Key to get the bitrate attribute.
*/
private static final String BITRATE_KEY = "bitrate";
/**
* Key to get the scalable attribute.
*/
private static final String SCALABLE_KEY = "scalable";
/**
* Key to get type attribute.
*/
private static final String TYPE_KEY = "type";
/**
* Key to get the delivery attribute.
*/
private static final String DELIVERY_KEY = "delivery";
/**
* Key to get the api framework attribute.
*/
private static final String API_FRAMEWORK_KEY = "apiFramework";
/**
* The ad URL value.
*/
private String mValue;
/**
* The id.
*/
private String mId;
/**
* The delivery protocol.
*/
private String mDelivery;
/**
* The MIME type for the file container.
*/
private String mType;
/**
* The average bitrate for the media file.
*/
private BigInteger mBitrate;
/**
* The native width of the video file, in pixels.
*/
private BigInteger mWidth;
/**
* The native height of the video file, in pixels.
*/
private BigInteger mHeight;
/**
* Whether the media file is meant to scale to larger dimensions.
*/
private boolean mScalable;
/**
* Whether the aspect ratio for media file dimensions should be maintained when scaled to
* larger dimensions.
*/
private boolean mMaintainAspectRatio;
/**
* The API needed to execute an interactive media file.
*/
private String mApiFramework;
/**
* Constructor.
*
* @param mediaFileMap A map containing the data needed to create the media file.
*/
public MediaFile(Map<String, Map> mediaFileMap) {
if (mediaFileMap != null) {
setValue(VmapHelper.getTextValueFromMap(mediaFileMap));
Map<String, String> attributes = mediaFileMap.get(XmlParser.ATTRIBUTES_TAG);
if (attributes != null) {
setId(attributes.get(VmapHelper.ID_KEY));
setDelivery(attributes.get(DELIVERY_KEY));
setType(attributes.get(TYPE_KEY));
setBitrate(BigInteger.valueOf(Long.valueOf(attributes.get(BITRATE_KEY))));
setWidth(BigInteger.valueOf(Long.valueOf(attributes.get(WIDTH_KEY))));
setHeight(BigInteger.valueOf(Long.valueOf(attributes.get(HEIGHT_KEY))));
setScalable(Boolean.valueOf(attributes.get(SCALABLE_KEY)));
setMaintainAspectRatio(Boolean.valueOf(attributes.get(MAINTAIN_ASPECT_RATIO_KEY)));
setApiFramework(attributes.get(API_FRAMEWORK_KEY));
}
}
}
/**
* Get the ad URL value.
*
* @return The value.
*/
public String getValue() {
return mValue;
}
/**
* Set the value.
*
* @param value The value.
*/
public void setValue(String value) {
mValue = value;
}
/**
* Get the id.
*
* @return The id.
*/
public String getId() {
return mId;
}
/**
* Set the id.
*
* @param id The id.
*/
public void setId(String id) {
mId = id;
}
/**
* Get the delivery.
*
* @return The delivery.
*/
public String getDelivery() {
return mDelivery;
}
/**
* Set the delivery.
*
* @param delivery The delivery.
*/
public void setDelivery(String delivery) {
mDelivery = delivery;
}
/**
* Get the type.
*
* @return The type.
*/
public String getType() {
return mType;
}
/**
* Set the type.
*
* @param type The type.
*/
public void setType(String type) {
mType = type;
}
/**
* Get the bitrate.
*
* @return The bitrate.
*/
public BigInteger getBitrate() {
return mBitrate;
}
/**
* Set the bitrate.
*
* @param bitrate The bitrate.
*/
public void setBitrate(BigInteger bitrate) {
mBitrate = bitrate;
}
/**
* Get the width.
*
* @return The width.
*/
public BigInteger getWidth() {
return mWidth;
}
/**
* Set the width.
*
* @param width The width.
*/
public void setWidth(BigInteger width) {
mWidth = width;
}
/**
* Get the height.
*
* @return The height.
*/
public BigInteger getHeight() {
return mHeight;
}
/**
* Set the height.
*
* @param height The height.
*/
public void setHeight(BigInteger height) {
mHeight = height;
}
/**
* Whether the media file is meant to scale to larger dimensions or not.
*
* @return True if it can be scaled, false otherwise.
*/
public boolean isScalable() {
return mScalable;
}
/**
* Set the scalable boolean.
*
* @param scalable True if its meant to be scaled, false otherwise.
*/
public void setScalable(boolean scalable) {
mScalable = scalable;
}
/**
* Whether the aspect ratio for media file dimensions should be maintained when scaled to new
* dimensions or not.
*
* @return True if the aspect ratio should be maintained, false otherwise.
*/
public boolean isMaintainAspectRatio() {
return mMaintainAspectRatio;
}
/**
* Set the maintain aspect ratio boolean.
*
* @param maintainAspectRatio True if the aspect ratio should be maintained, false otherwise.
*/
public void setMaintainAspectRatio(boolean maintainAspectRatio) {
mMaintainAspectRatio = maintainAspectRatio;
}
/**
* Get the API framework needed to execute an interactive media file.
*
* @return The API framework.
*/
public String getApiFramework() {
return mApiFramework;
}
/**
* Set the API framework needed to execute an interactive media file.
*
* @param apiFramework The API framework
*/
public void setApiFramework(String apiFramework) {
mApiFramework = apiFramework;
}
@Override
public String toString() {
return "MediaFile{" +
"mValue='" + mValue + '\'' +
", mId='" + mId + '\'' +
", mDelivery='" + mDelivery + '\'' +
", mType='" + mType + '\'' +
", mBitrate=" + mBitrate +
", mWidth=" + mWidth +
", mHeight=" + mHeight +
", mScalable=" + mScalable +
", mMaintainAspectRatio=" + mMaintainAspectRatio +
", mApiFramework='" + mApiFramework + '\'' +
'}';
}
}