MediaPropertiesTest.java revision e1103cfc781b09d1a227f448374473093a451d6f
1/*
2 * Copyright (C) 2011 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
17package com.android.mediaframeworktest.functional.videoeditor;
18
19import java.io.File;
20import java.io.IOException;
21
22import android.media.videoeditor.AudioTrack;
23import android.media.videoeditor.MediaImageItem;
24import android.media.videoeditor.MediaItem;
25import android.media.videoeditor.MediaProperties;
26import android.media.videoeditor.MediaVideoItem;
27import android.media.videoeditor.VideoEditor;
28import android.os.Environment;
29import android.test.ActivityInstrumentationTestCase;
30import android.test.suitebuilder.annotation.LargeTest;
31import com.android.mediaframeworktest.MediaFrameworkTest;
32import com.android.mediaframeworktest.VideoEditorHelper;
33import com.android.mediaframeworktest.MediaProfileReader;
34
35public class MediaPropertiesTest extends
36    ActivityInstrumentationTestCase<MediaFrameworkTest> {
37    private final String TAG = "MediaPropertiesTest";
38
39    private final String PROJECT_LOCATION = VideoEditorHelper.PROJECT_LOCATION_COMMON;
40
41    private final String INPUT_FILE_PATH = VideoEditorHelper.INPUT_FILE_PATH_COMMON;
42
43    private VideoEditor mVideoEditor;
44
45    private VideoEditorHelper mVideoEditorHelper;
46
47    public MediaPropertiesTest() {
48        super("com.android.mediaframeworktest", MediaFrameworkTest.class);
49    }
50
51    @Override
52    protected void setUp() throws Exception {
53        // setup for each test case.
54        super.setUp();
55        mVideoEditorHelper = new VideoEditorHelper();
56        // Create a random String which will be used as project path,
57        // where all project related files will be stored.
58        final String projectPath = mVideoEditorHelper.
59            createRandomFile(PROJECT_LOCATION);
60        mVideoEditor = mVideoEditorHelper.createVideoEditor(projectPath);
61    }
62
63    @Override
64    protected void tearDown() throws Exception {
65        mVideoEditorHelper.destroyVideoEditor(mVideoEditor);
66        // Clean the directory created as project path
67        mVideoEditorHelper.deleteProject(new File(mVideoEditor.getPath()));
68        System.gc();
69        super.tearDown();
70    }
71
72    protected void validateVideoProperties(int aspectRatio, int fileType,
73        int videoCodecType, int duration, int videoBitrate, int fps,
74        int videoProfile, int videoLevel, int width, int height, int audioCodecType,
75        int audioSamplingFrequency, int audioChannel, int audioBitrate,
76        MediaVideoItem mvi) throws Exception {
77        assertEquals("Aspect Ratio Mismatch", aspectRatio, mvi.getAspectRatio());
78        assertEquals("File Type Mismatch", fileType, mvi.getFileType());
79        assertEquals("VideoCodec Mismatch", videoCodecType, mvi.getVideoType());
80
81        assertTrue("Video duration Mismatch", mVideoEditorHelper.checkRange (
82            duration, mvi.getDuration(), 10));
83        assertEquals("Video Profile " + mvi.getVideoProfile(), videoProfile,
84            mvi.getVideoProfile());
85        assertEquals("Video Level " + mvi.getVideoLevel(), videoLevel,
86            mvi.getVideoLevel());
87        assertEquals("Video height " + mvi.getHeight(), height, mvi.getHeight());
88        assertEquals("Video width " + mvi.getWidth(), width, mvi.getWidth());
89        /** Check FPS with 10% range */
90        assertTrue("fps Mismatch" + mvi.getFps(),
91            mVideoEditorHelper.checkRange(fps, mvi.getFps(), 10));
92
93        assertEquals("AudioType Mismatch ", audioCodecType, mvi.getAudioType());
94        assertEquals("Audio Sampling " + mvi.getAudioSamplingFrequency(),
95            audioSamplingFrequency, mvi.getAudioSamplingFrequency());
96        // PV SW AAC codec always returns number of channels as Stereo.
97        // So we do not assert for number of audio channels for AAC_LC
98        if ( audioCodecType != MediaProperties.ACODEC_AAC_LC ) {
99            assertEquals("Audio Channels " + mvi.getAudioChannels(), audioChannel,
100                mvi.getAudioChannels());
101        }
102    }
103
104    protected void validateAudioProperties(int audioCodecType, int duration,
105        int audioSamplingFrequency, int audioChannel, int audioBitrate,
106        AudioTrack aT) throws Exception {
107        assertEquals("AudioType Mismatch ", audioCodecType, aT.getAudioType());
108        assertTrue("Video duration Mismatch", mVideoEditorHelper.checkRange (
109            duration, aT.getDuration(), 10));
110        assertEquals("Audio Sampling " + aT.getAudioSamplingFrequency(),
111            audioSamplingFrequency, aT.getAudioSamplingFrequency());
112        // PV SW AAC codec always returns number of channels as Stereo.
113        // So we do not assert for number of audio channels for AAC_LC
114        if ( audioCodecType != MediaProperties.ACODEC_AAC_LC ) {
115            assertEquals("Audio Channels " + aT.getAudioChannels(), audioChannel,
116                aT.getAudioChannels());
117        }
118    }
119
120    protected void validateImageProperties(int aspectRatio, int fileType,
121        int width, int height, MediaImageItem mii)
122        throws Exception {
123        assertEquals("Aspect Ratio Mismatch", aspectRatio, mii.getAspectRatio());
124        assertEquals("File Type Mismatch", fileType, mii.getFileType());
125        assertEquals("Image height " + mii.getHeight(), height, mii.getHeight());
126        assertEquals("Image width " + mii.getWidth(), width, mii.getWidth());
127    }
128
129
130    /**
131     *To test Media Properties for file MPEG4 854 x 480
132     */
133    @LargeTest
134    public void testPropertiesMPEG4854_480() throws Exception {
135        final String videoItemFilename = INPUT_FILE_PATH
136            + "MPEG4_SP_854x480_15fps_256kbps_AACLC_16khz_48kbps_s_0_26.mp4";
137        final int aspectRatio = MediaProperties.ASPECT_RATIO_16_9;
138        final int fileType = MediaProperties.FILE_MP4;
139        final int videoCodecType = MediaProperties.VCODEC_MPEG4;
140        final int duration = 26933;
141        final int videoBitrate = 319000;
142        final int audioBitrate = 48000;
143        final int fps = 15;
144        final int audioCodecType = MediaProperties.ACODEC_AAC_LC;
145        final int audioSamplingFrequency = 16000;
146        final int audioChannel = 2;
147        final int videoProfile = MediaProperties.MPEG4Profile.MPEG4ProfileSimple;
148        final int videoLevel = MediaProperties.MPEG4Level.MPEG4Level1;
149        final int width = 854;
150        final int height = MediaProperties.HEIGHT_480;
151
152        final MediaVideoItem mvi = mVideoEditorHelper.createMediaItem
153            (mVideoEditor, "m1", videoItemFilename,
154            MediaItem.RENDERING_MODE_BLACK_BORDER);
155
156        validateVideoProperties(aspectRatio, fileType, videoCodecType, duration,
157            videoBitrate, fps, videoProfile, videoLevel, width, height, audioCodecType,
158            audioSamplingFrequency, audioChannel, audioBitrate, mvi);
159    }
160
161
162    /**
163     *To test Media Properties for file MPEG4 WVGA
164     */
165    @LargeTest
166    public void testPropertiesMPEGWVGA() throws Exception {
167        final String videoItemFilename = INPUT_FILE_PATH
168            + "MPEG4_SP_800x480_515kbps_15fps_AMR_NB_8KHz_12.2kbps_m_0_26.mp4";
169        final int aspectRatio = MediaProperties.ASPECT_RATIO_5_3;
170        final int fileType = MediaProperties.FILE_MP4;
171        final int videoCodecType = MediaProperties.VCODEC_MPEG4;
172        final int duration = 26933;
173        final int videoBitrate = 384000;
174        final int audioBitrate = 12800;
175        final int fps = 15;
176        final int audioCodecType = MediaProperties.ACODEC_AMRNB;
177        final int audioSamplingFrequency = 8000;
178        final int audioChannel = 1;
179        final int videoProfile = MediaProperties.MPEG4Profile.MPEG4ProfileSimple;
180        final int videoLevel = MediaProperties.MPEG4Level.MPEG4Level1;
181        final int width = 800;
182        final int height = MediaProperties.HEIGHT_480;
183        final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
184
185        final MediaVideoItem mvi = mVideoEditorHelper.createMediaItem
186            (mVideoEditor, "m1", videoItemFilename, renderingMode);
187
188        validateVideoProperties(aspectRatio, fileType, videoCodecType, duration,
189            videoBitrate, fps, videoProfile, videoLevel, width, height, audioCodecType,
190            audioSamplingFrequency, audioChannel, audioBitrate, mvi);
191    }
192
193    /**
194     *To test media properties for MPEG4 720x480 (NTSC) + AAC file.
195     */
196    @LargeTest
197    public void testPropertiesMPEGNTSC() throws Exception {
198        final String videoItemFilename = INPUT_FILE_PATH
199            + "MPEG4_SP_720x480_30fps_280kbps_AACLC_48kHz_161kbps_s_0_26.mp4";
200        final int aspectRatio = MediaProperties.ASPECT_RATIO_3_2;
201        final int fileType = MediaProperties.FILE_MP4;
202        final int videoCodecType = MediaProperties.VCODEC_MPEG4;
203        final int duration = 26866;
204        final int videoBitrate = 403000;
205        final int audioBitrate = 160000;
206        final int fps = 30;
207        final int audioCodecType = MediaProperties.ACODEC_AAC_LC;
208        final int audioSamplingFrequency = 48000;
209        final int audioChannel = 2;
210        final int videoProfile = MediaProperties.MPEG4Profile.MPEG4ProfileSimple;
211        final int videoLevel = MediaProperties.MPEG4Level.MPEG4Level1;
212        final int width = 720;
213        final int height = MediaProperties.HEIGHT_480;
214        final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
215
216        final MediaVideoItem mvi = mVideoEditorHelper.createMediaItem
217            (mVideoEditor, "m1", videoItemFilename, renderingMode);
218
219        validateVideoProperties(aspectRatio, fileType, videoCodecType, duration,
220            videoBitrate, fps, videoProfile, videoLevel, width, height, audioCodecType,
221            audioSamplingFrequency, audioChannel, audioBitrate, mvi);
222    }
223
224    /**
225     *To test Media Properties for file MPEG4 VGA
226     */
227    @LargeTest
228    public void testPropertiesMPEGVGA() throws Exception {
229        final String videoItemFilename = INPUT_FILE_PATH
230            + "MPEG4_SP_640x480_15fps_512kbps_AACLC_48khz_132kbps_s_0_26.mp4";
231        final int aspectRatio = MediaProperties.ASPECT_RATIO_4_3;
232        final int fileType = MediaProperties.FILE_MP4;
233        final int videoCodecType = MediaProperties.VCODEC_MPEG4;
234        final int duration = 26933;
235        final int videoBitrate = 533000;
236        final int audioBitrate = 128000;
237        final int fps = 15;
238        final int audioCodecType = MediaProperties.ACODEC_AAC_LC;
239        final int audioSamplingFrequency = 48000;
240        final int audioChannel = 2;
241        final int videoProfile = MediaProperties.MPEG4Profile.MPEG4ProfileSimple;
242        final int videoLevel = MediaProperties.MPEG4Level.MPEG4Level1;
243        final int width = 640;
244        final int height = MediaProperties.HEIGHT_480;
245        final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
246
247        final MediaVideoItem mvi = mVideoEditorHelper.createMediaItem
248            (mVideoEditor, "m1", videoItemFilename, renderingMode);
249
250        validateVideoProperties(aspectRatio, fileType, videoCodecType, duration,
251            videoBitrate, fps, videoProfile, videoLevel, width, height, audioCodecType,
252            audioSamplingFrequency, audioChannel, audioBitrate, mvi);
253    }
254
255    /**
256     *To test Media Properties for file MPEG4 QCIF
257     */
258    @LargeTest
259    public void testPropertiesMPEGQCIF() throws Exception {
260        final String videoItemFilename = INPUT_FILE_PATH
261            + "MPEG4_SP_176x144_12fps_92kbps_AMRNB_8KHz_12.2kbps_m_0_27.3gp";
262        final int aspectRatio = MediaProperties.ASPECT_RATIO_11_9;
263        final int fileType = MediaProperties.FILE_3GP;
264        final int videoCodecType = MediaProperties.VCODEC_MPEG4;
265        final int duration = 27000;
266        final int videoBitrate = 384000;
267        final int audioBitrate = 12200;
268        final int fps = 12;
269        final int audioCodecType = MediaProperties.ACODEC_AMRNB;
270        final int audioSamplingFrequency = 8000;
271        final int audioChannel = 1;
272        final int videoProfile = MediaProperties.MPEG4Profile.MPEG4ProfileSimple;
273        final int videoLevel = MediaProperties.MPEG4Level.MPEG4Level1;
274        final int width = 176;
275        final int height = MediaProperties.HEIGHT_144;
276        final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
277
278        final MediaVideoItem mvi = mVideoEditorHelper.createMediaItem
279            (mVideoEditor, "m1", videoItemFilename, renderingMode);
280
281        validateVideoProperties(aspectRatio, fileType, videoCodecType, duration,
282            videoBitrate, fps, videoProfile, videoLevel, width, height, audioCodecType,
283            audioSamplingFrequency, audioChannel, audioBitrate, mvi);
284    }
285
286    /**
287     *To To test media properties for H263 176x144 (QCIF) + AAC (mono) file.
288     */
289    @LargeTest
290    public void testPropertiesH263QCIF() throws Exception {
291        final String videoItemFilename = INPUT_FILE_PATH
292            + "H263_profile0_176x144_15fps_256kbps_AACLC_16kHz_32kbps_m_0_26.3gp";
293        final int aspectRatio = MediaProperties.ASPECT_RATIO_11_9;
294        final int fileType = MediaProperties.FILE_3GP;
295        final int videoCodecType = MediaProperties.VCODEC_H263;
296        final int duration = 26933;
297        final int videoBitrate = 384000;
298        final int audioBitrate = 64000;
299        final int fps = 15;
300        final int audioCodecType = MediaProperties.ACODEC_AAC_LC;
301        final int audioSamplingFrequency = 16000;
302        final int audioChannel = 1;
303        final int videoProfile = MediaProperties.H263Profile.H263ProfileBaseline;
304        final int videoLevel = MediaProperties.H263Level.H263Level10;
305        final int width = 176;
306        final int height = MediaProperties.HEIGHT_144;
307        final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
308        final MediaVideoItem mvi = mVideoEditorHelper.createMediaItem
309            (mVideoEditor, "m1", videoItemFilename, renderingMode);
310
311        validateVideoProperties(aspectRatio, fileType, videoCodecType, duration,
312            videoBitrate, fps, videoProfile, videoLevel, width, height, audioCodecType,
313            audioSamplingFrequency, audioChannel, audioBitrate, mvi);
314    }
315
316    /**
317     *To test Media Properties for file H264 VGA
318     */
319    @LargeTest
320    public void testPropertiesH264VGA() throws Exception {
321        final String videoItemFilename = INPUT_FILE_PATH
322            + "H264_BP_640x480_15fps_1200Kbps_AACLC_48KHz_64kps_m_0_27.3gp";
323        final int aspectRatio = MediaProperties.ASPECT_RATIO_4_3;
324        final int fileType = MediaProperties.FILE_3GP;
325        final int videoCodecType = MediaProperties.VCODEC_H264;
326        final int duration = 77600;
327        final int videoBitrate = 745000;
328        final int audioBitrate = 64000;
329        final int fps = 15;
330        final int audioCodecType = MediaProperties.ACODEC_AAC_LC;
331        final int audioSamplingFrequency = 48000;
332        final int audioChannel = 2;
333        final int videoProfile = MediaProperties.H264Profile.H264ProfileBaseline;
334        final int videoLevel = MediaProperties.H264Level.H264Level13;
335        final int width = 640;
336        final int height = MediaProperties.HEIGHT_480;
337        final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
338        final MediaVideoItem mvi = mVideoEditorHelper.createMediaItem
339            (mVideoEditor, "m1", videoItemFilename, renderingMode);
340
341        validateVideoProperties(aspectRatio, fileType, videoCodecType, duration,
342            videoBitrate, fps, videoProfile, videoLevel, width, height, audioCodecType,
343            audioSamplingFrequency, audioChannel, audioBitrate, mvi);
344    }
345
346    /**
347     *To test Media Properties for file H264 NTSC
348     */
349    @LargeTest
350    public void testPropertiesH264NTSC() throws Exception {
351        final String videoItemFilename = INPUT_FILE_PATH
352            + "H264_BP_720x480_25fps_256kbps_AMRNB_8khz_12.2kbps_m_0_26.mp4";
353        final int aspectRatio = MediaProperties.ASPECT_RATIO_3_2;
354        final int fileType = MediaProperties.FILE_MP4;
355        final int videoCodecType = MediaProperties.VCODEC_H264;
356        final int duration = 26880;
357        final int videoBitrate = 244000;
358        final int audioBitrate = 12200;
359        final int fps = 25;
360        final int audioCodecType = MediaProperties.ACODEC_AMRNB;
361        final int audioSamplingFrequency = 8000;
362        final int audioChannel = 1;
363        final int videoProfile = MediaProperties.H264Profile.H264ProfileBaseline;
364        final int videoLevel = MediaProperties.H264Level.H264Level13;
365        final int width = 720;
366        final int height = MediaProperties.HEIGHT_480;
367        final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
368
369        final MediaVideoItem mvi = mVideoEditorHelper.createMediaItem
370            (mVideoEditor, "m1", videoItemFilename, renderingMode);
371
372        validateVideoProperties(aspectRatio, fileType, videoCodecType, duration,
373            videoBitrate, fps, videoProfile, videoLevel, width, height, audioCodecType,
374            audioSamplingFrequency, audioChannel, audioBitrate, mvi);
375    }
376
377    /**
378     *To test media properties for H264 800x480 (WVGA) + AAC file.
379     */
380    @LargeTest
381    public void testPropertiesH264WVGA() throws Exception {
382        final String videoItemFilename = INPUT_FILE_PATH +
383              "H264_BP_800x480_15fps_512kbps_AACLC_24KHz_38Kbps_s_1_17.mp4";
384        final int aspectRatio = MediaProperties.ASPECT_RATIO_5_3;
385        final int fileType = MediaProperties.FILE_MP4;
386        final int videoCodecType = MediaProperties.VCODEC_H264;
387        final int duration = 77466;
388        final int videoBitrate = 528000;
389        final int audioBitrate = 38000;
390        final int fps = 15;
391        final int audioCodecType = MediaProperties.ACODEC_AAC_LC;
392        final int audioSamplingFrequency = 24000;
393        final int audioChannel = 2;
394        final int videoProfile = MediaProperties.H264Profile.H264ProfileBaseline;
395        final int videoLevel = MediaProperties.H264Level.H264Level13;
396        final int width = 800;
397        final int height = MediaProperties.HEIGHT_480;
398        final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
399
400        final MediaVideoItem mvi = mVideoEditorHelper.createMediaItem
401            (mVideoEditor, "m1", videoItemFilename, renderingMode);
402
403        validateVideoProperties(aspectRatio, fileType, videoCodecType, duration,
404            videoBitrate, fps, videoProfile, videoLevel, width, height, audioCodecType,
405            audioSamplingFrequency, audioChannel, audioBitrate, mvi);
406    }
407
408    /**
409     *To test Media Properties for file H264 HD1280
410     */
411    @LargeTest
412    public void testPropertiesH264HD1280() throws Exception {
413        final String videoItemFilename = INPUT_FILE_PATH
414            + "H264_BP_1280x720_15fps_512kbps_AACLC_16khz_48kbps_s_1_17.mp4";
415        final int aspectRatio = MediaProperties.ASPECT_RATIO_16_9;
416        final int fileType = MediaProperties.FILE_MP4;
417        final int videoCodecType = MediaProperties.VCODEC_H264;
418        final int duration = 77600;
419        final int videoBitrate = 606000;
420        final int audioBitrate = 48000;
421        final int fps = 15;
422        final int audioCodecType = MediaProperties.ACODEC_AAC_LC;
423        final int audioSamplingFrequency = 16000;
424        final int audioChannel = 2;
425        final int videoProfile = MediaProperties.H264Profile.H264ProfileBaseline;
426        final int videoLevel = MediaProperties.H264Level.H264Level13;
427        final int width = 1280;
428        final int height = MediaProperties.HEIGHT_720;
429        final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
430
431        final MediaVideoItem mvi = mVideoEditorHelper.createMediaItem
432            (mVideoEditor, "m1", videoItemFilename, renderingMode);
433
434        validateVideoProperties(aspectRatio, fileType, videoCodecType, duration,
435            videoBitrate, fps, videoProfile, videoLevel, width, height, audioCodecType,
436            audioSamplingFrequency, audioChannel, audioBitrate, mvi);
437    }
438
439    /**
440     *To test media properties for H264 1080x720 + AAC file
441     */
442    @LargeTest
443    public void testPropertiesH264HD1080WithAudio() throws Exception {
444        final String videoItemFilename = INPUT_FILE_PATH
445            + "H264_BP_1080x720_30fps_12Mbps_AACLC_44.1khz_64kbps_s_1_17.mp4";
446        final int aspectRatio = MediaProperties.ASPECT_RATIO_3_2;
447        final int fileType = MediaProperties.FILE_MP4;
448        final int videoCodecType = MediaProperties.VCODEC_H264;
449        final int duration = 77500;
450        final int videoBitrate = 1190000;
451        final int audioBitrate = 64000;
452        final int fps = 10;
453        final int audioCodecType = MediaProperties.ACODEC_AAC_LC;
454        final int audioSamplingFrequency = 44100;
455        final int audioChannel = 2;
456        final int videoProfile = MediaProperties.H264Profile.H264ProfileBaseline;
457        final int videoLevel = MediaProperties.H264Level.H264Level13;
458        final int width = 1080;
459        final int height = MediaProperties.HEIGHT_720;
460        final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
461
462        final MediaVideoItem mvi = mVideoEditorHelper.createMediaItem
463            (mVideoEditor, "m1", videoItemFilename, renderingMode);
464
465        validateVideoProperties(aspectRatio, fileType, videoCodecType, duration,
466            videoBitrate, fps, videoProfile, videoLevel, width, height, audioCodecType,
467            audioSamplingFrequency, audioChannel, audioBitrate, mvi);
468    }
469
470    /**
471     *To test Media Properties for file WMV - Unsupported type
472     */
473    @LargeTest
474    public void testPropertiesWMVFile() throws Exception {
475        final String videoItemFilename = INPUT_FILE_PATH +
476            "WMV_V7_640x480_15fps_512Kbps_wma_V9_44khz_48Kbps_s_1_30.wmv";
477        boolean flagForException = false;
478        if (MediaProfileReader.getWMVEnable() == false) {
479            flagForException = true;
480        } else {
481            try {
482                new MediaVideoItem(mVideoEditor, "m1", videoItemFilename,
483                    MediaItem.RENDERING_MODE_BLACK_BORDER);
484            } catch (IllegalArgumentException e) {
485                flagForException = true;
486            } catch (IOException e) {
487                flagForException = true;
488            }
489        }
490        assertTrue("Media Properties for a WMV File -- Unsupported file type",
491            flagForException);
492    }
493
494    /**
495     *To test media properties for H.264 Main/Advanced profile.
496     */
497    @LargeTest
498    public void testPropertiesH264MainLineProfile() throws Exception {
499        final String videoItemFilename = INPUT_FILE_PATH
500            + "H264_MP_960x720_25fps_800kbps_AACLC_48Khz_192Kbps_s_1_17.mp4";
501        final int aspectRatio = MediaProperties.ASPECT_RATIO_4_3;
502        final int videoCodecType = MediaProperties.VCODEC_H264;
503        final int fileType = MediaProperties.FILE_MP4;
504        final int duration = 77500;
505        final int videoBitrate = 800000;
506        final int audioBitrate = 192000;
507        final int fps = 25;
508        final int audioCodecType = MediaProperties.ACODEC_AAC_LC;
509        final int audioSamplingFrequency = 48000;
510        final int audioChannel = 2;
511        final int videoProfile = MediaProperties.H264Profile.H264ProfileMain;
512        final int videoLevel = MediaProperties.H264Level.H264Level31;
513        final int width = 960;
514        final int height = MediaProperties.HEIGHT_720;
515        final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
516
517        final MediaVideoItem mvi = mVideoEditorHelper.createMediaItem
518            (mVideoEditor, "m1", videoItemFilename, renderingMode);
519
520        validateVideoProperties(aspectRatio, fileType, videoCodecType, duration,
521            videoBitrate, fps, videoProfile, videoLevel, width, height, audioCodecType,
522            audioSamplingFrequency, audioChannel, audioBitrate, mvi);
523
524    }
525
526    /**
527     *To test Media Properties for non existing file.
528     */
529    @LargeTest
530    public void testPropertiesForNonExsitingFile() throws Exception {
531        final String videoItemFilename = INPUT_FILE_PATH + "abc.3gp";
532        boolean flagForException = false;
533
534        try {
535            new MediaVideoItem(mVideoEditor, "m1", videoItemFilename,
536                MediaItem.RENDERING_MODE_BLACK_BORDER);
537        } catch (IllegalArgumentException e) {
538            flagForException = true;
539        } catch (IOException e) {
540            flagForException = true;
541        }
542        assertTrue("Media Properties for non exsisting file", flagForException);
543     }
544
545    /**
546     *To test Media Properties for file H264 HD1080
547     */
548    @LargeTest
549    public void testPropertiesH264HD1080WithoutAudio() throws Exception {
550        final String videoItemFilename = INPUT_FILE_PATH +
551            "H264_BP_1080x720_30fps_800kbps_1_17.mp4";
552        final int aspectRatio = MediaProperties.ASPECT_RATIO_3_2;
553        final int fileType = MediaProperties.FILE_MP4;
554        final int videoCodecType = MediaProperties.VCODEC_H264;
555        final int duration = 77366;
556        final int videoBitrate = 859000;
557        final int audioBitrate = 0;
558        final int fps = 30;
559        final int audioCodecType = -1;
560        final int audioSamplingFrequency = 0;
561        final int audioChannel = 0;
562        final int videoProfile = MediaProperties.H264Profile.H264ProfileBaseline;
563        final int videoLevel = MediaProperties.H264Level.H264Level13;
564        final int width = 1080;
565        final int height = MediaProperties.HEIGHT_720;
566        final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
567
568        final MediaVideoItem mvi = mVideoEditorHelper.createMediaItem
569            (mVideoEditor, "m1", videoItemFilename, renderingMode);
570
571        validateVideoProperties(aspectRatio, fileType, videoCodecType, duration,
572            videoBitrate, fps, videoProfile, videoLevel, width, height, audioCodecType,
573            audioSamplingFrequency, audioChannel, audioBitrate, mvi);
574    }
575
576    /**
577     *To test Media Properties for Image file of JPEG Type
578     */
579    @LargeTest
580    public void testPropertiesVGAImage() throws Exception {
581        final String imageItemFilename = INPUT_FILE_PATH + "IMG_640x480.jpg";
582        final int imageItemDuration = 10000;
583        final int aspectRatio = MediaProperties.ASPECT_RATIO_4_3;
584        final int fileType = MediaProperties.FILE_JPEG;
585        final int width = 640;
586        final int height = MediaProperties.HEIGHT_480;
587        final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
588
589        final MediaImageItem mii = mVideoEditorHelper.createMediaItem
590            (mVideoEditor, "m1", imageItemFilename, imageItemDuration,
591            renderingMode);
592        validateImageProperties(aspectRatio, fileType, width, height, mii);
593    }
594
595    /**
596     *To test Media Properties for Image file of PNG Type
597     */
598    @LargeTest
599    public void testPropertiesPNG() throws Exception {
600        final String imageItemFilename = INPUT_FILE_PATH + "IMG_640x480.png";
601        final int imageItemDuration = 10000;
602        final int aspectRatio = MediaProperties.ASPECT_RATIO_4_3;
603        final int fileType = MediaProperties.FILE_PNG;
604        final int width = 640;
605        final int height = 480;
606        final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
607        final MediaImageItem mii = mVideoEditorHelper.createMediaItem
608            (mVideoEditor, "m1", imageItemFilename, imageItemDuration,
609            renderingMode);
610        validateImageProperties(aspectRatio, fileType, width, height, mii);
611    }
612
613    /**
614     *To test Media Properties for file GIF - Unsupported type
615     */
616    @LargeTest
617    public void testPropertiesGIFFile() throws Exception {
618
619        final String imageItemFilename = INPUT_FILE_PATH + "IMG_640x480.gif";
620        final int imageItemDuration = 10000;
621        final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
622        boolean flagForException = false;
623        try {
624            new MediaImageItem(mVideoEditor, "m1", imageItemFilename,
625                imageItemDuration, renderingMode);
626        } catch (IllegalArgumentException e) {
627            flagForException = true;
628        }
629        assertTrue("Media Properties for a GIF File -- Unsupported file type",
630            flagForException);
631    }
632
633    /**
634     *To test Media Properties for file Text file named as 3GP
635     */
636    @LargeTest
637    public void testPropertiesofDirtyFile() throws Exception {
638
639        final String videoItemFilename = INPUT_FILE_PATH +
640            "Text_FileRenamedTo3gp.3gp";
641        boolean flagForException = false;
642
643        try {
644            new MediaVideoItem(mVideoEditor, "m1", videoItemFilename,
645                MediaItem.RENDERING_MODE_BLACK_BORDER);
646        } catch (IllegalArgumentException e) {
647            flagForException = true;
648        }
649        assertTrue("Media Properties for a Dirty  File ",
650            flagForException);
651    }
652
653    /**
654     *To test Media Properties for file name as NULL
655     */
656    @LargeTest
657    public void testPropertieNULLFile() throws Exception {
658        final String videoItemFilename = null;
659        boolean flagForException = false;
660        final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
661        try {
662            new MediaVideoItem(mVideoEditor, "m1", videoItemFilename,
663                renderingMode);
664        } catch (IllegalArgumentException e) {
665            flagForException = true;
666        }
667        assertTrue("Media Properties for NULL  File ",
668            flagForException);
669    }
670
671    /**
672     *To test Media Properties for file which is of type MPEG2
673     */
674    @LargeTest
675    public void testPropertiesMPEG2File() throws Exception {
676        final String videoItemFilename = INPUT_FILE_PATH +
677            "MPEG2_640x480_30fps_192kbps_1_5.mp4";
678        boolean flagForException = false;
679        final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
680        try {
681            new MediaVideoItem(mVideoEditor, "m1", videoItemFilename,
682                renderingMode);
683        } catch (IllegalArgumentException e) {
684            flagForException = true;
685        }
686        assertTrue("Media Properties for a MPEG2 File --Unsupported file type",
687            flagForException);
688    }
689
690    /**
691     *To test Media Properties for file without Video only Audio
692     */
693    @LargeTest
694    public void testProperties3GPWithoutVideoMediaItem() throws Exception {
695        final String audioFilename = INPUT_FILE_PATH +
696            "AACLC_48KHz_256Kbps_s_1_17.3gp";
697        boolean flagForException = false;
698        final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
699        try {
700            new MediaVideoItem(mVideoEditor, "m1", audioFilename,
701                renderingMode);
702        } catch (IllegalArgumentException e) {
703            flagForException = true;
704        }
705        assertTrue("Exception in Creaing Media Video item object without video",
706            flagForException);
707    }
708
709    /**
710     *To test media properties for Audio Track file. (No Video, AAC Audio)
711     */
712    @LargeTest
713    public void testProperties3GPWithoutVideoAudioTrack() throws Exception {
714
715        final String audioFilename = INPUT_FILE_PATH +
716            "AACLC_44.1kHz_256kbps_s_1_17.mp4";
717        final int duration = 77554;
718        final int audioBitrate = 384000;
719        final int audioCodecType = MediaProperties.ACODEC_AAC_LC;
720        final int audioSamplingFrequency = 44100;
721        final int audioChannel = 2;
722
723        final AudioTrack audioTrack = mVideoEditorHelper.createAudio
724            (mVideoEditor, "a1", audioFilename);
725
726        validateAudioProperties(audioCodecType, duration, audioSamplingFrequency,
727            audioChannel, audioBitrate, audioTrack);
728    }
729
730        /**
731     *To test media properties for Audio Track file. MP3 file
732     */
733    @LargeTest
734    public void testPropertiesMP3AudioTrack() throws Exception {
735
736        final String audioFilename = INPUT_FILE_PATH +
737            "MP3_48KHz_128kbps_s_1_17.mp3";
738        final int duration = 77640;
739        final int audioBitrate = 128000;
740        final int audioCodecType = MediaProperties.ACODEC_MP3;
741        final int audioSamplingFrequency = 48000;
742        final int audioChannel = 2;
743
744        final AudioTrack audioTrack = mVideoEditorHelper.createAudio
745            (mVideoEditor, "a1", audioFilename);
746
747        validateAudioProperties(audioCodecType, duration, audioSamplingFrequency,
748            audioChannel, audioBitrate, audioTrack);
749    }
750}
751