Added specific resolution and time lapse profiles.
- Added enums QUALITY_{QCIF,480P,720P,1080P}
QUALITY_TIME_LAPSE_{LOW,HIGH,QCIF,480P,720P,1080P} in CamcorderProfile
and corresponding ones in MediaProfiles.
- Added functions createDefaultCamcorderTimeLapseLowProfile,
createDefaultCamcorderTimeLapseHighProfile to set default values.
- Moved javadoc for constants to the get() function.
Change-Id: Ib8b3f8d29395dff77a397d1e6b44cfaf8c481d4d
This commit is contained in:
@@ -25,7 +25,18 @@ namespace android {
|
||||
|
||||
enum camcorder_quality {
|
||||
CAMCORDER_QUALITY_LOW = 0,
|
||||
CAMCORDER_QUALITY_HIGH = 1
|
||||
CAMCORDER_QUALITY_HIGH = 1,
|
||||
CAMCORDER_QUALITY_QCIF = 2,
|
||||
CAMCORDER_QUALITY_480P = 3,
|
||||
CAMCORDER_QUALITY_720P = 4,
|
||||
CAMCORDER_QUALITY_1080P = 5,
|
||||
|
||||
CAMCORDER_QUALITY_TIME_LAPSE_LOW = 1000,
|
||||
CAMCORDER_QUALITY_TIME_LAPSE_HIGH = 1001,
|
||||
CAMCORDER_QUALITY_TIME_LAPSE_QCIF = 1002,
|
||||
CAMCORDER_QUALITY_TIME_LAPSE_480P = 1003,
|
||||
CAMCORDER_QUALITY_TIME_LAPSE_720P = 1004,
|
||||
CAMCORDER_QUALITY_TIME_LAPSE_1080P = 1005
|
||||
};
|
||||
|
||||
enum video_decoder {
|
||||
@@ -283,6 +294,8 @@ private:
|
||||
static MediaProfiles* createDefaultInstance();
|
||||
static CamcorderProfile *createDefaultCamcorderLowProfile();
|
||||
static CamcorderProfile *createDefaultCamcorderHighProfile();
|
||||
static CamcorderProfile *createDefaultCamcorderTimeLapseLowProfile();
|
||||
static CamcorderProfile *createDefaultCamcorderTimeLapseHighProfile();
|
||||
static void createDefaultCamcorderProfiles(MediaProfiles *profiles);
|
||||
static void createDefaultVideoEncoders(MediaProfiles *profiles);
|
||||
static void createDefaultAudioEncoders(MediaProfiles *profiles);
|
||||
|
||||
@@ -39,21 +39,69 @@ package android.media;
|
||||
*/
|
||||
public class CamcorderProfile
|
||||
{
|
||||
// Do not change these values/ordinals without updating their counterpart
|
||||
// in include/media/MediaProfiles.h!
|
||||
|
||||
/**
|
||||
* The output from camcorder recording sessions can have different quality levels.
|
||||
*
|
||||
* Currently, we define two quality levels: high quality and low quality.
|
||||
* A camcorder recording session with high quality level usually has higher output bit
|
||||
* rate, better video and/or audio recording quality, larger video frame
|
||||
* resolution and higher audio sampling rate, etc, than those with low quality
|
||||
* level.
|
||||
*
|
||||
* Do not change these values/ordinals without updating their counterpart
|
||||
* in include/media/MediaProfiles.h!
|
||||
* Quality level corresponding to the lowest available resolution.
|
||||
*/
|
||||
public static final int QUALITY_LOW = 0;
|
||||
|
||||
/**
|
||||
* Quality level corresponding to the highest available resolution.
|
||||
*/
|
||||
public static final int QUALITY_HIGH = 1;
|
||||
|
||||
/**
|
||||
* Quality level corresponding to the qcif (176 × 144) resolution.
|
||||
*/
|
||||
private static final int QUALITY_QCIF = 2;
|
||||
|
||||
/**
|
||||
* Quality level corresponding to the 480p (720 x 480) resolution.
|
||||
*/
|
||||
private static final int QUALITY_480P = 3;
|
||||
|
||||
/**
|
||||
* Quality level corresponding to the 720p (1280 x 720) resolution.
|
||||
*/
|
||||
private static final int QUALITY_720P = 4;
|
||||
|
||||
/**
|
||||
* Quality level corresponding to the 1080p (1920 x 1088) resolution.
|
||||
*/
|
||||
private static final int QUALITY_1080P = 5;
|
||||
|
||||
/**
|
||||
* Time lapse quality level corresponding to the lowest available resolution.
|
||||
*/
|
||||
private static final int QUALITY_TIME_LAPSE_LOW = 1000;
|
||||
|
||||
/**
|
||||
* Time lapse quality level corresponding to the highest available resolution.
|
||||
*/
|
||||
private static final int QUALITY_TIME_LAPSE_HIGH = 1001;
|
||||
|
||||
/**
|
||||
* Time lapse quality level corresponding to the qcif (176 × 144) resolution.
|
||||
*/
|
||||
private static final int QUALITY_TIME_LAPSE_QCIF = 1002;
|
||||
|
||||
/**
|
||||
* Time lapse quality level corresponding to the 480p (720 x 480) resolution.
|
||||
*/
|
||||
private static final int QUALITY_TIME_LAPSE_480P = 1003;
|
||||
|
||||
/**
|
||||
* Time lapse quality level corresponding to the 720p (1280 x 720) resolution.
|
||||
*/
|
||||
private static final int QUALITY_TIME_LAPSE_720P = 1004;
|
||||
|
||||
/**
|
||||
* Time lapse quality level corresponding to the 1080p (1920 x 1088) resolution.
|
||||
*/
|
||||
private static final int QUALITY_TIME_LAPSE_1080P = 1005;
|
||||
|
||||
/**
|
||||
* Default recording duration in seconds before the session is terminated.
|
||||
* This is useful for applications like MMS has limited file size requirement.
|
||||
@@ -122,6 +170,7 @@ public class CamcorderProfile
|
||||
* Returns the camcorder profile for the default camera at the given
|
||||
* quality level.
|
||||
* @param quality the target quality level for the camcorder profile
|
||||
* @see #get(int, int)
|
||||
*/
|
||||
public static CamcorderProfile get(int quality) {
|
||||
return get(0, quality);
|
||||
@@ -130,11 +179,26 @@ public class CamcorderProfile
|
||||
/**
|
||||
* Returns the camcorder profile for the given camera at the given
|
||||
* quality level.
|
||||
*
|
||||
* Quality levels QUALITY_LOW, QUALITY_HIGH are guaranteed to be supported, while
|
||||
* other levels may or may not be supported.
|
||||
* QUALITY_LOW refers to the lowest quality available, while QUALITY_HIGH refers to
|
||||
* the highest quality available.
|
||||
* QUALITY_LOW/QUALITY_HIGH have to match one of qcif, 480p, 720p, or 1080p.
|
||||
* E.g. if the device supports 480p, 720p, and 1080p, then low is 480p and high is
|
||||
* 1080p.
|
||||
*
|
||||
* A camcorder recording session with higher quality level usually has higher output
|
||||
* bit rate, better video and/or audio recording quality, larger video frame
|
||||
* resolution and higher audio sampling rate, etc, than those with lower quality
|
||||
* level.
|
||||
*
|
||||
* @param cameraId the id for the camera
|
||||
* @param quality the target quality level for the camcorder profile
|
||||
* @param quality the target quality level for the camcorder profile.
|
||||
*/
|
||||
public static CamcorderProfile get(int cameraId, int quality) {
|
||||
if (quality < QUALITY_LOW || quality > QUALITY_HIGH) {
|
||||
if (!((quality >= QUALITY_LOW && quality <= QUALITY_1080P) ||
|
||||
(quality >= QUALITY_TIME_LAPSE_LOW && quality <= QUALITY_TIME_LAPSE_1080P))) {
|
||||
String errMessage = "Unsupported quality level: " + quality;
|
||||
throw new IllegalArgumentException(errMessage);
|
||||
}
|
||||
|
||||
@@ -165,7 +165,9 @@ static jobject
|
||||
android_media_MediaProfiles_native_get_camcorder_profile(JNIEnv *env, jobject thiz, jint id, jint quality)
|
||||
{
|
||||
LOGV("native_get_camcorder_profile: %d %d", id, quality);
|
||||
if (quality != CAMCORDER_QUALITY_HIGH && quality != CAMCORDER_QUALITY_LOW) {
|
||||
if (!((quality >= CAMCORDER_QUALITY_LOW && quality <= CAMCORDER_QUALITY_1080P) ||
|
||||
(quality >= CAMCORDER_QUALITY_TIME_LAPSE_LOW &&
|
||||
quality <= CAMCORDER_QUALITY_TIME_LAPSE_1080P))) {
|
||||
jniThrowException(env, "java/lang/RuntimeException", "Unknown camcorder profile quality");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -59,8 +59,19 @@ const MediaProfiles::NameToTagMap MediaProfiles::sAudioDecoderNameMap[] = {
|
||||
};
|
||||
|
||||
const MediaProfiles::NameToTagMap MediaProfiles::sCamcorderQualityNameMap[] = {
|
||||
{"low", CAMCORDER_QUALITY_LOW},
|
||||
{"high", CAMCORDER_QUALITY_HIGH},
|
||||
{"low", CAMCORDER_QUALITY_LOW}
|
||||
{"qcif", CAMCORDER_QUALITY_QCIF},
|
||||
{"480p", CAMCORDER_QUALITY_480P},
|
||||
{"720p", CAMCORDER_QUALITY_720P},
|
||||
{"1080p", CAMCORDER_QUALITY_1080P},
|
||||
|
||||
{"timelapselow", CAMCORDER_QUALITY_TIME_LAPSE_LOW},
|
||||
{"timelapsehigh", CAMCORDER_QUALITY_TIME_LAPSE_HIGH},
|
||||
{"timelapseqcif", CAMCORDER_QUALITY_TIME_LAPSE_QCIF},
|
||||
{"timelapse480p", CAMCORDER_QUALITY_TIME_LAPSE_480P},
|
||||
{"timelapse720p", CAMCORDER_QUALITY_TIME_LAPSE_720P},
|
||||
{"timelapse1080p", CAMCORDER_QUALITY_TIME_LAPSE_1080P}
|
||||
};
|
||||
|
||||
/*static*/ void
|
||||
@@ -410,6 +421,40 @@ MediaProfiles::createDefaultVideoEncoders(MediaProfiles *profiles)
|
||||
profiles->mVideoEncoders.add(createDefaultM4vVideoEncoderCap());
|
||||
}
|
||||
|
||||
/*static*/ MediaProfiles::CamcorderProfile*
|
||||
MediaProfiles::createDefaultCamcorderTimeLapseHighProfile()
|
||||
{
|
||||
MediaProfiles::VideoCodec *videoCodec =
|
||||
new MediaProfiles::VideoCodec(VIDEO_ENCODER_H263, 20000000, 720, 480, 20);
|
||||
|
||||
AudioCodec *audioCodec = new AudioCodec(AUDIO_ENCODER_AMR_NB, 12200, 8000, 1);
|
||||
CamcorderProfile *profile = new MediaProfiles::CamcorderProfile;
|
||||
profile->mCameraId = 0;
|
||||
profile->mFileFormat = OUTPUT_FORMAT_THREE_GPP;
|
||||
profile->mQuality = CAMCORDER_QUALITY_TIME_LAPSE_HIGH;
|
||||
profile->mDuration = 60;
|
||||
profile->mVideoCodec = videoCodec;
|
||||
profile->mAudioCodec = audioCodec;
|
||||
return profile;
|
||||
}
|
||||
|
||||
/*static*/ MediaProfiles::CamcorderProfile*
|
||||
MediaProfiles::createDefaultCamcorderTimeLapseLowProfile()
|
||||
{
|
||||
MediaProfiles::VideoCodec *videoCodec =
|
||||
new MediaProfiles::VideoCodec(VIDEO_ENCODER_H263, 1000000, 176, 144, 20);
|
||||
|
||||
AudioCodec *audioCodec = new AudioCodec(AUDIO_ENCODER_AMR_NB, 12200, 8000, 1);
|
||||
CamcorderProfile *profile = new MediaProfiles::CamcorderProfile;
|
||||
profile->mCameraId = 0;
|
||||
profile->mFileFormat = OUTPUT_FORMAT_THREE_GPP;
|
||||
profile->mQuality = CAMCORDER_QUALITY_TIME_LAPSE_LOW;
|
||||
profile->mDuration = 60;
|
||||
profile->mVideoCodec = videoCodec;
|
||||
profile->mAudioCodec = audioCodec;
|
||||
return profile;
|
||||
}
|
||||
|
||||
/*static*/ MediaProfiles::CamcorderProfile*
|
||||
MediaProfiles::createDefaultCamcorderHighProfile()
|
||||
{
|
||||
@@ -449,6 +494,8 @@ MediaProfiles::createDefaultCamcorderLowProfile()
|
||||
/*static*/ void
|
||||
MediaProfiles::createDefaultCamcorderProfiles(MediaProfiles *profiles)
|
||||
{
|
||||
profiles->mCamcorderProfiles.add(createDefaultCamcorderTimeLapseHighProfile());
|
||||
profiles->mCamcorderProfiles.add(createDefaultCamcorderTimeLapseLowProfile());
|
||||
profiles->mCamcorderProfiles.add(createDefaultCamcorderHighProfile());
|
||||
profiles->mCamcorderProfiles.add(createDefaultCamcorderLowProfile());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user