From b8a89c8c3cdcaa95706897b18bff35098df0c817 Mon Sep 17 00:00:00 2001 From: Deva Ramasubramanian Date: Thu, 17 Sep 2015 12:48:59 -0700 Subject: libstagefright: Allow for CameraSourceTimeLapse to be extended Add in hooks to route CameraSourceTimeLapse creation to AVFactory so that we can add our customizations. Change-Id: I309a247ba6e3c5626cfba096677a6dbfeae543f3 --- include/media/stagefright/CameraSourceTimeLapse.h | 5 +++-- media/libavextensions/stagefright/AVExtensions.h | 15 ++++++++++++++- media/libavextensions/stagefright/AVFactory.cpp | 18 +++++++++++++++++- media/libmediaplayerservice/StagefrightRecorder.cpp | 4 ++-- 4 files changed, 36 insertions(+), 6 deletions(-) diff --git a/include/media/stagefright/CameraSourceTimeLapse.h b/include/media/stagefright/CameraSourceTimeLapse.h index 34213be..f264d98 100644 --- a/include/media/stagefright/CameraSourceTimeLapse.h +++ b/include/media/stagefright/CameraSourceTimeLapse.h @@ -20,6 +20,7 @@ #include +#include #include #include #include @@ -56,7 +57,7 @@ public: // returning quickly. void startQuickReadReturns(); -private: +protected: // size of the encoded video. int32_t mVideoWidth; int32_t mVideoHeight; @@ -152,7 +153,7 @@ private: // the frame needs to be encoded, it returns false and also modifies // the time stamp to be one frame time ahead of the last encoded // frame's time stamp. - bool skipFrameAndModifyTimeStamp(int64_t *timestampUs); + virtual bool skipFrameAndModifyTimeStamp(int64_t *timestampUs); // Wrapper to enter threadTimeLapseEntry() static void *ThreadTimeLapseWrapper(void *me); diff --git a/media/libavextensions/stagefright/AVExtensions.h b/media/libavextensions/stagefright/AVExtensions.h index fc04df1..9c712e4 100644 --- a/media/libavextensions/stagefright/AVExtensions.h +++ b/media/libavextensions/stagefright/AVExtensions.h @@ -54,6 +54,7 @@ class CameraParameters; class MediaBuffer; struct AudioSource; class CameraSource; +class CameraSourceTimeLapse; class ICamera; class ICameraRecordingProxy; class String16; @@ -85,7 +86,7 @@ struct AVFactory { uint32_t channels, uint32_t outSampleRate = 0); - virtual CameraSource *CreateFromCamera( + virtual CameraSource *CreateCameraSourceFromCamera( const sp &camera, const sp &proxy, int32_t cameraId, @@ -95,6 +96,18 @@ struct AVFactory { int32_t frameRate, const sp& surface, bool storeMetaDataInVideoBuffers = true); + + virtual CameraSourceTimeLapse *CreateCameraSourceTimeLapseFromCamera( + const sp &camera, + const sp &proxy, + int32_t cameraId, + const String16& clientName, + uid_t clientUid, + Size videoSize, + int32_t videoFrameRate, + const sp& surface, + int64_t timeBetweenFrameCaptureUs, + bool storeMetaDataInVideoBuffers = true); // ----- NO TRESSPASSING BEYOND THIS LINE ------ DECLARE_LOADABLE_SINGLETON(AVFactory); }; diff --git a/media/libavextensions/stagefright/AVFactory.cpp b/media/libavextensions/stagefright/AVFactory.cpp index 19977e9..90ac7b2 100644 --- a/media/libavextensions/stagefright/AVFactory.cpp +++ b/media/libavextensions/stagefright/AVFactory.cpp @@ -43,6 +43,7 @@ #include #include #include +#include #include #include "common/ExtensionsLoader.hpp" @@ -88,7 +89,7 @@ AudioSource* AVFactory::createAudioSource( channels, outSampleRate); } -CameraSource* AVFactory::CreateFromCamera( +CameraSource* AVFactory::CreateCameraSourceFromCamera( const sp &camera, const sp &proxy, int32_t cameraId, @@ -103,6 +104,21 @@ CameraSource* AVFactory::CreateFromCamera( storeMetaDataInVideoBuffers); } +CameraSourceTimeLapse* AVFactory::CreateCameraSourceTimeLapseFromCamera( + const sp &camera, + const sp &proxy, + int32_t cameraId, + const String16& clientName, + uid_t clientUid, + Size videoSize, + int32_t videoFrameRate, + const sp& surface, + int64_t timeBetweenFrameCaptureUs, + bool storeMetaDataInVideoBuffers) { + return CameraSourceTimeLapse::CreateFromCamera(camera, proxy, cameraId, + clientName, clientUid, videoSize, videoFrameRate, surface, + timeBetweenFrameCaptureUs, storeMetaDataInVideoBuffers); +} // ----- NO TRESSPASSING BEYOND THIS LINE ------ AVFactory::AVFactory() { } diff --git a/media/libmediaplayerservice/StagefrightRecorder.cpp b/media/libmediaplayerservice/StagefrightRecorder.cpp index 136e6cf..80d5ac2 100644 --- a/media/libmediaplayerservice/StagefrightRecorder.cpp +++ b/media/libmediaplayerservice/StagefrightRecorder.cpp @@ -1465,13 +1465,13 @@ status_t StagefrightRecorder::setupCameraSource( return BAD_VALUE; } - mCameraSourceTimeLapse = CameraSourceTimeLapse::CreateFromCamera( + mCameraSourceTimeLapse = AVFactory::get()->CreateCameraSourceTimeLapseFromCamera( mCamera, mCameraProxy, mCameraId, mClientName, mClientUid, videoSize, mFrameRate, mPreviewSurface, mTimeBetweenCaptureUs); *cameraSource = mCameraSourceTimeLapse; } else { - *cameraSource = AVFactory::get()->CreateFromCamera( + *cameraSource = AVFactory::get()->CreateCameraSourceFromCamera( mCamera, mCameraProxy, mCameraId, mClientName, mClientUid, videoSize, mFrameRate, mPreviewSurface); -- cgit v1.1