diff options
author | Eino-Ville Talvala <etalvala@google.com> | 2015-05-14 17:26:24 -0700 |
---|---|---|
committer | Eino-Ville Talvala <etalvala@google.com> | 2015-06-08 13:21:50 -0700 |
commit | d46a6b9fd8b2a4f9098757384711e2cd03a91651 (patch) | |
tree | 6a292d7d4948ad40719925c82ee95945a6ccb99d /media | |
parent | b4b4cd11c9b95af613f5c0f14f93e3c9590fda7c (diff) | |
download | frameworks_av-d46a6b9fd8b2a4f9098757384711e2cd03a91651.zip frameworks_av-d46a6b9fd8b2a4f9098757384711e2cd03a91651.tar.gz frameworks_av-d46a6b9fd8b2a4f9098757384711e2cd03a91651.tar.bz2 |
Camera1 API: Support SW encoders for new camera HALs
- Support new set video format/dataspace command in camera service
- HALv3: Select gralloc usage flags based on format
- HALv1: Pass format command directly to HAL layer
- Use format/dataspace command in CameraSource
- Switch all API1 recording to use metadata mode
- Switch all >= HALv2 API1 recording to use kMetadataBufferTypeANWBuffer
Bug: 13222807
Change-Id: I2e609b92c65792611bb1dab09e0c41c363ebbc42
Diffstat (limited to 'media')
-rw-r--r-- | media/libmediaplayerservice/StagefrightRecorder.cpp | 15 | ||||
-rw-r--r-- | media/libmediaplayerservice/StagefrightRecorder.h | 3 | ||||
-rw-r--r-- | media/libstagefright/CameraSource.cpp | 17 |
3 files changed, 22 insertions, 13 deletions
diff --git a/media/libmediaplayerservice/StagefrightRecorder.cpp b/media/libmediaplayerservice/StagefrightRecorder.cpp index e16a4b5..98abe9c 100644 --- a/media/libmediaplayerservice/StagefrightRecorder.cpp +++ b/media/libmediaplayerservice/StagefrightRecorder.cpp @@ -1194,8 +1194,7 @@ void StagefrightRecorder::clipVideoFrameWidth() { } } -status_t StagefrightRecorder::checkVideoEncoderCapabilities( - bool *supportsCameraSourceMetaDataMode) { +status_t StagefrightRecorder::checkVideoEncoderCapabilities() { /* hardware codecs must support camera source meta data mode */ Vector<CodecCapabilities> codecs; OMXClient client; @@ -1207,9 +1206,6 @@ status_t StagefrightRecorder::checkVideoEncoderCapabilities( mVideoEncoder == VIDEO_ENCODER_VP8 ? MEDIA_MIMETYPE_VIDEO_VP8 : mVideoEncoder == VIDEO_ENCODER_H264 ? MEDIA_MIMETYPE_VIDEO_AVC : ""), false /* decoder */, true /* hwCodec */, &codecs); - *supportsCameraSourceMetaDataMode = codecs.size() > 0; - ALOGV("encoder %s camera source meta-data mode", - *supportsCameraSourceMetaDataMode ? "supports" : "DOES NOT SUPPORT"); if (!mCaptureTimeLapse) { // Dont clip for time lapse capture as encoder will have enough @@ -1418,9 +1414,7 @@ status_t StagefrightRecorder::setupMediaSource( status_t StagefrightRecorder::setupCameraSource( sp<CameraSource> *cameraSource) { status_t err = OK; - bool encoderSupportsCameraSourceMetaDataMode; - if ((err = checkVideoEncoderCapabilities( - &encoderSupportsCameraSourceMetaDataMode)) != OK) { + if ((err = checkVideoEncoderCapabilities()) != OK) { return err; } Size videoSize; @@ -1436,14 +1430,13 @@ status_t StagefrightRecorder::setupCameraSource( mCameraSourceTimeLapse = CameraSourceTimeLapse::CreateFromCamera( mCamera, mCameraProxy, mCameraId, mClientName, mClientUid, videoSize, mFrameRate, mPreviewSurface, - mTimeBetweenTimeLapseFrameCaptureUs, - encoderSupportsCameraSourceMetaDataMode); + mTimeBetweenTimeLapseFrameCaptureUs); *cameraSource = mCameraSourceTimeLapse; } else { *cameraSource = CameraSource::CreateFromCamera( mCamera, mCameraProxy, mCameraId, mClientName, mClientUid, videoSize, mFrameRate, - mPreviewSurface, encoderSupportsCameraSourceMetaDataMode); + mPreviewSurface); } mCamera.clear(); mCameraProxy.clear(); diff --git a/media/libmediaplayerservice/StagefrightRecorder.h b/media/libmediaplayerservice/StagefrightRecorder.h index 7473f42..8af9278 100644 --- a/media/libmediaplayerservice/StagefrightRecorder.h +++ b/media/libmediaplayerservice/StagefrightRecorder.h @@ -141,8 +141,7 @@ private: status_t setupRTPRecording(); status_t setupMPEG2TSRecording(); sp<MediaSource> createAudioSource(); - status_t checkVideoEncoderCapabilities( - bool *supportsCameraSourceMetaDataMode); + status_t checkVideoEncoderCapabilities(); status_t checkAudioEncoderCapabilities(); // Generic MediaSource set-up. Returns the appropriate // source (CameraSource or SurfaceMediaSource) diff --git a/media/libstagefright/CameraSource.cpp b/media/libstagefright/CameraSource.cpp index 1b788f3..2606e44 100644 --- a/media/libstagefright/CameraSource.cpp +++ b/media/libstagefright/CameraSource.cpp @@ -608,6 +608,16 @@ status_t CameraSource::startCameraRecording() { } } + err = mCamera->sendCommand( + CAMERA_CMD_SET_VIDEO_FORMAT, mEncoderFormat, mEncoderDataSpace); + + // This could happen for CameraHAL1 clients; thus the failure is + // not a fatal error + if (err != OK) { + ALOGW("Failed to set video encoder format/dataspace to %d, %d due to %d", + mEncoderFormat, mEncoderDataSpace, err); + } + err = OK; if (mCameraFlags & FLAGS_HOT_CAMERA) { mCamera->unlock(); @@ -645,6 +655,9 @@ status_t CameraSource::start(MetaData *meta) { mStartTimeUs = 0; mNumInputBuffers = 0; + mEncoderFormat = HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED; + mEncoderDataSpace = HAL_DATASPACE_BT709; + if (meta) { int64_t startTimeUs; if (meta->findInt64(kKeyTime, &startTimeUs)) { @@ -656,6 +669,10 @@ status_t CameraSource::start(MetaData *meta) { CHECK_GT(nBuffers, 0); mNumInputBuffers = nBuffers; } + + // TODO: Read in format/dataspace from somewhere + // Uncomment to test SW encoders until TODO is resolved + // mEncoderFormat = HAL_PIXEL_FORMAT_YCbCr_420_888; } status_t err; |