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. 70a00c2939c7263fe421c33364a17e489c7c3a4d1fJames Dong * Note that the horizontal resolution for 480p can also be other 71a00c2939c7263fe421c33364a17e489c7c3a4d1fJames Dong * values, such as 640 or 704, instead of 720. 724af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra */ 73522632cde516001429549c60bd570c399ffad800Nipun Kwatra public static final int QUALITY_480P = 4; 744af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra 754af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra /** 764af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra * Quality level corresponding to the 720p (1280 x 720) resolution. 774af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra */ 78522632cde516001429549c60bd570c399ffad800Nipun Kwatra public static final int QUALITY_720P = 5; 794af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra 804af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra /** 81a00c2939c7263fe421c33364a17e489c7c3a4d1fJames Dong * Quality level corresponding to the 1080p (1920 x 1080) resolution. 82a00c2939c7263fe421c33364a17e489c7c3a4d1fJames Dong * Note that the vertical resolution for 1080p can also be 1088, 83a00c2939c7263fe421c33364a17e489c7c3a4d1fJames Dong * instead of 1080 (used by some vendors to avoid cropping during 84a00c2939c7263fe421c33364a17e489c7c3a4d1fJames Dong * video playback). 854af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra */ 86522632cde516001429549c60bd570c399ffad800Nipun Kwatra public static final int QUALITY_1080P = 6; 874af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra 884af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra /** 8907b9ae33127212fd9e15f96fa89b7d4cab81e55eJames Dong * Quality level corresponding to the QVGA (320x240) resolution. 9007b9ae33127212fd9e15f96fa89b7d4cab81e55eJames Dong */ 9107b9ae33127212fd9e15f96fa89b7d4cab81e55eJames Dong public static final int QUALITY_QVGA = 7; 9207b9ae33127212fd9e15f96fa89b7d4cab81e55eJames Dong 9307b9ae33127212fd9e15f96fa89b7d4cab81e55eJames Dong // Start and end of quality list 9407b9ae33127212fd9e15f96fa89b7d4cab81e55eJames Dong private static final int QUALITY_LIST_START = QUALITY_LOW; 9507b9ae33127212fd9e15f96fa89b7d4cab81e55eJames Dong private static final int QUALITY_LIST_END = QUALITY_QVGA; 9607b9ae33127212fd9e15f96fa89b7d4cab81e55eJames Dong 9707b9ae33127212fd9e15f96fa89b7d4cab81e55eJames Dong /** 984af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra * Time lapse quality level corresponding to the lowest available resolution. 994af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra */ 100522632cde516001429549c60bd570c399ffad800Nipun Kwatra public static final int QUALITY_TIME_LAPSE_LOW = 1000; 1014af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra 1024af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra /** 1034af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra * Time lapse quality level corresponding to the highest available resolution. 1044af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra */ 105522632cde516001429549c60bd570c399ffad800Nipun Kwatra public static final int QUALITY_TIME_LAPSE_HIGH = 1001; 106522632cde516001429549c60bd570c399ffad800Nipun Kwatra 107522632cde516001429549c60bd570c399ffad800Nipun Kwatra /** 108522632cde516001429549c60bd570c399ffad800Nipun Kwatra * Time lapse quality level corresponding to the qcif (176 x 144) resolution. 109522632cde516001429549c60bd570c399ffad800Nipun Kwatra */ 110522632cde516001429549c60bd570c399ffad800Nipun Kwatra public static final int QUALITY_TIME_LAPSE_QCIF = 1002; 1114af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra 1124af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra /** 113522632cde516001429549c60bd570c399ffad800Nipun Kwatra * Time lapse quality level corresponding to the cif (352 x 288) resolution. 1144af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra */ 115522632cde516001429549c60bd570c399ffad800Nipun Kwatra public static final int QUALITY_TIME_LAPSE_CIF = 1003; 1164af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra 1174af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra /** 1184af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra * Time lapse quality level corresponding to the 480p (720 x 480) resolution. 1194af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra */ 120522632cde516001429549c60bd570c399ffad800Nipun Kwatra public static final int QUALITY_TIME_LAPSE_480P = 1004; 1214af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra 1224af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra /** 1234af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra * Time lapse quality level corresponding to the 720p (1280 x 720) resolution. 1244af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra */ 125522632cde516001429549c60bd570c399ffad800Nipun Kwatra public static final int QUALITY_TIME_LAPSE_720P = 1005; 1264af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra 1274af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra /** 1284af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra * Time lapse quality level corresponding to the 1080p (1920 x 1088) resolution. 1294af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra */ 130522632cde516001429549c60bd570c399ffad800Nipun Kwatra public static final int QUALITY_TIME_LAPSE_1080P = 1006; 1314af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra 1324af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra /** 13307b9ae33127212fd9e15f96fa89b7d4cab81e55eJames Dong * Time lapse quality level corresponding to the QVGA (320 x 240) resolution. 13407b9ae33127212fd9e15f96fa89b7d4cab81e55eJames Dong */ 13507b9ae33127212fd9e15f96fa89b7d4cab81e55eJames Dong public static final int QUALITY_TIME_LAPSE_QVGA = 1007; 13607b9ae33127212fd9e15f96fa89b7d4cab81e55eJames Dong 13707b9ae33127212fd9e15f96fa89b7d4cab81e55eJames Dong // Start and end of timelapse quality list 13807b9ae33127212fd9e15f96fa89b7d4cab81e55eJames Dong private static final int QUALITY_TIME_LAPSE_LIST_START = QUALITY_TIME_LAPSE_LOW; 13907b9ae33127212fd9e15f96fa89b7d4cab81e55eJames Dong private static final int QUALITY_TIME_LAPSE_LIST_END = QUALITY_TIME_LAPSE_QVGA; 14007b9ae33127212fd9e15f96fa89b7d4cab81e55eJames Dong 14107b9ae33127212fd9e15f96fa89b7d4cab81e55eJames Dong /** 142e64d9a236e4704abf53d3b7eea2eb066f23cf402James Dong * Default recording duration in seconds before the session is terminated. 143e64d9a236e4704abf53d3b7eea2eb066f23cf402James Dong * This is useful for applications like MMS has limited file size requirement. 1449b433f0b654d32530b0b48a7a653216ae0bb94d8James Dong */ 145e64d9a236e4704abf53d3b7eea2eb066f23cf402James Dong public int duration; 1469b433f0b654d32530b0b48a7a653216ae0bb94d8James Dong 1479b433f0b654d32530b0b48a7a653216ae0bb94d8James Dong /** 148e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong * The quality level of the camcorder profile 149e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong */ 150e64d9a236e4704abf53d3b7eea2eb066f23cf402James Dong public int quality; 151e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong 152e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong /** 153e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong * The file output format of the camcorder profile 154e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong * @see android.media.MediaRecorder.OutputFormat 155e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong */ 156e64d9a236e4704abf53d3b7eea2eb066f23cf402James Dong public int fileFormat; 157e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong 158e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong /** 159e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong * The video encoder being used for the video track 160e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong * @see android.media.MediaRecorder.VideoEncoder 161e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong */ 162e64d9a236e4704abf53d3b7eea2eb066f23cf402James Dong public int videoCodec; 163e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong 164e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong /** 165e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong * The target video output bit rate in bits per second 166e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong */ 167e64d9a236e4704abf53d3b7eea2eb066f23cf402James Dong public int videoBitRate; 168e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong 169e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong /** 170e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong * The target video frame rate in frames per second 171e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong */ 172e64d9a236e4704abf53d3b7eea2eb066f23cf402James Dong public int videoFrameRate; 173e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong 174e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong /** 175e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong * The target video frame width in pixels 176e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong */ 177e64d9a236e4704abf53d3b7eea2eb066f23cf402James Dong public int videoFrameWidth; 178e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong 179e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong /** 180e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong * The target video frame height in pixels 181e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong */ 182e64d9a236e4704abf53d3b7eea2eb066f23cf402James Dong public int videoFrameHeight; 183e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong 184e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong /** 185e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong * The audio encoder being used for the audio track. 186e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong * @see android.media.MediaRecorder.AudioEncoder 187e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong */ 188e64d9a236e4704abf53d3b7eea2eb066f23cf402James Dong public int audioCodec; 189e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong 190e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong /** 191e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong * The target audio output bit rate in bits per second 192e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong */ 193e64d9a236e4704abf53d3b7eea2eb066f23cf402James Dong public int audioBitRate; 194e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong 195e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong /** 196e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong * The audio sampling rate used for the audio track 197e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong */ 198e64d9a236e4704abf53d3b7eea2eb066f23cf402James Dong public int audioSampleRate; 199e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong 200e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong /** 201e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong * The number of audio channels used for the audio track 202e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong */ 203e64d9a236e4704abf53d3b7eea2eb066f23cf402James Dong public int audioChannels; 204e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong 205e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong /** 2065680635f39b3098539cbfd120f95fdc4479bab0fWu-cheng Li * Returns the camcorder profile for the first back-facing camera on the 2075680635f39b3098539cbfd120f95fdc4479bab0fWu-cheng Li * device at the given quality level. If the device has no back-facing 2085680635f39b3098539cbfd120f95fdc4479bab0fWu-cheng Li * camera, this returns null. 209e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong * @param quality the target quality level for the camcorder profile 2104af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra * @see #get(int, int) 211e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong */ 212e64d9a236e4704abf53d3b7eea2eb066f23cf402James Dong public static CamcorderProfile get(int quality) { 2135680635f39b3098539cbfd120f95fdc4479bab0fWu-cheng Li int numberOfCameras = Camera.getNumberOfCameras(); 2145680635f39b3098539cbfd120f95fdc4479bab0fWu-cheng Li CameraInfo cameraInfo = new CameraInfo(); 2155680635f39b3098539cbfd120f95fdc4479bab0fWu-cheng Li for (int i = 0; i < numberOfCameras; i++) { 2165680635f39b3098539cbfd120f95fdc4479bab0fWu-cheng Li Camera.getCameraInfo(i, cameraInfo); 2175680635f39b3098539cbfd120f95fdc4479bab0fWu-cheng Li if (cameraInfo.facing == CameraInfo.CAMERA_FACING_BACK) { 2185680635f39b3098539cbfd120f95fdc4479bab0fWu-cheng Li return get(i, quality); 2195680635f39b3098539cbfd120f95fdc4479bab0fWu-cheng Li } 2205680635f39b3098539cbfd120f95fdc4479bab0fWu-cheng Li } 2215680635f39b3098539cbfd120f95fdc4479bab0fWu-cheng Li return null; 22209b9005769f2b717f637131578ce6cfa6bd62bd9Chih-Chung Chang } 22309b9005769f2b717f637131578ce6cfa6bd62bd9Chih-Chung Chang 22409b9005769f2b717f637131578ce6cfa6bd62bd9Chih-Chung Chang /** 22509b9005769f2b717f637131578ce6cfa6bd62bd9Chih-Chung Chang * Returns the camcorder profile for the given camera at the given 22609b9005769f2b717f637131578ce6cfa6bd62bd9Chih-Chung Chang * quality level. 2274af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra * 2284af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra * Quality levels QUALITY_LOW, QUALITY_HIGH are guaranteed to be supported, while 229522632cde516001429549c60bd570c399ffad800Nipun Kwatra * other levels may or may not be supported. The supported levels can be checked using 230522632cde516001429549c60bd570c399ffad800Nipun Kwatra * {@link #hasProfile(int, int)}. 2314af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra * QUALITY_LOW refers to the lowest quality available, while QUALITY_HIGH refers to 2324af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra * the highest quality available. 233522632cde516001429549c60bd570c399ffad800Nipun Kwatra * QUALITY_LOW/QUALITY_HIGH have to match one of qcif, cif, 480p, 720p, or 1080p. 2344af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra * E.g. if the device supports 480p, 720p, and 1080p, then low is 480p and high is 2354af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra * 1080p. 2364af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra * 237d48a15c3fead59a1aa710a16bb5f923164475918Nipun Kwatra * The same is true for time lapse quality levels, i.e. QUALITY_TIME_LAPSE_LOW, 238d48a15c3fead59a1aa710a16bb5f923164475918Nipun Kwatra * QUALITY_TIME_LAPSE_HIGH are guaranteed to be supported and have to match one of 239d48a15c3fead59a1aa710a16bb5f923164475918Nipun Kwatra * qcif, cif, 480p, 720p, or 1080p. 240d48a15c3fead59a1aa710a16bb5f923164475918Nipun Kwatra * 2414af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra * A camcorder recording session with higher quality level usually has higher output 2424af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra * bit rate, better video and/or audio recording quality, larger video frame 2434af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra * resolution and higher audio sampling rate, etc, than those with lower quality 2444af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra * level. 2454af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra * 24609b9005769f2b717f637131578ce6cfa6bd62bd9Chih-Chung Chang * @param cameraId the id for the camera 2474af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra * @param quality the target quality level for the camcorder profile. 248522632cde516001429549c60bd570c399ffad800Nipun Kwatra * @see #QUALITY_LOW 249522632cde516001429549c60bd570c399ffad800Nipun Kwatra * @see #QUALITY_HIGH 250522632cde516001429549c60bd570c399ffad800Nipun Kwatra * @see #QUALITY_QCIF 251522632cde516001429549c60bd570c399ffad800Nipun Kwatra * @see #QUALITY_CIF 252522632cde516001429549c60bd570c399ffad800Nipun Kwatra * @see #QUALITY_480P 253522632cde516001429549c60bd570c399ffad800Nipun Kwatra * @see #QUALITY_720P 254522632cde516001429549c60bd570c399ffad800Nipun Kwatra * @see #QUALITY_1080P 255522632cde516001429549c60bd570c399ffad800Nipun Kwatra * @see #QUALITY_TIME_LAPSE_LOW 256522632cde516001429549c60bd570c399ffad800Nipun Kwatra * @see #QUALITY_TIME_LAPSE_HIGH 257522632cde516001429549c60bd570c399ffad800Nipun Kwatra * @see #QUALITY_TIME_LAPSE_QCIF 258522632cde516001429549c60bd570c399ffad800Nipun Kwatra * @see #QUALITY_TIME_LAPSE_CIF 259522632cde516001429549c60bd570c399ffad800Nipun Kwatra * @see #QUALITY_TIME_LAPSE_480P 260522632cde516001429549c60bd570c399ffad800Nipun Kwatra * @see #QUALITY_TIME_LAPSE_720P 261522632cde516001429549c60bd570c399ffad800Nipun Kwatra * @see #QUALITY_TIME_LAPSE_1080P 26209b9005769f2b717f637131578ce6cfa6bd62bd9Chih-Chung Chang */ 26309b9005769f2b717f637131578ce6cfa6bd62bd9Chih-Chung Chang public static CamcorderProfile get(int cameraId, int quality) { 26407b9ae33127212fd9e15f96fa89b7d4cab81e55eJames Dong if (!((quality >= QUALITY_LIST_START && 26507b9ae33127212fd9e15f96fa89b7d4cab81e55eJames Dong quality <= QUALITY_LIST_END) || 26607b9ae33127212fd9e15f96fa89b7d4cab81e55eJames Dong (quality >= QUALITY_TIME_LAPSE_LIST_START && 26707b9ae33127212fd9e15f96fa89b7d4cab81e55eJames Dong quality <= QUALITY_TIME_LAPSE_LIST_END))) { 268e64d9a236e4704abf53d3b7eea2eb066f23cf402James Dong String errMessage = "Unsupported quality level: " + quality; 269e64d9a236e4704abf53d3b7eea2eb066f23cf402James Dong throw new IllegalArgumentException(errMessage); 270e64d9a236e4704abf53d3b7eea2eb066f23cf402James Dong } 27109b9005769f2b717f637131578ce6cfa6bd62bd9Chih-Chung Chang return native_get_camcorder_profile(cameraId, quality); 272e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong } 273e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong 2749d619542bea7d4c376a5a8b4a55c795a796adef3Nipun Kwatra /** 2755680635f39b3098539cbfd120f95fdc4479bab0fWu-cheng Li * Returns true if camcorder profile exists for the first back-facing 2765680635f39b3098539cbfd120f95fdc4479bab0fWu-cheng Li * camera at the given quality level. 2779d619542bea7d4c376a5a8b4a55c795a796adef3Nipun Kwatra * @param quality the target quality level for the camcorder profile 2789d619542bea7d4c376a5a8b4a55c795a796adef3Nipun Kwatra */ 2799d619542bea7d4c376a5a8b4a55c795a796adef3Nipun Kwatra public static boolean hasProfile(int quality) { 2805680635f39b3098539cbfd120f95fdc4479bab0fWu-cheng Li int numberOfCameras = Camera.getNumberOfCameras(); 2815680635f39b3098539cbfd120f95fdc4479bab0fWu-cheng Li CameraInfo cameraInfo = new CameraInfo(); 2825680635f39b3098539cbfd120f95fdc4479bab0fWu-cheng Li for (int i = 0; i < numberOfCameras; i++) { 2835680635f39b3098539cbfd120f95fdc4479bab0fWu-cheng Li Camera.getCameraInfo(i, cameraInfo); 2845680635f39b3098539cbfd120f95fdc4479bab0fWu-cheng Li if (cameraInfo.facing == CameraInfo.CAMERA_FACING_BACK) { 2855680635f39b3098539cbfd120f95fdc4479bab0fWu-cheng Li return hasProfile(i, quality); 2865680635f39b3098539cbfd120f95fdc4479bab0fWu-cheng Li } 2875680635f39b3098539cbfd120f95fdc4479bab0fWu-cheng Li } 2885680635f39b3098539cbfd120f95fdc4479bab0fWu-cheng Li return false; 2899d619542bea7d4c376a5a8b4a55c795a796adef3Nipun Kwatra } 2909d619542bea7d4c376a5a8b4a55c795a796adef3Nipun Kwatra 2919d619542bea7d4c376a5a8b4a55c795a796adef3Nipun Kwatra /** 2929d619542bea7d4c376a5a8b4a55c795a796adef3Nipun Kwatra * Returns true if camcorder profile exists for the given camera at 2939d619542bea7d4c376a5a8b4a55c795a796adef3Nipun Kwatra * the given quality level. 2949d619542bea7d4c376a5a8b4a55c795a796adef3Nipun Kwatra * @param cameraId the id for the camera 2959d619542bea7d4c376a5a8b4a55c795a796adef3Nipun Kwatra * @param quality the target quality level for the camcorder profile 2969d619542bea7d4c376a5a8b4a55c795a796adef3Nipun Kwatra */ 2979d619542bea7d4c376a5a8b4a55c795a796adef3Nipun Kwatra public static boolean hasProfile(int cameraId, int quality) { 2989d619542bea7d4c376a5a8b4a55c795a796adef3Nipun Kwatra return native_has_camcorder_profile(cameraId, quality); 2999d619542bea7d4c376a5a8b4a55c795a796adef3Nipun Kwatra } 3009d619542bea7d4c376a5a8b4a55c795a796adef3Nipun Kwatra 301e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong static { 302e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong System.loadLibrary("media_jni"); 303e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong native_init(); 304e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong } 305e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong 306e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong // Private constructor called by JNI 3079b433f0b654d32530b0b48a7a653216ae0bb94d8James Dong private CamcorderProfile(int duration, 3089b433f0b654d32530b0b48a7a653216ae0bb94d8James Dong int quality, 309e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong int fileFormat, 310e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong int videoCodec, 311e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong int videoBitRate, 312e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong int videoFrameRate, 313e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong int videoWidth, 314e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong int videoHeight, 315e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong int audioCodec, 316e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong int audioBitRate, 317e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong int audioSampleRate, 318e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong int audioChannels) { 319e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong 320e64d9a236e4704abf53d3b7eea2eb066f23cf402James Dong this.duration = duration; 321e64d9a236e4704abf53d3b7eea2eb066f23cf402James Dong this.quality = quality; 322e64d9a236e4704abf53d3b7eea2eb066f23cf402James Dong this.fileFormat = fileFormat; 323e64d9a236e4704abf53d3b7eea2eb066f23cf402James Dong this.videoCodec = videoCodec; 324e64d9a236e4704abf53d3b7eea2eb066f23cf402James Dong this.videoBitRate = videoBitRate; 325e64d9a236e4704abf53d3b7eea2eb066f23cf402James Dong this.videoFrameRate = videoFrameRate; 326e64d9a236e4704abf53d3b7eea2eb066f23cf402James Dong this.videoFrameWidth = videoWidth; 327e64d9a236e4704abf53d3b7eea2eb066f23cf402James Dong this.videoFrameHeight = videoHeight; 328e64d9a236e4704abf53d3b7eea2eb066f23cf402James Dong this.audioCodec = audioCodec; 329e64d9a236e4704abf53d3b7eea2eb066f23cf402James Dong this.audioBitRate = audioBitRate; 330e64d9a236e4704abf53d3b7eea2eb066f23cf402James Dong this.audioSampleRate = audioSampleRate; 331e64d9a236e4704abf53d3b7eea2eb066f23cf402James Dong this.audioChannels = audioChannels; 332e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong } 333e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong 334e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong // Methods implemented by JNI 335e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong private static native final void native_init(); 33609b9005769f2b717f637131578ce6cfa6bd62bd9Chih-Chung Chang private static native final CamcorderProfile native_get_camcorder_profile( 33709b9005769f2b717f637131578ce6cfa6bd62bd9Chih-Chung Chang int cameraId, int quality); 3389d619542bea7d4c376a5a8b4a55c795a796adef3Nipun Kwatra private static native final boolean native_has_camcorder_profile( 3399d619542bea7d4c376a5a8b4a55c795a796adef3Nipun Kwatra int cameraId, int quality); 340e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong} 341