diff options
author | James Dong <jdong@google.com> | 2010-10-05 19:01:10 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2010-10-05 19:01:10 -0700 |
commit | b74ccaad18159d8236650448513ef90c02fab451 (patch) | |
tree | 9785c83f26989d9e1159efd492b584951aa3ea0b /media | |
parent | 1e14f49d06b871d8101e33c47ba34b87c3c8089d (diff) | |
parent | 8a9f8bfe16fc1904f5e835de0f13240f6daf8339 (diff) | |
download | frameworks_base-b74ccaad18159d8236650448513ef90c02fab451.zip frameworks_base-b74ccaad18159d8236650448513ef90c02fab451.tar.gz frameworks_base-b74ccaad18159d8236650448513ef90c02fab451.tar.bz2 |
Merge "Use setVideoSize API in StagefrightRecorder"
Diffstat (limited to 'media')
-rw-r--r-- | media/libmediaplayerservice/StagefrightRecorder.cpp | 70 | ||||
-rw-r--r-- | media/libmediaplayerservice/StagefrightRecorder.h | 4 |
2 files changed, 72 insertions, 2 deletions
diff --git a/media/libmediaplayerservice/StagefrightRecorder.cpp b/media/libmediaplayerservice/StagefrightRecorder.cpp index bf0c6e17..7a78185 100644 --- a/media/libmediaplayerservice/StagefrightRecorder.cpp +++ b/media/libmediaplayerservice/StagefrightRecorder.cpp @@ -966,6 +966,65 @@ void StagefrightRecorder::clipVideoFrameWidth() { } } +/* + * Check to see whether the requested video width and height is one + * of the supported sizes. It returns true if so; otherwise, it + * returns false. + */ +bool StagefrightRecorder::isVideoSizeSupported( + const Vector<Size>& supportedSizes) const { + + LOGV("isVideoSizeSupported"); + for (size_t i = 0; i < supportedSizes.size(); ++i) { + if (mVideoWidth == supportedSizes[i].width && + mVideoHeight == supportedSizes[i].height) { + return true; + } + } + return false; +} + +/* + * If the preview and video output is separate, we only set the + * the video size, and applications should set the preview size + * to some proper value, and the recording framework will not + * change the preview size; otherwise, if the video and preview + * output is the same, we need to set the preview to be the same + * as the requested video size. + * + * On return, it also returns whether the setVideoSize() is + * supported. + */ +status_t StagefrightRecorder::setCameraVideoSize( + CameraParameters* params, + bool* isSetVideoSizeSupported) { + LOGV("setCameraVideoSize: %dx%d", mVideoWidth, mVideoHeight); + + // Check whether the requested video size is supported + Vector<Size> sizes; + params->getSupportedVideoSizes(sizes); + *isSetVideoSizeSupported = true; + if (sizes.size() == 0) { + LOGD("Camera does not support setVideoSize()"); + params->getSupportedPreviewSizes(sizes); + *isSetVideoSizeSupported = false; + } + if (!isVideoSizeSupported(sizes)) { + LOGE("Camera does not support video size (%dx%d)!", + mVideoWidth, mVideoHeight); + return BAD_VALUE; + } + + // Actually set the video size + if (isSetVideoSizeSupported) { + params->setVideoSize(mVideoWidth, mVideoHeight); + } else { + params->setPreviewSize(mVideoWidth, mVideoHeight); + } + + return OK; +} + status_t StagefrightRecorder::setupCamera() { if (!mCaptureTimeLapse) { // Dont clip for time lapse capture as encoder will have enough @@ -993,8 +1052,11 @@ status_t StagefrightRecorder::setupCamera() { // dont change the preview size because time lapse may be using still camera // as mVideoWidth, mVideoHeight may correspond to HD resolution not // supported by the video camera. + bool isSetVideoSizeSupported = false; if (!mCaptureTimeLapse) { - params.setPreviewSize(mVideoWidth, mVideoHeight); + if (OK != setCameraVideoSize(¶ms, &isSetVideoSizeSupported)) { + return BAD_VALUE; + } } params.setPreviewFrameRate(mFrameRate); @@ -1008,7 +1070,11 @@ status_t StagefrightRecorder::setupCamera() { // Check on video frame size int frameWidth = 0, frameHeight = 0; - newCameraParams.getPreviewSize(&frameWidth, &frameHeight); + if (isSetVideoSizeSupported) { + newCameraParams.getVideoSize(&frameWidth, &frameHeight); + } else { + newCameraParams.getPreviewSize(&frameWidth, &frameHeight); + } if (!mCaptureTimeLapse && (frameWidth < 0 || frameWidth != mVideoWidth || frameHeight < 0 || frameHeight != mVideoHeight)) { diff --git a/media/libmediaplayerservice/StagefrightRecorder.h b/media/libmediaplayerservice/StagefrightRecorder.h index 02d9a01..f14c704 100644 --- a/media/libmediaplayerservice/StagefrightRecorder.h +++ b/media/libmediaplayerservice/StagefrightRecorder.h @@ -19,6 +19,7 @@ #define STAGEFRIGHT_RECORDER_H_ #include <media/MediaRecorderBase.h> +#include <camera/CameraParameters.h> #include <utils/String8.h> namespace android { @@ -125,6 +126,9 @@ private: status_t startRTPRecording(); sp<MediaSource> createAudioSource(); status_t setupCamera(); + bool isVideoSizeSupported(const Vector<Size>& supportedSizes) const; + status_t setCameraVideoSize(CameraParameters* params, + bool *isSetVideoSizeSupported); status_t setupCameraSource(sp<CameraSource> *cameraSource); status_t setupAudioEncoder(const sp<MediaWriter>& writer); status_t setupVideoEncoder( |