CamcorderProfile.java revision 52bfc243684b2f340da326aaa38e9021e4e3b2e6
1e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong/* 2e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong * Copyright (C) 2010 The Android Open Source Project 3e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong * 4e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong * Licensed under the Apache License, Version 2.0 (the "License"); 5e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong * you may not use this file except in compliance with the License. 6e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong * You may obtain a copy of the License at 7e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong * 8e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong * http://www.apache.org/licenses/LICENSE-2.0 9e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong * 10e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong * Unless required by applicable law or agreed to in writing, software 11e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong * distributed under the License is distributed on an "AS IS" BASIS, 12e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong * See the License for the specific language governing permissions and 14e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong * limitations under the License. 15e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong */ 16e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong 17e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dongpackage android.media; 18e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong 195680635f39b3098539cbfd120f95fdc4479bab0fWu-cheng Liimport android.hardware.Camera; 205680635f39b3098539cbfd120f95fdc4479bab0fWu-cheng Liimport android.hardware.Camera.CameraInfo; 215680635f39b3098539cbfd120f95fdc4479bab0fWu-cheng Li 22e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong/** 2352bfc243684b2f340da326aaa38e9021e4e3b2e6Scott Main * Retrieves the 24e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong * predefined camcorder profile settings for camcorder applications. 25e64d9a236e4704abf53d3b7eea2eb066f23cf402James Dong * These settings are read-only. 26e64d9a236e4704abf53d3b7eea2eb066f23cf402James Dong * 2752bfc243684b2f340da326aaa38e9021e4e3b2e6Scott Main * <p>The compressed output from a recording session with a given 2852bfc243684b2f340da326aaa38e9021e4e3b2e6Scott Main * CamcorderProfile contains two tracks: one for audio and one for video. 29e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong * 30e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong * <p>Each profile specifies the following set of parameters: 31e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong * <ul> 32e64d9a236e4704abf53d3b7eea2eb066f23cf402James Dong * <li> The file output format 33e64d9a236e4704abf53d3b7eea2eb066f23cf402James Dong * <li> Video codec format 34e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong * <li> Video bit rate in bits per second 35e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong * <li> Video frame rate in frames per second 36e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong * <li> Video frame width and height, 37e64d9a236e4704abf53d3b7eea2eb066f23cf402James Dong * <li> Audio codec format 38e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong * <li> Audio bit rate in bits per second, 39e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong * <li> Audio sample rate 40e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong * <li> Number of audio channels for recording. 41e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong * </ul> 42e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong */ 43e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dongpublic class CamcorderProfile 44e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong{ 454af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra // Do not change these values/ordinals without updating their counterpart 464af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra // in include/media/MediaProfiles.h! 474af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra 48e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong /** 494af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra * Quality level corresponding to the lowest available resolution. 50e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong */ 51e64d9a236e4704abf53d3b7eea2eb066f23cf402James Dong public static final int QUALITY_LOW = 0; 524af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra 534af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra /** 544af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra * Quality level corresponding to the highest available resolution. 554af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra */ 56e64d9a236e4704abf53d3b7eea2eb066f23cf402James Dong public static final int QUALITY_HIGH = 1; 57e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong 58e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong /** 59522632cde516001429549c60bd570c399ffad800Nipun Kwatra * Quality level corresponding to the qcif (176 x 144) resolution. 604af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra */ 61522632cde516001429549c60bd570c399ffad800Nipun Kwatra public static final int QUALITY_QCIF = 2; 62522632cde516001429549c60bd570c399ffad800Nipun Kwatra 63522632cde516001429549c60bd570c399ffad800Nipun Kwatra /** 64522632cde516001429549c60bd570c399ffad800Nipun Kwatra * Quality level corresponding to the cif (352 x 288) resolution. 65522632cde516001429549c60bd570c399ffad800Nipun Kwatra */ 66522632cde516001429549c60bd570c399ffad800Nipun Kwatra public static final int QUALITY_CIF = 3; 674af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra 684af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra /** 694af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra * Quality level corresponding to the 480p (720 x 480) resolution. 704af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra */ 71522632cde516001429549c60bd570c399ffad800Nipun Kwatra public static final int QUALITY_480P = 4; 724af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra 734af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra /** 744af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra * Quality level corresponding to the 720p (1280 x 720) resolution. 754af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra */ 76522632cde516001429549c60bd570c399ffad800Nipun Kwatra public static final int QUALITY_720P = 5; 774af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra 784af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra /** 794af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra * Quality level corresponding to the 1080p (1920 x 1088) resolution. 804af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra */ 81522632cde516001429549c60bd570c399ffad800Nipun Kwatra public static final int QUALITY_1080P = 6; 824af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra 834af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra /** 8407b9ae33127212fd9e15f96fa89b7d4cab81e55eJames Dong * Quality level corresponding to the QVGA (320x240) resolution. 8507b9ae33127212fd9e15f96fa89b7d4cab81e55eJames Dong */ 8607b9ae33127212fd9e15f96fa89b7d4cab81e55eJames Dong public static final int QUALITY_QVGA = 7; 8707b9ae33127212fd9e15f96fa89b7d4cab81e55eJames Dong 8807b9ae33127212fd9e15f96fa89b7d4cab81e55eJames Dong // Start and end of quality list 8907b9ae33127212fd9e15f96fa89b7d4cab81e55eJames Dong private static final int QUALITY_LIST_START = QUALITY_LOW; 9007b9ae33127212fd9e15f96fa89b7d4cab81e55eJames Dong private static final int QUALITY_LIST_END = QUALITY_QVGA; 9107b9ae33127212fd9e15f96fa89b7d4cab81e55eJames Dong 9207b9ae33127212fd9e15f96fa89b7d4cab81e55eJames Dong /** 934af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra * Time lapse quality level corresponding to the lowest available resolution. 944af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra */ 95522632cde516001429549c60bd570c399ffad800Nipun Kwatra public static final int QUALITY_TIME_LAPSE_LOW = 1000; 964af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra 974af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra /** 984af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra * Time lapse quality level corresponding to the highest available resolution. 994af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra */ 100522632cde516001429549c60bd570c399ffad800Nipun Kwatra public static final int QUALITY_TIME_LAPSE_HIGH = 1001; 101522632cde516001429549c60bd570c399ffad800Nipun Kwatra 102522632cde516001429549c60bd570c399ffad800Nipun Kwatra /** 103522632cde516001429549c60bd570c399ffad800Nipun Kwatra * Time lapse quality level corresponding to the qcif (176 x 144) resolution. 104522632cde516001429549c60bd570c399ffad800Nipun Kwatra */ 105522632cde516001429549c60bd570c399ffad800Nipun Kwatra public static final int QUALITY_TIME_LAPSE_QCIF = 1002; 1064af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra 1074af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra /** 108522632cde516001429549c60bd570c399ffad800Nipun Kwatra * Time lapse quality level corresponding to the cif (352 x 288) resolution. 1094af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra */ 110522632cde516001429549c60bd570c399ffad800Nipun Kwatra public static final int QUALITY_TIME_LAPSE_CIF = 1003; 1114af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra 1124af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra /** 1134af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra * Time lapse quality level corresponding to the 480p (720 x 480) resolution. 1144af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra */ 115522632cde516001429549c60bd570c399ffad800Nipun Kwatra public static final int QUALITY_TIME_LAPSE_480P = 1004; 1164af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra 1174af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra /** 1184af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra * Time lapse quality level corresponding to the 720p (1280 x 720) resolution. 1194af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra */ 120522632cde516001429549c60bd570c399ffad800Nipun Kwatra public static final int QUALITY_TIME_LAPSE_720P = 1005; 1214af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra 1224af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra /** 1234af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra * Time lapse quality level corresponding to the 1080p (1920 x 1088) resolution. 1244af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra */ 125522632cde516001429549c60bd570c399ffad800Nipun Kwatra public static final int QUALITY_TIME_LAPSE_1080P = 1006; 1264af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra 1274af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra /** 12807b9ae33127212fd9e15f96fa89b7d4cab81e55eJames Dong * Time lapse quality level corresponding to the QVGA (320 x 240) resolution. 12907b9ae33127212fd9e15f96fa89b7d4cab81e55eJames Dong */ 13007b9ae33127212fd9e15f96fa89b7d4cab81e55eJames Dong public static final int QUALITY_TIME_LAPSE_QVGA = 1007; 13107b9ae33127212fd9e15f96fa89b7d4cab81e55eJames Dong 13207b9ae33127212fd9e15f96fa89b7d4cab81e55eJames Dong // Start and end of timelapse quality list 13307b9ae33127212fd9e15f96fa89b7d4cab81e55eJames Dong private static final int QUALITY_TIME_LAPSE_LIST_START = QUALITY_TIME_LAPSE_LOW; 13407b9ae33127212fd9e15f96fa89b7d4cab81e55eJames Dong private static final int QUALITY_TIME_LAPSE_LIST_END = QUALITY_TIME_LAPSE_QVGA; 13507b9ae33127212fd9e15f96fa89b7d4cab81e55eJames Dong 13607b9ae33127212fd9e15f96fa89b7d4cab81e55eJames Dong /** 137e64d9a236e4704abf53d3b7eea2eb066f23cf402James Dong * Default recording duration in seconds before the session is terminated. 138e64d9a236e4704abf53d3b7eea2eb066f23cf402James Dong * This is useful for applications like MMS has limited file size requirement. 1399b433f0b654d32530b0b48a7a653216ae0bb94d8James Dong */ 140e64d9a236e4704abf53d3b7eea2eb066f23cf402James Dong public int duration; 1419b433f0b654d32530b0b48a7a653216ae0bb94d8James Dong 1429b433f0b654d32530b0b48a7a653216ae0bb94d8James Dong /** 143e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong * The quality level of the camcorder profile 144e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong */ 145e64d9a236e4704abf53d3b7eea2eb066f23cf402James Dong public int quality; 146e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong 147e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong /** 148e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong * The file output format of the camcorder profile 149e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong * @see android.media.MediaRecorder.OutputFormat 150e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong */ 151e64d9a236e4704abf53d3b7eea2eb066f23cf402James Dong public int fileFormat; 152e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong 153e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong /** 154e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong * The video encoder being used for the video track 155e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong * @see android.media.MediaRecorder.VideoEncoder 156e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong */ 157e64d9a236e4704abf53d3b7eea2eb066f23cf402James Dong public int videoCodec; 158e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong 159e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong /** 160e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong * The target video output bit rate in bits per second 161e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong */ 162e64d9a236e4704abf53d3b7eea2eb066f23cf402James Dong public int videoBitRate; 163e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong 164e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong /** 165e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong * The target video frame rate in frames per second 166e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong */ 167e64d9a236e4704abf53d3b7eea2eb066f23cf402James Dong public int videoFrameRate; 168e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong 169e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong /** 170e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong * The target video frame width in pixels 171e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong */ 172e64d9a236e4704abf53d3b7eea2eb066f23cf402James Dong public int videoFrameWidth; 173e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong 174e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong /** 175e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong * The target video frame height in pixels 176e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong */ 177e64d9a236e4704abf53d3b7eea2eb066f23cf402James Dong public int videoFrameHeight; 178e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong 179e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong /** 180e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong * The audio encoder being used for the audio track. 181e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong * @see android.media.MediaRecorder.AudioEncoder 182e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong */ 183e64d9a236e4704abf53d3b7eea2eb066f23cf402James Dong public int audioCodec; 184e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong 185e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong /** 186e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong * The target audio output bit rate in bits per second 187e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong */ 188e64d9a236e4704abf53d3b7eea2eb066f23cf402James Dong public int audioBitRate; 189e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong 190e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong /** 191e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong * The audio sampling rate used for the audio track 192e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong */ 193e64d9a236e4704abf53d3b7eea2eb066f23cf402James Dong public int audioSampleRate; 194e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong 195e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong /** 196e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong * The number of audio channels used for the audio track 197e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong */ 198e64d9a236e4704abf53d3b7eea2eb066f23cf402James Dong public int audioChannels; 199e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong 200e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong /** 2015680635f39b3098539cbfd120f95fdc4479bab0fWu-cheng Li * Returns the camcorder profile for the first back-facing camera on the 2025680635f39b3098539cbfd120f95fdc4479bab0fWu-cheng Li * device at the given quality level. If the device has no back-facing 2035680635f39b3098539cbfd120f95fdc4479bab0fWu-cheng Li * camera, this returns null. 204e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong * @param quality the target quality level for the camcorder profile 2054af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra * @see #get(int, int) 206e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong */ 207e64d9a236e4704abf53d3b7eea2eb066f23cf402James Dong public static CamcorderProfile get(int quality) { 2085680635f39b3098539cbfd120f95fdc4479bab0fWu-cheng Li int numberOfCameras = Camera.getNumberOfCameras(); 2095680635f39b3098539cbfd120f95fdc4479bab0fWu-cheng Li CameraInfo cameraInfo = new CameraInfo(); 2105680635f39b3098539cbfd120f95fdc4479bab0fWu-cheng Li for (int i = 0; i < numberOfCameras; i++) { 2115680635f39b3098539cbfd120f95fdc4479bab0fWu-cheng Li Camera.getCameraInfo(i, cameraInfo); 2125680635f39b3098539cbfd120f95fdc4479bab0fWu-cheng Li if (cameraInfo.facing == CameraInfo.CAMERA_FACING_BACK) { 2135680635f39b3098539cbfd120f95fdc4479bab0fWu-cheng Li return get(i, quality); 2145680635f39b3098539cbfd120f95fdc4479bab0fWu-cheng Li } 2155680635f39b3098539cbfd120f95fdc4479bab0fWu-cheng Li } 2165680635f39b3098539cbfd120f95fdc4479bab0fWu-cheng Li return null; 21709b9005769f2b717f637131578ce6cfa6bd62bd9Chih-Chung Chang } 21809b9005769f2b717f637131578ce6cfa6bd62bd9Chih-Chung Chang 21909b9005769f2b717f637131578ce6cfa6bd62bd9Chih-Chung Chang /** 22009b9005769f2b717f637131578ce6cfa6bd62bd9Chih-Chung Chang * Returns the camcorder profile for the given camera at the given 22109b9005769f2b717f637131578ce6cfa6bd62bd9Chih-Chung Chang * quality level. 2224af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra * 2234af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra * Quality levels QUALITY_LOW, QUALITY_HIGH are guaranteed to be supported, while 224522632cde516001429549c60bd570c399ffad800Nipun Kwatra * other levels may or may not be supported. The supported levels can be checked using 225522632cde516001429549c60bd570c399ffad800Nipun Kwatra * {@link #hasProfile(int, int)}. 2264af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra * QUALITY_LOW refers to the lowest quality available, while QUALITY_HIGH refers to 2274af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra * the highest quality available. 228522632cde516001429549c60bd570c399ffad800Nipun Kwatra * QUALITY_LOW/QUALITY_HIGH have to match one of qcif, cif, 480p, 720p, or 1080p. 2294af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra * E.g. if the device supports 480p, 720p, and 1080p, then low is 480p and high is 2304af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra * 1080p. 2314af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra * 232d48a15c3fead59a1aa710a16bb5f923164475918Nipun Kwatra * The same is true for time lapse quality levels, i.e. QUALITY_TIME_LAPSE_LOW, 233d48a15c3fead59a1aa710a16bb5f923164475918Nipun Kwatra * QUALITY_TIME_LAPSE_HIGH are guaranteed to be supported and have to match one of 234d48a15c3fead59a1aa710a16bb5f923164475918Nipun Kwatra * qcif, cif, 480p, 720p, or 1080p. 235d48a15c3fead59a1aa710a16bb5f923164475918Nipun Kwatra * 2364af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra * A camcorder recording session with higher quality level usually has higher output 2374af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra * bit rate, better video and/or audio recording quality, larger video frame 2384af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra * resolution and higher audio sampling rate, etc, than those with lower quality 2394af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra * level. 2404af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra * 24109b9005769f2b717f637131578ce6cfa6bd62bd9Chih-Chung Chang * @param cameraId the id for the camera 2424af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra * @param quality the target quality level for the camcorder profile. 243522632cde516001429549c60bd570c399ffad800Nipun Kwatra * @see #QUALITY_LOW 244522632cde516001429549c60bd570c399ffad800Nipun Kwatra * @see #QUALITY_HIGH 245522632cde516001429549c60bd570c399ffad800Nipun Kwatra * @see #QUALITY_QCIF 246522632cde516001429549c60bd570c399ffad800Nipun Kwatra * @see #QUALITY_CIF 247522632cde516001429549c60bd570c399ffad800Nipun Kwatra * @see #QUALITY_480P 248522632cde516001429549c60bd570c399ffad800Nipun Kwatra * @see #QUALITY_720P 249522632cde516001429549c60bd570c399ffad800Nipun Kwatra * @see #QUALITY_1080P 250522632cde516001429549c60bd570c399ffad800Nipun Kwatra * @see #QUALITY_TIME_LAPSE_LOW 251522632cde516001429549c60bd570c399ffad800Nipun Kwatra * @see #QUALITY_TIME_LAPSE_HIGH 252522632cde516001429549c60bd570c399ffad800Nipun Kwatra * @see #QUALITY_TIME_LAPSE_QCIF 253522632cde516001429549c60bd570c399ffad800Nipun Kwatra * @see #QUALITY_TIME_LAPSE_CIF 254522632cde516001429549c60bd570c399ffad800Nipun Kwatra * @see #QUALITY_TIME_LAPSE_480P 255522632cde516001429549c60bd570c399ffad800Nipun Kwatra * @see #QUALITY_TIME_LAPSE_720P 256522632cde516001429549c60bd570c399ffad800Nipun Kwatra * @see #QUALITY_TIME_LAPSE_1080P 25709b9005769f2b717f637131578ce6cfa6bd62bd9Chih-Chung Chang */ 25809b9005769f2b717f637131578ce6cfa6bd62bd9Chih-Chung Chang public static CamcorderProfile get(int cameraId, int quality) { 25907b9ae33127212fd9e15f96fa89b7d4cab81e55eJames Dong if (!((quality >= QUALITY_LIST_START && 26007b9ae33127212fd9e15f96fa89b7d4cab81e55eJames Dong quality <= QUALITY_LIST_END) || 26107b9ae33127212fd9e15f96fa89b7d4cab81e55eJames Dong (quality >= QUALITY_TIME_LAPSE_LIST_START && 26207b9ae33127212fd9e15f96fa89b7d4cab81e55eJames Dong quality <= QUALITY_TIME_LAPSE_LIST_END))) { 263e64d9a236e4704abf53d3b7eea2eb066f23cf402James Dong String errMessage = "Unsupported quality level: " + quality; 264e64d9a236e4704abf53d3b7eea2eb066f23cf402James Dong throw new IllegalArgumentException(errMessage); 265e64d9a236e4704abf53d3b7eea2eb066f23cf402James Dong } 26609b9005769f2b717f637131578ce6cfa6bd62bd9Chih-Chung Chang return native_get_camcorder_profile(cameraId, quality); 267e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong } 268e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong 2699d619542bea7d4c376a5a8b4a55c795a796adef3Nipun Kwatra /** 2705680635f39b3098539cbfd120f95fdc4479bab0fWu-cheng Li * Returns true if camcorder profile exists for the first back-facing 2715680635f39b3098539cbfd120f95fdc4479bab0fWu-cheng Li * camera at the given quality level. 2729d619542bea7d4c376a5a8b4a55c795a796adef3Nipun Kwatra * @param quality the target quality level for the camcorder profile 2739d619542bea7d4c376a5a8b4a55c795a796adef3Nipun Kwatra */ 2749d619542bea7d4c376a5a8b4a55c795a796adef3Nipun Kwatra public static boolean hasProfile(int quality) { 2755680635f39b3098539cbfd120f95fdc4479bab0fWu-cheng Li int numberOfCameras = Camera.getNumberOfCameras(); 2765680635f39b3098539cbfd120f95fdc4479bab0fWu-cheng Li CameraInfo cameraInfo = new CameraInfo(); 2775680635f39b3098539cbfd120f95fdc4479bab0fWu-cheng Li for (int i = 0; i < numberOfCameras; i++) { 2785680635f39b3098539cbfd120f95fdc4479bab0fWu-cheng Li Camera.getCameraInfo(i, cameraInfo); 2795680635f39b3098539cbfd120f95fdc4479bab0fWu-cheng Li if (cameraInfo.facing == CameraInfo.CAMERA_FACING_BACK) { 2805680635f39b3098539cbfd120f95fdc4479bab0fWu-cheng Li return hasProfile(i, quality); 2815680635f39b3098539cbfd120f95fdc4479bab0fWu-cheng Li } 2825680635f39b3098539cbfd120f95fdc4479bab0fWu-cheng Li } 2835680635f39b3098539cbfd120f95fdc4479bab0fWu-cheng Li return false; 2849d619542bea7d4c376a5a8b4a55c795a796adef3Nipun Kwatra } 2859d619542bea7d4c376a5a8b4a55c795a796adef3Nipun Kwatra 2869d619542bea7d4c376a5a8b4a55c795a796adef3Nipun Kwatra /** 2879d619542bea7d4c376a5a8b4a55c795a796adef3Nipun Kwatra * Returns true if camcorder profile exists for the given camera at 2889d619542bea7d4c376a5a8b4a55c795a796adef3Nipun Kwatra * the given quality level. 2899d619542bea7d4c376a5a8b4a55c795a796adef3Nipun Kwatra * @param cameraId the id for the camera 2909d619542bea7d4c376a5a8b4a55c795a796adef3Nipun Kwatra * @param quality the target quality level for the camcorder profile 2919d619542bea7d4c376a5a8b4a55c795a796adef3Nipun Kwatra */ 2929d619542bea7d4c376a5a8b4a55c795a796adef3Nipun Kwatra public static boolean hasProfile(int cameraId, int quality) { 2939d619542bea7d4c376a5a8b4a55c795a796adef3Nipun Kwatra return native_has_camcorder_profile(cameraId, quality); 2949d619542bea7d4c376a5a8b4a55c795a796adef3Nipun Kwatra } 2959d619542bea7d4c376a5a8b4a55c795a796adef3Nipun Kwatra 296e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong static { 297e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong System.loadLibrary("media_jni"); 298e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong native_init(); 299e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong } 300e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong 301e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong // Private constructor called by JNI 3029b433f0b654d32530b0b48a7a653216ae0bb94d8James Dong private CamcorderProfile(int duration, 3039b433f0b654d32530b0b48a7a653216ae0bb94d8James Dong int quality, 304e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong int fileFormat, 305e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong int videoCodec, 306e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong int videoBitRate, 307e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong int videoFrameRate, 308e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong int videoWidth, 309e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong int videoHeight, 310e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong int audioCodec, 311e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong int audioBitRate, 312e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong int audioSampleRate, 313e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong int audioChannels) { 314e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong 315e64d9a236e4704abf53d3b7eea2eb066f23cf402James Dong this.duration = duration; 316e64d9a236e4704abf53d3b7eea2eb066f23cf402James Dong this.quality = quality; 317e64d9a236e4704abf53d3b7eea2eb066f23cf402James Dong this.fileFormat = fileFormat; 318e64d9a236e4704abf53d3b7eea2eb066f23cf402James Dong this.videoCodec = videoCodec; 319e64d9a236e4704abf53d3b7eea2eb066f23cf402James Dong this.videoBitRate = videoBitRate; 320e64d9a236e4704abf53d3b7eea2eb066f23cf402James Dong this.videoFrameRate = videoFrameRate; 321e64d9a236e4704abf53d3b7eea2eb066f23cf402James Dong this.videoFrameWidth = videoWidth; 322e64d9a236e4704abf53d3b7eea2eb066f23cf402James Dong this.videoFrameHeight = videoHeight; 323e64d9a236e4704abf53d3b7eea2eb066f23cf402James Dong this.audioCodec = audioCodec; 324e64d9a236e4704abf53d3b7eea2eb066f23cf402James Dong this.audioBitRate = audioBitRate; 325e64d9a236e4704abf53d3b7eea2eb066f23cf402James Dong this.audioSampleRate = audioSampleRate; 326e64d9a236e4704abf53d3b7eea2eb066f23cf402James Dong this.audioChannels = audioChannels; 327e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong } 328e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong 329e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong // Methods implemented by JNI 330e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong private static native final void native_init(); 33109b9005769f2b717f637131578ce6cfa6bd62bd9Chih-Chung Chang private static native final CamcorderProfile native_get_camcorder_profile( 33209b9005769f2b717f637131578ce6cfa6bd62bd9Chih-Chung Chang int cameraId, int quality); 3339d619542bea7d4c376a5a8b4a55c795a796adef3Nipun Kwatra private static native final boolean native_has_camcorder_profile( 3349d619542bea7d4c376a5a8b4a55c795a796adef3Nipun Kwatra int cameraId, int quality); 335e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong} 336