summaryrefslogtreecommitdiffstats
path: root/media
diff options
context:
space:
mode:
authorJames Dong <jdong@google.com>2010-10-03 22:08:23 -0700
committerJames Dong <jdong@google.com>2010-10-04 13:14:22 -0700
commit5f4d93467a03b3a38320416f8cc2c2c2c94bf3fc (patch)
tree096ebecff6d3483fe96bc504d584fb5837011c90 /media
parent0d14c25355b7807b88fcdc76040ef986aa754815 (diff)
downloadframeworks_av-5f4d93467a03b3a38320416f8cc2c2c2c94bf3fc.zip
frameworks_av-5f4d93467a03b3a38320416f8cc2c2c2c94bf3fc.tar.gz
frameworks_av-5f4d93467a03b3a38320416f8cc2c2c2c94bf3fc.tar.bz2
Use setVideoSize API in StagefrightRecorder
Change-Id: Ia7ddf5e8d2b931453d2cb801169906191349ca07
Diffstat (limited to 'media')
-rw-r--r--media/libmediaplayerservice/StagefrightRecorder.cpp70
-rw-r--r--media/libmediaplayerservice/StagefrightRecorder.h4
2 files changed, 72 insertions, 2 deletions
diff --git a/media/libmediaplayerservice/StagefrightRecorder.cpp b/media/libmediaplayerservice/StagefrightRecorder.cpp
index bf0c6e1..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(&params, &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(