summaryrefslogtreecommitdiffstats
path: root/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/videoeditor/MediaPropertiesTest.java
blob: 34cf9f0aceb8b869bb16601e9008012ea2c272a8 (plain)
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
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
/*
 * Copyright (C) 2011 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License 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.android.mediaframeworktest.functional.videoeditor;

import java.io.File;
import java.io.IOException;

import android.media.videoeditor.AudioTrack;
import android.media.videoeditor.MediaImageItem;
import android.media.videoeditor.MediaItem;
import android.media.videoeditor.MediaProperties;
import android.media.videoeditor.MediaVideoItem;
import android.media.videoeditor.VideoEditor;
import android.os.Environment;
import android.test.ActivityInstrumentationTestCase;
import android.test.suitebuilder.annotation.LargeTest;
import com.android.mediaframeworktest.MediaFrameworkTest;
import com.android.mediaframeworktest.VideoEditorHelper;
import com.android.mediaframeworktest.MediaProfileReader;

public class MediaPropertiesTest extends
    ActivityInstrumentationTestCase<MediaFrameworkTest> {
    private final String TAG = "MediaPropertiesTest";

    private final String PROJECT_LOCATION = VideoEditorHelper.PROJECT_LOCATION_COMMON;

    private final String INPUT_FILE_PATH = VideoEditorHelper.INPUT_FILE_PATH_COMMON;

    private VideoEditor mVideoEditor;

    private VideoEditorHelper mVideoEditorHelper;

    public MediaPropertiesTest() {
        super("com.android.mediaframeworktest", MediaFrameworkTest.class);
    }

    @Override
    protected void setUp() throws Exception {
        // setup for each test case.
        super.setUp();
        mVideoEditorHelper = new VideoEditorHelper();
        // Create a random String which will be used as project path,
        // where all project related files will be stored.
        final String projectPath = mVideoEditorHelper.
            createRandomFile(PROJECT_LOCATION);
        mVideoEditor = mVideoEditorHelper.createVideoEditor(projectPath);
    }

    @Override
    protected void tearDown() throws Exception {
        mVideoEditorHelper.destroyVideoEditor(mVideoEditor);
        // Clean the directory created as project path
        mVideoEditorHelper.deleteProject(new File(mVideoEditor.getPath()));
        System.gc();
        super.tearDown();
    }

    protected void validateVideoProperties(int aspectRatio, int fileType,
        int videoCodecType, int duration, int videoBitrate, int fps,
        int videoProfile, int videoLevel, int width, int height, int audioCodecType,
        int audioSamplingFrequency, int audioChannel, int audioBitrate,
        MediaVideoItem mvi) throws Exception {
        assertEquals("Aspect Ratio Mismatch", aspectRatio, mvi.getAspectRatio());
        assertEquals("File Type Mismatch", fileType, mvi.getFileType());
        assertEquals("VideoCodec Mismatch", videoCodecType, mvi.getVideoType());

        assertTrue("Video duration Mismatch", mVideoEditorHelper.checkRange (
            duration, mvi.getDuration(), 10));
        assertEquals("Video Profile " + mvi.getVideoProfile(), videoProfile,
            mvi.getVideoProfile());
        assertEquals("Video Level " + mvi.getVideoLevel(), videoLevel,
            mvi.getVideoLevel());
        assertEquals("Video height " + mvi.getHeight(), height, mvi.getHeight());
        assertEquals("Video width " + mvi.getWidth(), width, mvi.getWidth());
        /** Check FPS with 10% range */
        assertTrue("fps Mismatch" + mvi.getFps(),
            mVideoEditorHelper.checkRange(fps, mvi.getFps(), 10));

        assertEquals("AudioType Mismatch ", audioCodecType, mvi.getAudioType());
        assertEquals("Audio Sampling " + mvi.getAudioSamplingFrequency(),
            audioSamplingFrequency, mvi.getAudioSamplingFrequency());
        // PV SW AAC codec always returns number of channels as Stereo.
        // So we do not assert for number of audio channels for AAC_LC
        if ( audioCodecType != MediaProperties.ACODEC_AAC_LC ) {
            assertEquals("Audio Channels " + mvi.getAudioChannels(), audioChannel,
                mvi.getAudioChannels());
        }
    }

    protected void validateAudioProperties(int audioCodecType, int duration,
        int audioSamplingFrequency, int audioChannel, int audioBitrate,
        AudioTrack aT) throws Exception {
        assertEquals("AudioType Mismatch ", audioCodecType, aT.getAudioType());
        assertTrue("Video duration Mismatch", mVideoEditorHelper.checkRange (
            duration, aT.getDuration(), 10));
        assertEquals("Audio Sampling " + aT.getAudioSamplingFrequency(),
            audioSamplingFrequency, aT.getAudioSamplingFrequency());
        // PV SW AAC codec always returns number of channels as Stereo.
        // So we do not assert for number of audio channels for AAC_LC
        if ( audioCodecType != MediaProperties.ACODEC_AAC_LC ) {
            assertEquals("Audio Channels " + aT.getAudioChannels(), audioChannel,
                aT.getAudioChannels());
        }
    }

    protected void validateImageProperties(int aspectRatio, int fileType,
        int width, int height, MediaImageItem mii)
        throws Exception {
        assertEquals("Aspect Ratio Mismatch", aspectRatio, mii.getAspectRatio());
        assertEquals("File Type Mismatch", fileType, mii.getFileType());
        assertEquals("Image height " + mii.getHeight(), height, mii.getHeight());
        assertEquals("Image width " + mii.getWidth(), width, mii.getWidth());
    }


    /**
     *To test Media Properties for file MPEG4 854 x 480
     */
    @LargeTest
    public void testPropertiesMPEG4854_480() throws Exception {
        final String videoItemFilename = INPUT_FILE_PATH
            + "MPEG4_SP_854x480_15fps_256kbps_AACLC_16khz_48kbps_s_0_26.mp4";
        final int aspectRatio = MediaProperties.ASPECT_RATIO_16_9;
        final int fileType = MediaProperties.FILE_MP4;
        final int videoCodecType = MediaProperties.VCODEC_MPEG4;
        final int duration = 26933;
        final int videoBitrate = 319000;
        final int audioBitrate = 48000;
        final int fps = 15;
        final int audioCodecType = MediaProperties.ACODEC_AAC_LC;
        final int audioSamplingFrequency = 16000;
        final int audioChannel = 2;
        final int videoProfile = MediaProperties.MPEG4Profile.MPEG4ProfileSimple;
        final int videoLevel = MediaProperties.MPEG4Level.MPEG4Level1;
        final int width = 854;
        final int height = MediaProperties.HEIGHT_480;

        final MediaVideoItem mvi = mVideoEditorHelper.createMediaItem
            (mVideoEditor, "m1", videoItemFilename,
            MediaItem.RENDERING_MODE_BLACK_BORDER);

        validateVideoProperties(aspectRatio, fileType, videoCodecType, duration,
            videoBitrate, fps, videoProfile, videoLevel, width, height, audioCodecType,
            audioSamplingFrequency, audioChannel, audioBitrate, mvi);
    }


    /**
     *To test Media Properties for file MPEG4 WVGA
     */
    @LargeTest
    public void testPropertiesMPEGWVGA() throws Exception {
        final String videoItemFilename = INPUT_FILE_PATH
            + "MPEG4_SP_800x480_515kbps_15fps_AMR_NB_8KHz_12.2kbps_m_0_26.mp4";
        final int aspectRatio = MediaProperties.ASPECT_RATIO_5_3;
        final int fileType = MediaProperties.FILE_MP4;
        final int videoCodecType = MediaProperties.VCODEC_MPEG4;
        final int duration = 26933;
        final int videoBitrate = 384000;
        final int audioBitrate = 12800;
        final int fps = 15;
        final int audioCodecType = MediaProperties.ACODEC_AMRNB;
        final int audioSamplingFrequency = 8000;
        final int audioChannel = 1;
        final int videoProfile = MediaProperties.MPEG4Profile.MPEG4ProfileSimple;
        final int videoLevel = MediaProperties.MPEG4Level.MPEG4Level1;
        final int width = 800;
        final int height = MediaProperties.HEIGHT_480;
        final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;

        final MediaVideoItem mvi = mVideoEditorHelper.createMediaItem
            (mVideoEditor, "m1", videoItemFilename, renderingMode);

        validateVideoProperties(aspectRatio, fileType, videoCodecType, duration,
            videoBitrate, fps, videoProfile, videoLevel, width, height, audioCodecType,
            audioSamplingFrequency, audioChannel, audioBitrate, mvi);
    }

    /**
     *To test media properties for MPEG4 720x480 (NTSC) + AAC file.
     */
    @LargeTest
    public void testPropertiesMPEGNTSC() throws Exception {
        final String videoItemFilename = INPUT_FILE_PATH
            + "MPEG4_SP_720x480_30fps_280kbps_AACLC_48kHz_161kbps_s_0_26.mp4";
        final int aspectRatio = MediaProperties.ASPECT_RATIO_3_2;
        final int fileType = MediaProperties.FILE_MP4;
        final int videoCodecType = MediaProperties.VCODEC_MPEG4;
        final int duration = 26866;
        final int videoBitrate = 403000;
        final int audioBitrate = 160000;
        final int fps = 30;
        final int audioCodecType = MediaProperties.ACODEC_AAC_LC;
        final int audioSamplingFrequency = 48000;
        final int audioChannel = 2;
        final int videoProfile = MediaProperties.MPEG4Profile.MPEG4ProfileSimple;
        final int videoLevel = MediaProperties.MPEG4Level.MPEG4Level1;
        final int width = 720;
        final int height = MediaProperties.HEIGHT_480;
        final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;

        final MediaVideoItem mvi = mVideoEditorHelper.createMediaItem
            (mVideoEditor, "m1", videoItemFilename, renderingMode);

        validateVideoProperties(aspectRatio, fileType, videoCodecType, duration,
            videoBitrate, fps, videoProfile, videoLevel, width, height, audioCodecType,
            audioSamplingFrequency, audioChannel, audioBitrate, mvi);
    }

    /**
     *To test Media Properties for file MPEG4 VGA
     */
    @LargeTest
    public void testPropertiesMPEGVGA() throws Exception {
        final String videoItemFilename = INPUT_FILE_PATH
            + "MPEG4_SP_640x480_15fps_512kbps_AACLC_48khz_132kbps_s_0_26.mp4";
        final int aspectRatio = MediaProperties.ASPECT_RATIO_4_3;
        final int fileType = MediaProperties.FILE_MP4;
        final int videoCodecType = MediaProperties.VCODEC_MPEG4;
        final int duration = 26933;
        final int videoBitrate = 533000;
        final int audioBitrate = 128000;
        final int fps = 15;
        final int audioCodecType = MediaProperties.ACODEC_AAC_LC;
        final int audioSamplingFrequency = 48000;
        final int audioChannel = 2;
        final int videoProfile = MediaProperties.MPEG4Profile.MPEG4ProfileSimple;
        final int videoLevel = MediaProperties.MPEG4Level.MPEG4Level1;
        final int width = 640;
        final int height = MediaProperties.HEIGHT_480;
        final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;

        final MediaVideoItem mvi = mVideoEditorHelper.createMediaItem
            (mVideoEditor, "m1", videoItemFilename, renderingMode);

        validateVideoProperties(aspectRatio, fileType, videoCodecType, duration,
            videoBitrate, fps, videoProfile, videoLevel, width, height, audioCodecType,
            audioSamplingFrequency, audioChannel, audioBitrate, mvi);
    }

    /**
     *To test Media Properties for file MPEG4 QCIF
     */
    @LargeTest
    public void testPropertiesMPEGQCIF() throws Exception {
        final String videoItemFilename = INPUT_FILE_PATH
            + "MPEG4_SP_176x144_12fps_92kbps_AMRNB_8KHz_12.2kbps_m_0_27.3gp";
        final int aspectRatio = MediaProperties.ASPECT_RATIO_11_9;
        final int fileType = MediaProperties.FILE_3GP;
        final int videoCodecType = MediaProperties.VCODEC_MPEG4;
        final int duration = 27000;
        final int videoBitrate = 384000;
        final int audioBitrate = 12200;
        final int fps = 12;
        final int audioCodecType = MediaProperties.ACODEC_AMRNB;
        final int audioSamplingFrequency = 8000;
        final int audioChannel = 1;
        final int videoProfile = MediaProperties.MPEG4Profile.MPEG4ProfileSimple;
        final int videoLevel = MediaProperties.MPEG4Level.MPEG4Level1;
        final int width = 176;
        final int height = MediaProperties.HEIGHT_144;
        final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;

        final MediaVideoItem mvi = mVideoEditorHelper.createMediaItem
            (mVideoEditor, "m1", videoItemFilename, renderingMode);

        validateVideoProperties(aspectRatio, fileType, videoCodecType, duration,
            videoBitrate, fps, videoProfile, videoLevel, width, height, audioCodecType,
            audioSamplingFrequency, audioChannel, audioBitrate, mvi);
    }

    /**
     *To To test media properties for H263 176x144 (QCIF) + AAC (mono) file.
     */
    @LargeTest
    public void testPropertiesH263QCIF() throws Exception {
        final String videoItemFilename = INPUT_FILE_PATH
            + "H263_profile0_176x144_15fps_256kbps_AACLC_16kHz_32kbps_m_0_26.3gp";
        final int aspectRatio = MediaProperties.ASPECT_RATIO_11_9;
        final int fileType = MediaProperties.FILE_3GP;
        final int videoCodecType = MediaProperties.VCODEC_H263;
        final int duration = 26933;
        final int videoBitrate = 384000;
        final int audioBitrate = 64000;
        final int fps = 15;
        final int audioCodecType = MediaProperties.ACODEC_AAC_LC;
        final int audioSamplingFrequency = 16000;
        final int audioChannel = 1;
        final int videoProfile = MediaProperties.H263Profile.H263ProfileBaseline;
        final int videoLevel = MediaProperties.H263Level.H263Level10;
        final int width = 176;
        final int height = MediaProperties.HEIGHT_144;
        final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
        final MediaVideoItem mvi = mVideoEditorHelper.createMediaItem
            (mVideoEditor, "m1", videoItemFilename, renderingMode);

        validateVideoProperties(aspectRatio, fileType, videoCodecType, duration,
            videoBitrate, fps, videoProfile, videoLevel, width, height, audioCodecType,
            audioSamplingFrequency, audioChannel, audioBitrate, mvi);
    }

    /**
     *To test Media Properties for file H264 VGA
     */
    @LargeTest
    public void testPropertiesH264VGA() throws Exception {
        final String videoItemFilename = INPUT_FILE_PATH
            + "H264_BP_640x480_15fps_1200Kbps_AACLC_48KHz_64kps_m_0_27.3gp";
        final int aspectRatio = MediaProperties.ASPECT_RATIO_4_3;
        final int fileType = MediaProperties.FILE_3GP;
        final int videoCodecType = MediaProperties.VCODEC_H264;
        final int duration = 77600;
        final int videoBitrate = 745000;
        final int audioBitrate = 64000;
        final int fps = 15;
        final int audioCodecType = MediaProperties.ACODEC_AAC_LC;
        final int audioSamplingFrequency = 48000;
        final int audioChannel = 2;
        final int videoProfile = MediaProperties.H264Profile.H264ProfileBaseline;
        final int videoLevel = MediaProperties.H264Level.H264Level13;
        final int width = 640;
        final int height = MediaProperties.HEIGHT_480;
        final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
        final MediaVideoItem mvi = mVideoEditorHelper.createMediaItem
            (mVideoEditor, "m1", videoItemFilename, renderingMode);

        validateVideoProperties(aspectRatio, fileType, videoCodecType, duration,
            videoBitrate, fps, videoProfile, videoLevel, width, height, audioCodecType,
            audioSamplingFrequency, audioChannel, audioBitrate, mvi);
    }

    /**
     *To test Media Properties for file H264 NTSC
     */
    @LargeTest
    public void testPropertiesH264NTSC() throws Exception {
        final String videoItemFilename = INPUT_FILE_PATH
            + "H264_BP_720x480_25fps_256kbps_AMRNB_8khz_12.2kbps_m_0_26.mp4";
        final int aspectRatio = MediaProperties.ASPECT_RATIO_3_2;
        final int fileType = MediaProperties.FILE_MP4;
        final int videoCodecType = MediaProperties.VCODEC_H264;
        final int duration = 26880;
        final int videoBitrate = 244000;
        final int audioBitrate = 12200;
        final int fps = 25;
        final int audioCodecType = MediaProperties.ACODEC_AMRNB;
        final int audioSamplingFrequency = 8000;
        final int audioChannel = 1;
        final int videoProfile = MediaProperties.H264Profile.H264ProfileBaseline;
        final int videoLevel = MediaProperties.H264Level.H264Level13;
        final int width = 720;
        final int height = MediaProperties.HEIGHT_480;
        final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;

        final MediaVideoItem mvi = mVideoEditorHelper.createMediaItem
            (mVideoEditor, "m1", videoItemFilename, renderingMode);

        validateVideoProperties(aspectRatio, fileType, videoCodecType, duration,
            videoBitrate, fps, videoProfile, videoLevel, width, height, audioCodecType,
            audioSamplingFrequency, audioChannel, audioBitrate, mvi);
    }

    /**
     *To test media properties for H264 800x480 (WVGA) + AAC file.
     */
    @LargeTest
    public void testPropertiesH264WVGA() throws Exception {
        final String videoItemFilename = INPUT_FILE_PATH +
              "H264_BP_800x480_15fps_512kbps_AACLC_24KHz_38Kbps_s_1_17.mp4";
        final int aspectRatio = MediaProperties.ASPECT_RATIO_5_3;
        final int fileType = MediaProperties.FILE_MP4;
        final int videoCodecType = MediaProperties.VCODEC_H264;
        final int duration = 77466;
        final int videoBitrate = 528000;
        final int audioBitrate = 38000;
        final int fps = 15;
        final int audioCodecType = MediaProperties.ACODEC_AAC_LC;
        final int audioSamplingFrequency = 24000;
        final int audioChannel = 2;
        final int videoProfile = MediaProperties.H264Profile.H264ProfileBaseline;
        final int videoLevel = MediaProperties.H264Level.H264Level13;
        final int width = 800;
        final int height = MediaProperties.HEIGHT_480;
        final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;

        final MediaVideoItem mvi = mVideoEditorHelper.createMediaItem
            (mVideoEditor, "m1", videoItemFilename, renderingMode);

        validateVideoProperties(aspectRatio, fileType, videoCodecType, duration,
            videoBitrate, fps, videoProfile, videoLevel, width, height, audioCodecType,
            audioSamplingFrequency, audioChannel, audioBitrate, mvi);
    }

    /**
     *To test Media Properties for file H264 HD1280
     */
    @LargeTest
    public void testPropertiesH264HD1280() throws Exception {
        final String videoItemFilename = INPUT_FILE_PATH
            + "H264_BP_1280x720_15fps_512kbps_AACLC_16khz_48kbps_s_1_17.mp4";
        final int aspectRatio = MediaProperties.ASPECT_RATIO_16_9;
        final int fileType = MediaProperties.FILE_MP4;
        final int videoCodecType = MediaProperties.VCODEC_H264;
        final int duration = 77600;
        final int videoBitrate = 606000;
        final int audioBitrate = 48000;
        final int fps = 15;
        final int audioCodecType = MediaProperties.ACODEC_AAC_LC;
        final int audioSamplingFrequency = 16000;
        final int audioChannel = 2;
        final int videoProfile = MediaProperties.H264Profile.H264ProfileBaseline;
        final int videoLevel = MediaProperties.H264Level.H264Level13;
        final int width = 1280;
        final int height = MediaProperties.HEIGHT_720;
        final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;

        final MediaVideoItem mvi = mVideoEditorHelper.createMediaItem
            (mVideoEditor, "m1", videoItemFilename, renderingMode);

        validateVideoProperties(aspectRatio, fileType, videoCodecType, duration,
            videoBitrate, fps, videoProfile, videoLevel, width, height, audioCodecType,
            audioSamplingFrequency, audioChannel, audioBitrate, mvi);
    }

    /**
     *To test media properties for H264 1080x720 + AAC file
     */
    @LargeTest
    public void testPropertiesH264HD1080WithAudio() throws Exception {
        final String videoItemFilename = INPUT_FILE_PATH
            + "H264_BP_1080x720_30fps_12Mbps_AACLC_44.1khz_64kbps_s_1_17.mp4";
        final int aspectRatio = MediaProperties.ASPECT_RATIO_3_2;
        final int fileType = MediaProperties.FILE_MP4;
        final int videoCodecType = MediaProperties.VCODEC_H264;
        final int duration = 77500;
        final int videoBitrate = 1190000;
        final int audioBitrate = 64000;
        final int fps = 10;
        final int audioCodecType = MediaProperties.ACODEC_AAC_LC;
        final int audioSamplingFrequency = 44100;
        final int audioChannel = 2;
        final int videoProfile = MediaProperties.H264Profile.H264ProfileBaseline;
        final int videoLevel = MediaProperties.H264Level.H264Level13;
        final int width = 1080;
        final int height = MediaProperties.HEIGHT_720;
        final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;

        final MediaVideoItem mvi = mVideoEditorHelper.createMediaItem
            (mVideoEditor, "m1", videoItemFilename, renderingMode);

        validateVideoProperties(aspectRatio, fileType, videoCodecType, duration,
            videoBitrate, fps, videoProfile, videoLevel, width, height, audioCodecType,
            audioSamplingFrequency, audioChannel, audioBitrate, mvi);
    }

    /**
     *To test Media Properties for file WMV - Unsupported type
     */
    @LargeTest
    public void testPropertiesWMVFile() throws Exception {
        final String videoItemFilename = INPUT_FILE_PATH +
            "WMV_V7_640x480_15fps_512Kbps_wma_V9_44khz_48Kbps_s_1_30.wmv";
        boolean flagForException = false;
        if (MediaProfileReader.getWMVEnable() == false) {
            flagForException = true;
        } else {
            try {
                new MediaVideoItem(mVideoEditor, "m1", videoItemFilename,
                    MediaItem.RENDERING_MODE_BLACK_BORDER);
            } catch (IllegalArgumentException e) {
                flagForException = true;
            } catch (IOException e) {
                flagForException = true;
            }
        }
        assertTrue("Media Properties for a WMV File -- Unsupported file type",
            flagForException);
    }

    /**
     *To test media properties for H.264 Main/Advanced profile.
     */
    @LargeTest
    public void testPropertiesH264MainLineProfile() throws Exception {
        final String videoItemFilename = INPUT_FILE_PATH
            + "H264_MP_960x720_25fps_800kbps_AACLC_48Khz_192Kbps_s_1_17.mp4";
        final int aspectRatio = MediaProperties.ASPECT_RATIO_4_3;
        final int videoCodecType = MediaProperties.VCODEC_H264;
        final int fileType = MediaProperties.FILE_MP4;
        final int duration = 77500;
        final int videoBitrate = 800000;
        final int audioBitrate = 192000;
        final int fps = 25;
        final int audioCodecType = MediaProperties.ACODEC_AAC_LC;
        final int audioSamplingFrequency = 48000;
        final int audioChannel = 2;
        final int videoProfile = MediaProperties.H264Profile.H264ProfileMain;
        final int videoLevel = MediaProperties.H264Level.H264Level31;
        final int width = 960;
        final int height = MediaProperties.HEIGHT_720;
        final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;

        final MediaVideoItem mvi = mVideoEditorHelper.createMediaItem
            (mVideoEditor, "m1", videoItemFilename, renderingMode);

        validateVideoProperties(aspectRatio, fileType, videoCodecType, duration,
            videoBitrate, fps, videoProfile, videoLevel, width, height, audioCodecType,
            audioSamplingFrequency, audioChannel, audioBitrate, mvi);

    }

    /**
     *To test Media Properties for non existing file.
     */
    @LargeTest
    public void testPropertiesForNonExsitingFile() throws Exception {
        final String videoItemFilename = INPUT_FILE_PATH + "abc.3gp";
        boolean flagForException = false;

        try {
            new MediaVideoItem(mVideoEditor, "m1", videoItemFilename,
                MediaItem.RENDERING_MODE_BLACK_BORDER);
        } catch (IllegalArgumentException e) {
            flagForException = true;
        } catch (IOException e) {
            flagForException = true;
        }
        assertTrue("Media Properties for non exsisting file", flagForException);
     }

    /**
     *To test Media Properties for file H264 HD1080
     */
    @LargeTest
    public void testPropertiesH264HD1080WithoutAudio() throws Exception {
        final String videoItemFilename = INPUT_FILE_PATH +
            "H264_BP_1080x720_30fps_800kbps_1_17.mp4";
        final int aspectRatio = MediaProperties.ASPECT_RATIO_3_2;
        final int fileType = MediaProperties.FILE_MP4;
        final int videoCodecType = MediaProperties.VCODEC_H264;
        final int duration = 77366;
        final int videoBitrate = 859000;
        final int audioBitrate = 0;
        final int fps = 30;
        final int audioCodecType = -1;
        final int audioSamplingFrequency = 0;
        final int audioChannel = 0;
        final int videoProfile = MediaProperties.H264Profile.H264ProfileBaseline;
        final int videoLevel = MediaProperties.H264Level.H264Level13;
        final int width = 1080;
        final int height = MediaProperties.HEIGHT_720;
        final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;

        final MediaVideoItem mvi = mVideoEditorHelper.createMediaItem
            (mVideoEditor, "m1", videoItemFilename, renderingMode);

        validateVideoProperties(aspectRatio, fileType, videoCodecType, duration,
            videoBitrate, fps, videoProfile, videoLevel, width, height, audioCodecType,
            audioSamplingFrequency, audioChannel, audioBitrate, mvi);
    }

    /**
     *To test Media Properties for Image file of JPEG Type
     */
    @LargeTest
    public void testPropertiesVGAImage() throws Exception {
        final String imageItemFilename = INPUT_FILE_PATH + "IMG_640x480.jpg";
        final int imageItemDuration = 10000;
        final int aspectRatio = MediaProperties.ASPECT_RATIO_4_3;
        final int fileType = MediaProperties.FILE_JPEG;
        final int width = 640;
        final int height = MediaProperties.HEIGHT_480;
        final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;

        final MediaImageItem mii = mVideoEditorHelper.createMediaItem
            (mVideoEditor, "m1", imageItemFilename, imageItemDuration,
            renderingMode);
        validateImageProperties(aspectRatio, fileType, width, height, mii);
    }

    /**
     *To test Media Properties for Image file of PNG Type
     */
    @LargeTest
    public void testPropertiesPNG() throws Exception {
        final String imageItemFilename = INPUT_FILE_PATH + "IMG_640x480.png";
        final int imageItemDuration = 10000;
        final int aspectRatio = MediaProperties.ASPECT_RATIO_4_3;
        final int fileType = MediaProperties.FILE_PNG;
        final int width = 640;
        final int height = 480;
        final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
        final MediaImageItem mii = mVideoEditorHelper.createMediaItem
            (mVideoEditor, "m1", imageItemFilename, imageItemDuration,
            renderingMode);
        validateImageProperties(aspectRatio, fileType, width, height, mii);
    }

    /**
     *To test Media Properties for file GIF - Unsupported type
     */
    @LargeTest
    public void testPropertiesGIFFile() throws Exception {

        final String imageItemFilename = INPUT_FILE_PATH + "IMG_640x480.gif";
        final int imageItemDuration = 10000;
        final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
        boolean flagForException = false;
        try {
            new MediaImageItem(mVideoEditor, "m1", imageItemFilename,
                imageItemDuration, renderingMode);
        } catch (IllegalArgumentException e) {
            flagForException = true;
        }
        assertTrue("Media Properties for a GIF File -- Unsupported file type",
            flagForException);
    }

    /**
     *To test Media Properties for file Text file named as 3GP
     */
    @LargeTest
    public void testPropertiesofDirtyFile() throws Exception {

        final String videoItemFilename = INPUT_FILE_PATH +
            "Text_FileRenamedTo3gp.3gp";
        boolean flagForException = false;

        try {
            new MediaVideoItem(mVideoEditor, "m1", videoItemFilename,
                MediaItem.RENDERING_MODE_BLACK_BORDER);
        } catch (IllegalArgumentException e) {
            flagForException = true;
        }
        assertTrue("Media Properties for a Dirty  File ",
            flagForException);
    }

    /**
     *To test Media Properties for file name as NULL
     */
    @LargeTest
    public void testPropertieNULLFile() throws Exception {
        final String videoItemFilename = null;
        boolean flagForException = false;
        final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
        try {
            new MediaVideoItem(mVideoEditor, "m1", videoItemFilename,
                renderingMode);
        } catch (IllegalArgumentException e) {
            flagForException = true;
        }
        assertTrue("Media Properties for NULL  File ",
            flagForException);
    }

    /**
     *To test Media Properties for file which is of type MPEG2
     */
    @LargeTest
    public void testPropertiesMPEG2File() throws Exception {
        final String videoItemFilename = INPUT_FILE_PATH +
            "MPEG2_640x480_30fps_192kbps_1_5.mp4";
        boolean flagForException = false;
        final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
        try {
            new MediaVideoItem(mVideoEditor, "m1", videoItemFilename,
                renderingMode);
        } catch (IllegalArgumentException e) {
            flagForException = true;
        }
        assertTrue("Media Properties for a MPEG2 File --Unsupported file type",
            flagForException);
    }

    /**
     *To test Media Properties for file without Video only Audio
     */
    @LargeTest
    public void testProperties3GPWithoutVideoMediaItem() throws Exception {
        final String audioFilename = INPUT_FILE_PATH +
            "AACLC_48KHz_256Kbps_s_1_17.3gp";
        boolean flagForException = false;
        final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
        try {
            new MediaVideoItem(mVideoEditor, "m1", audioFilename,
                renderingMode);
        } catch (IllegalArgumentException e) {
            flagForException = true;
        }
        assertTrue("Exception in Creaing Media Video item object without video",
            flagForException);
    }

    /**
     *To test media properties for Audio Track file. (No Video, AAC Audio)
     */
    @LargeTest
    public void testProperties3GPWithoutVideoAudioTrack() throws Exception {

        final String audioFilename = INPUT_FILE_PATH +
            "AACLC_44.1kHz_256kbps_s_1_17.mp4";
        final int duration = 77554;
        final int audioBitrate = 384000;
        final int audioCodecType = MediaProperties.ACODEC_AAC_LC;
        final int audioSamplingFrequency = 44100;
        final int audioChannel = 2;

        final AudioTrack audioTrack = mVideoEditorHelper.createAudio
            (mVideoEditor, "a1", audioFilename);

        validateAudioProperties(audioCodecType, duration, audioSamplingFrequency,
            audioChannel, audioBitrate, audioTrack);
    }

        /**
     *To test media properties for Audio Track file. MP3 file
     */
    @LargeTest
    public void testPropertiesMP3AudioTrack() throws Exception {

        final String audioFilename = INPUT_FILE_PATH +
            "MP3_48KHz_128kbps_s_1_17.mp3";
        final int duration = 77640;
        final int audioBitrate = 128000;
        final int audioCodecType = MediaProperties.ACODEC_MP3;
        final int audioSamplingFrequency = 48000;
        final int audioChannel = 2;

        final AudioTrack audioTrack = mVideoEditorHelper.createAudio
            (mVideoEditor, "a1", audioFilename);

        validateAudioProperties(audioCodecType, duration, audioSamplingFrequency,
            audioChannel, audioBitrate, audioTrack);
    }
}