CamcorderProfile.java revision 5680635f39b3098539cbfd120f95fdc4479bab0f
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/** 23e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong * The CamcorderProfile class is used to retrieve the 24e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong * predefined camcorder profile settings for camcorder applications. 25e64d9a236e4704abf53d3b7eea2eb066f23cf402James Dong * These settings are read-only. 26e64d9a236e4704abf53d3b7eea2eb066f23cf402James Dong * 27e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong * The compressed output from a recording session with a given 28e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong * CamcorderProfile contains two tracks: one for auido 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 /** 844af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra * Time lapse quality level corresponding to the lowest available resolution. 854af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra */ 86522632cde516001429549c60bd570c399ffad800Nipun Kwatra public static final int QUALITY_TIME_LAPSE_LOW = 1000; 874af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra 884af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra /** 894af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra * Time lapse quality level corresponding to the highest available resolution. 904af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra */ 91522632cde516001429549c60bd570c399ffad800Nipun Kwatra public static final int QUALITY_TIME_LAPSE_HIGH = 1001; 92522632cde516001429549c60bd570c399ffad800Nipun Kwatra 93522632cde516001429549c60bd570c399ffad800Nipun Kwatra /** 94522632cde516001429549c60bd570c399ffad800Nipun Kwatra * Time lapse quality level corresponding to the qcif (176 x 144) resolution. 95522632cde516001429549c60bd570c399ffad800Nipun Kwatra */ 96522632cde516001429549c60bd570c399ffad800Nipun Kwatra public static final int QUALITY_TIME_LAPSE_QCIF = 1002; 974af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra 984af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra /** 99522632cde516001429549c60bd570c399ffad800Nipun Kwatra * Time lapse quality level corresponding to the cif (352 x 288) resolution. 1004af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra */ 101522632cde516001429549c60bd570c399ffad800Nipun Kwatra public static final int QUALITY_TIME_LAPSE_CIF = 1003; 1024af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra 1034af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra /** 1044af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra * Time lapse quality level corresponding to the 480p (720 x 480) resolution. 1054af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra */ 106522632cde516001429549c60bd570c399ffad800Nipun Kwatra public static final int QUALITY_TIME_LAPSE_480P = 1004; 1074af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra 1084af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra /** 1094af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra * Time lapse quality level corresponding to the 720p (1280 x 720) resolution. 1104af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra */ 111522632cde516001429549c60bd570c399ffad800Nipun Kwatra public static final int QUALITY_TIME_LAPSE_720P = 1005; 1124af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra 1134af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra /** 1144af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra * Time lapse quality level corresponding to the 1080p (1920 x 1088) resolution. 1154af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra */ 116522632cde516001429549c60bd570c399ffad800Nipun Kwatra public static final int QUALITY_TIME_LAPSE_1080P = 1006; 1174af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra 1184af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra /** 119e64d9a236e4704abf53d3b7eea2eb066f23cf402James Dong * Default recording duration in seconds before the session is terminated. 120e64d9a236e4704abf53d3b7eea2eb066f23cf402James Dong * This is useful for applications like MMS has limited file size requirement. 1219b433f0b654d32530b0b48a7a653216ae0bb94d8James Dong */ 122e64d9a236e4704abf53d3b7eea2eb066f23cf402James Dong public int duration; 1239b433f0b654d32530b0b48a7a653216ae0bb94d8James Dong 1249b433f0b654d32530b0b48a7a653216ae0bb94d8James Dong /** 125e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong * The quality level of the camcorder profile 126e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong */ 127e64d9a236e4704abf53d3b7eea2eb066f23cf402James Dong public int quality; 128e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong 129e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong /** 130e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong * The file output format of the camcorder profile 131e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong * @see android.media.MediaRecorder.OutputFormat 132e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong */ 133e64d9a236e4704abf53d3b7eea2eb066f23cf402James Dong public int fileFormat; 134e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong 135e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong /** 136e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong * The video encoder being used for the video track 137e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong * @see android.media.MediaRecorder.VideoEncoder 138e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong */ 139e64d9a236e4704abf53d3b7eea2eb066f23cf402James Dong public int videoCodec; 140e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong 141e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong /** 142e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong * The target video output bit rate in bits per second 143e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong */ 144e64d9a236e4704abf53d3b7eea2eb066f23cf402James Dong public int videoBitRate; 145e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong 146e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong /** 147e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong * The target video frame rate in frames per second 148e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong */ 149e64d9a236e4704abf53d3b7eea2eb066f23cf402James Dong public int videoFrameRate; 150e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong 151e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong /** 152e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong * The target video frame width in pixels 153e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong */ 154e64d9a236e4704abf53d3b7eea2eb066f23cf402James Dong public int videoFrameWidth; 155e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong 156e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong /** 157e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong * The target video frame height in pixels 158e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong */ 159e64d9a236e4704abf53d3b7eea2eb066f23cf402James Dong public int videoFrameHeight; 160e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong 161e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong /** 162e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong * The audio encoder being used for the audio track. 163e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong * @see android.media.MediaRecorder.AudioEncoder 164e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong */ 165e64d9a236e4704abf53d3b7eea2eb066f23cf402James Dong public int audioCodec; 166e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong 167e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong /** 168e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong * The target audio output bit rate in bits per second 169e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong */ 170e64d9a236e4704abf53d3b7eea2eb066f23cf402James Dong public int audioBitRate; 171e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong 172e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong /** 173e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong * The audio sampling rate used for the audio track 174e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong */ 175e64d9a236e4704abf53d3b7eea2eb066f23cf402James Dong public int audioSampleRate; 176e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong 177e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong /** 178e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong * The number of audio channels used for the audio track 179e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong */ 180e64d9a236e4704abf53d3b7eea2eb066f23cf402James Dong public int audioChannels; 181e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong 182e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong /** 1835680635f39b3098539cbfd120f95fdc4479bab0fWu-cheng Li * Returns the camcorder profile for the first back-facing camera on the 1845680635f39b3098539cbfd120f95fdc4479bab0fWu-cheng Li * device at the given quality level. If the device has no back-facing 1855680635f39b3098539cbfd120f95fdc4479bab0fWu-cheng Li * camera, this returns null. 186e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong * @param quality the target quality level for the camcorder profile 1874af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra * @see #get(int, int) 188e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong */ 189e64d9a236e4704abf53d3b7eea2eb066f23cf402James Dong public static CamcorderProfile get(int quality) { 1905680635f39b3098539cbfd120f95fdc4479bab0fWu-cheng Li int numberOfCameras = Camera.getNumberOfCameras(); 1915680635f39b3098539cbfd120f95fdc4479bab0fWu-cheng Li CameraInfo cameraInfo = new CameraInfo(); 1925680635f39b3098539cbfd120f95fdc4479bab0fWu-cheng Li for (int i = 0; i < numberOfCameras; i++) { 1935680635f39b3098539cbfd120f95fdc4479bab0fWu-cheng Li Camera.getCameraInfo(i, cameraInfo); 1945680635f39b3098539cbfd120f95fdc4479bab0fWu-cheng Li if (cameraInfo.facing == CameraInfo.CAMERA_FACING_BACK) { 1955680635f39b3098539cbfd120f95fdc4479bab0fWu-cheng Li return get(i, quality); 1965680635f39b3098539cbfd120f95fdc4479bab0fWu-cheng Li } 1975680635f39b3098539cbfd120f95fdc4479bab0fWu-cheng Li } 1985680635f39b3098539cbfd120f95fdc4479bab0fWu-cheng Li return null; 19909b9005769f2b717f637131578ce6cfa6bd62bd9Chih-Chung Chang } 20009b9005769f2b717f637131578ce6cfa6bd62bd9Chih-Chung Chang 20109b9005769f2b717f637131578ce6cfa6bd62bd9Chih-Chung Chang /** 20209b9005769f2b717f637131578ce6cfa6bd62bd9Chih-Chung Chang * Returns the camcorder profile for the given camera at the given 20309b9005769f2b717f637131578ce6cfa6bd62bd9Chih-Chung Chang * quality level. 2044af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra * 2054af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra * Quality levels QUALITY_LOW, QUALITY_HIGH are guaranteed to be supported, while 206522632cde516001429549c60bd570c399ffad800Nipun Kwatra * other levels may or may not be supported. The supported levels can be checked using 207522632cde516001429549c60bd570c399ffad800Nipun Kwatra * {@link #hasProfile(int, int)}. 2084af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra * QUALITY_LOW refers to the lowest quality available, while QUALITY_HIGH refers to 2094af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra * the highest quality available. 210522632cde516001429549c60bd570c399ffad800Nipun Kwatra * QUALITY_LOW/QUALITY_HIGH have to match one of qcif, cif, 480p, 720p, or 1080p. 2114af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra * E.g. if the device supports 480p, 720p, and 1080p, then low is 480p and high is 2124af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra * 1080p. 2134af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra * 214d48a15c3fead59a1aa710a16bb5f923164475918Nipun Kwatra * The same is true for time lapse quality levels, i.e. QUALITY_TIME_LAPSE_LOW, 215d48a15c3fead59a1aa710a16bb5f923164475918Nipun Kwatra * QUALITY_TIME_LAPSE_HIGH are guaranteed to be supported and have to match one of 216d48a15c3fead59a1aa710a16bb5f923164475918Nipun Kwatra * qcif, cif, 480p, 720p, or 1080p. 217d48a15c3fead59a1aa710a16bb5f923164475918Nipun Kwatra * 2184af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra * A camcorder recording session with higher quality level usually has higher output 2194af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra * bit rate, better video and/or audio recording quality, larger video frame 2204af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra * resolution and higher audio sampling rate, etc, than those with lower quality 2214af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra * level. 2224af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra * 22309b9005769f2b717f637131578ce6cfa6bd62bd9Chih-Chung Chang * @param cameraId the id for the camera 2244af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra * @param quality the target quality level for the camcorder profile. 225522632cde516001429549c60bd570c399ffad800Nipun Kwatra * @see #QUALITY_LOW 226522632cde516001429549c60bd570c399ffad800Nipun Kwatra * @see #QUALITY_HIGH 227522632cde516001429549c60bd570c399ffad800Nipun Kwatra * @see #QUALITY_QCIF 228522632cde516001429549c60bd570c399ffad800Nipun Kwatra * @see #QUALITY_CIF 229522632cde516001429549c60bd570c399ffad800Nipun Kwatra * @see #QUALITY_480P 230522632cde516001429549c60bd570c399ffad800Nipun Kwatra * @see #QUALITY_720P 231522632cde516001429549c60bd570c399ffad800Nipun Kwatra * @see #QUALITY_1080P 232522632cde516001429549c60bd570c399ffad800Nipun Kwatra * @see #QUALITY_TIME_LAPSE_LOW 233522632cde516001429549c60bd570c399ffad800Nipun Kwatra * @see #QUALITY_TIME_LAPSE_HIGH 234522632cde516001429549c60bd570c399ffad800Nipun Kwatra * @see #QUALITY_TIME_LAPSE_QCIF 235522632cde516001429549c60bd570c399ffad800Nipun Kwatra * @see #QUALITY_TIME_LAPSE_CIF 236522632cde516001429549c60bd570c399ffad800Nipun Kwatra * @see #QUALITY_TIME_LAPSE_480P 237522632cde516001429549c60bd570c399ffad800Nipun Kwatra * @see #QUALITY_TIME_LAPSE_720P 238522632cde516001429549c60bd570c399ffad800Nipun Kwatra * @see #QUALITY_TIME_LAPSE_1080P 23909b9005769f2b717f637131578ce6cfa6bd62bd9Chih-Chung Chang */ 24009b9005769f2b717f637131578ce6cfa6bd62bd9Chih-Chung Chang public static CamcorderProfile get(int cameraId, int quality) { 2414af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra if (!((quality >= QUALITY_LOW && quality <= QUALITY_1080P) || 2424af0dfd6cbc13fa6a89ec1430cbe6f619cd64d8aNipun Kwatra (quality >= QUALITY_TIME_LAPSE_LOW && quality <= QUALITY_TIME_LAPSE_1080P))) { 243e64d9a236e4704abf53d3b7eea2eb066f23cf402James Dong String errMessage = "Unsupported quality level: " + quality; 244e64d9a236e4704abf53d3b7eea2eb066f23cf402James Dong throw new IllegalArgumentException(errMessage); 245e64d9a236e4704abf53d3b7eea2eb066f23cf402James Dong } 24609b9005769f2b717f637131578ce6cfa6bd62bd9Chih-Chung Chang return native_get_camcorder_profile(cameraId, quality); 247e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong } 248e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong 2499d619542bea7d4c376a5a8b4a55c795a796adef3Nipun Kwatra /** 2505680635f39b3098539cbfd120f95fdc4479bab0fWu-cheng Li * Returns true if camcorder profile exists for the first back-facing 2515680635f39b3098539cbfd120f95fdc4479bab0fWu-cheng Li * camera at the given quality level. 2529d619542bea7d4c376a5a8b4a55c795a796adef3Nipun Kwatra * @param quality the target quality level for the camcorder profile 2539d619542bea7d4c376a5a8b4a55c795a796adef3Nipun Kwatra */ 2549d619542bea7d4c376a5a8b4a55c795a796adef3Nipun Kwatra public static boolean hasProfile(int quality) { 2555680635f39b3098539cbfd120f95fdc4479bab0fWu-cheng Li int numberOfCameras = Camera.getNumberOfCameras(); 2565680635f39b3098539cbfd120f95fdc4479bab0fWu-cheng Li CameraInfo cameraInfo = new CameraInfo(); 2575680635f39b3098539cbfd120f95fdc4479bab0fWu-cheng Li for (int i = 0; i < numberOfCameras; i++) { 2585680635f39b3098539cbfd120f95fdc4479bab0fWu-cheng Li Camera.getCameraInfo(i, cameraInfo); 2595680635f39b3098539cbfd120f95fdc4479bab0fWu-cheng Li if (cameraInfo.facing == CameraInfo.CAMERA_FACING_BACK) { 2605680635f39b3098539cbfd120f95fdc4479bab0fWu-cheng Li return hasProfile(i, quality); 2615680635f39b3098539cbfd120f95fdc4479bab0fWu-cheng Li } 2625680635f39b3098539cbfd120f95fdc4479bab0fWu-cheng Li } 2635680635f39b3098539cbfd120f95fdc4479bab0fWu-cheng Li return false; 2649d619542bea7d4c376a5a8b4a55c795a796adef3Nipun Kwatra } 2659d619542bea7d4c376a5a8b4a55c795a796adef3Nipun Kwatra 2669d619542bea7d4c376a5a8b4a55c795a796adef3Nipun Kwatra /** 2679d619542bea7d4c376a5a8b4a55c795a796adef3Nipun Kwatra * Returns true if camcorder profile exists for the given camera at 2689d619542bea7d4c376a5a8b4a55c795a796adef3Nipun Kwatra * the given quality level. 2699d619542bea7d4c376a5a8b4a55c795a796adef3Nipun Kwatra * @param cameraId the id for the camera 2709d619542bea7d4c376a5a8b4a55c795a796adef3Nipun Kwatra * @param quality the target quality level for the camcorder profile 2719d619542bea7d4c376a5a8b4a55c795a796adef3Nipun Kwatra */ 2729d619542bea7d4c376a5a8b4a55c795a796adef3Nipun Kwatra public static boolean hasProfile(int cameraId, int quality) { 2739d619542bea7d4c376a5a8b4a55c795a796adef3Nipun Kwatra return native_has_camcorder_profile(cameraId, quality); 2749d619542bea7d4c376a5a8b4a55c795a796adef3Nipun Kwatra } 2759d619542bea7d4c376a5a8b4a55c795a796adef3Nipun Kwatra 276e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong static { 277e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong System.loadLibrary("media_jni"); 278e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong native_init(); 279e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong } 280e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong 281e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong // Private constructor called by JNI 2829b433f0b654d32530b0b48a7a653216ae0bb94d8James Dong private CamcorderProfile(int duration, 2839b433f0b654d32530b0b48a7a653216ae0bb94d8James Dong int quality, 284e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong int fileFormat, 285e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong int videoCodec, 286e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong int videoBitRate, 287e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong int videoFrameRate, 288e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong int videoWidth, 289e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong int videoHeight, 290e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong int audioCodec, 291e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong int audioBitRate, 292e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong int audioSampleRate, 293e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong int audioChannels) { 294e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong 295e64d9a236e4704abf53d3b7eea2eb066f23cf402James Dong this.duration = duration; 296e64d9a236e4704abf53d3b7eea2eb066f23cf402James Dong this.quality = quality; 297e64d9a236e4704abf53d3b7eea2eb066f23cf402James Dong this.fileFormat = fileFormat; 298e64d9a236e4704abf53d3b7eea2eb066f23cf402James Dong this.videoCodec = videoCodec; 299e64d9a236e4704abf53d3b7eea2eb066f23cf402James Dong this.videoBitRate = videoBitRate; 300e64d9a236e4704abf53d3b7eea2eb066f23cf402James Dong this.videoFrameRate = videoFrameRate; 301e64d9a236e4704abf53d3b7eea2eb066f23cf402James Dong this.videoFrameWidth = videoWidth; 302e64d9a236e4704abf53d3b7eea2eb066f23cf402James Dong this.videoFrameHeight = videoHeight; 303e64d9a236e4704abf53d3b7eea2eb066f23cf402James Dong this.audioCodec = audioCodec; 304e64d9a236e4704abf53d3b7eea2eb066f23cf402James Dong this.audioBitRate = audioBitRate; 305e64d9a236e4704abf53d3b7eea2eb066f23cf402James Dong this.audioSampleRate = audioSampleRate; 306e64d9a236e4704abf53d3b7eea2eb066f23cf402James Dong this.audioChannels = audioChannels; 307e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong } 308e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong 309e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong // Methods implemented by JNI 310e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong private static native final void native_init(); 31109b9005769f2b717f637131578ce6cfa6bd62bd9Chih-Chung Chang private static native final CamcorderProfile native_get_camcorder_profile( 31209b9005769f2b717f637131578ce6cfa6bd62bd9Chih-Chung Chang int cameraId, int quality); 3139d619542bea7d4c376a5a8b4a55c795a796adef3Nipun Kwatra private static native final boolean native_has_camcorder_profile( 3149d619542bea7d4c376a5a8b4a55c795a796adef3Nipun Kwatra int cameraId, int quality); 315e7038ace44ed6e6cd27be35b003e6dd0412e936fJames Dong} 316