michael@0: diff --git a/GonkCameraListener.h b/GonkCameraListener.h michael@0: index 67eeef3..243264c 100644 michael@0: --- a/GonkCameraListener.h michael@0: +++ b/GonkCameraListener.h michael@0: @@ -14,49 +14,16 @@ michael@0: * limitations under the License. michael@0: */ michael@0: michael@0: -#ifndef ANDROID_HARDWARE_CAMERA_H michael@0: -#define ANDROID_HARDWARE_CAMERA_H michael@0: +#ifndef GONK_CAMERA_LISTENER_H michael@0: +#define GONK_CAMERA_LISTENER_H michael@0: michael@0: #include michael@0: -#include michael@0: -#include michael@0: -#include michael@0: -#include michael@0: -#include michael@0: +#include "libcameraservice/CameraHardwareInterface.h" michael@0: michael@0: namespace android { michael@0: michael@0: -struct CameraInfo { michael@0: - /** michael@0: - * The direction that the camera faces to. It should be CAMERA_FACING_BACK michael@0: - * or CAMERA_FACING_FRONT. michael@0: - */ michael@0: - int facing; michael@0: - michael@0: - /** michael@0: - * The orientation of the camera image. The value is the angle that the michael@0: - * camera image needs to be rotated clockwise so it shows correctly on the michael@0: - * display in its natural orientation. It should be 0, 90, 180, or 270. michael@0: - * michael@0: - * For example, suppose a device has a naturally tall screen. The michael@0: - * back-facing camera sensor is mounted in landscape. You are looking at michael@0: - * the screen. If the top side of the camera sensor is aligned with the michael@0: - * right edge of the screen in natural orientation, the value should be michael@0: - * 90. If the top side of a front-facing camera sensor is aligned with the michael@0: - * right of the screen, the value should be 270. michael@0: - */ michael@0: - int orientation; michael@0: - int mode; michael@0: -}; michael@0: - michael@0: -class ICameraService; michael@0: -class ICamera; michael@0: -class Surface; michael@0: -class Mutex; michael@0: -class String8; michael@0: - michael@0: // ref-counted object for callbacks michael@0: -class CameraListener: virtual public RefBase michael@0: +class GonkCameraListener: virtual public RefBase michael@0: { michael@0: public: michael@0: virtual void notify(int32_t msgType, int32_t ext1, int32_t ext2) = 0; michael@0: @@ -65,133 +32,6 @@ public: michael@0: virtual void postDataTimestamp(nsecs_t timestamp, int32_t msgType, const sp& dataPtr) = 0; michael@0: }; michael@0: michael@0: -class Camera : public BnCameraClient, public IBinder::DeathRecipient michael@0: -{ michael@0: -public: michael@0: - // construct a camera client from an existing remote michael@0: - static sp create(const sp& camera); michael@0: - static int32_t getNumberOfCameras(); michael@0: - static status_t getCameraInfo(int cameraId, michael@0: - struct CameraInfo* cameraInfo); michael@0: - static sp connect(int cameraId); michael@0: - virtual ~Camera(); michael@0: - void init(); michael@0: - michael@0: - status_t reconnect(); michael@0: - void disconnect(); michael@0: - status_t lock(); michael@0: - status_t unlock(); michael@0: - michael@0: - status_t getStatus() { return mStatus; } michael@0: - michael@0: - // pass the buffered Surface to the camera service michael@0: - status_t setPreviewDisplay(const sp& surface); michael@0: - michael@0: - // pass the buffered ISurfaceTexture to the camera service michael@0: - status_t setPreviewTexture(const sp& surfaceTexture); michael@0: - michael@0: - // start preview mode, must call setPreviewDisplay first michael@0: - status_t startPreview(); michael@0: - michael@0: - // stop preview mode michael@0: - void stopPreview(); michael@0: - michael@0: - // get preview state michael@0: - bool previewEnabled(); michael@0: - michael@0: - // start recording mode, must call setPreviewDisplay first michael@0: - status_t startRecording(); michael@0: - michael@0: - // stop recording mode michael@0: - void stopRecording(); michael@0: - michael@0: - // get recording state michael@0: - bool recordingEnabled(); michael@0: - michael@0: - // release a recording frame michael@0: - void releaseRecordingFrame(const sp& mem); michael@0: - michael@0: - // autoFocus - status returned from callback michael@0: - status_t autoFocus(); michael@0: - michael@0: - // cancel auto focus michael@0: - status_t cancelAutoFocus(); michael@0: - michael@0: - // take a picture - picture returned from callback michael@0: - status_t takePicture(int msgType); michael@0: - michael@0: - // set preview/capture parameters - key/value pairs michael@0: - status_t setParameters(const String8& params); michael@0: - michael@0: - // get preview/capture parameters - key/value pairs michael@0: - String8 getParameters() const; michael@0: - michael@0: - // send command to camera driver michael@0: - status_t sendCommand(int32_t cmd, int32_t arg1, int32_t arg2); michael@0: - michael@0: - // tell camera hal to store meta data or real YUV in video buffers. michael@0: - status_t storeMetaDataInBuffers(bool enabled); michael@0: - michael@0: - void setListener(const sp& listener); michael@0: - void setRecordingProxyListener(const sp& listener); michael@0: - void setPreviewCallbackFlags(int preview_callback_flag); michael@0: - michael@0: - sp getRecordingProxy(); michael@0: - michael@0: - // ICameraClient interface michael@0: - virtual void notifyCallback(int32_t msgType, int32_t ext, int32_t ext2); michael@0: - virtual void dataCallback(int32_t msgType, const sp& dataPtr, michael@0: - camera_frame_metadata_t *metadata); michael@0: - virtual void dataCallbackTimestamp(nsecs_t timestamp, int32_t msgType, const sp& dataPtr); michael@0: - michael@0: - sp remote(); michael@0: - michael@0: - class RecordingProxy : public BnCameraRecordingProxy michael@0: - { michael@0: - public: michael@0: - RecordingProxy(const sp& camera); michael@0: - michael@0: - // ICameraRecordingProxy interface michael@0: - virtual status_t startRecording(const sp& listener); michael@0: - virtual void stopRecording(); michael@0: - virtual void releaseRecordingFrame(const sp& mem); michael@0: - michael@0: - private: michael@0: - sp mCamera; michael@0: - }; michael@0: - michael@0: -private: michael@0: - Camera(); michael@0: - Camera(const Camera&); michael@0: - Camera& operator=(const Camera); michael@0: - virtual void binderDied(const wp& who); michael@0: - michael@0: - class DeathNotifier: public IBinder::DeathRecipient michael@0: - { michael@0: - public: michael@0: - DeathNotifier() { michael@0: - } michael@0: - michael@0: - virtual void binderDied(const wp& who); michael@0: - }; michael@0: - michael@0: - static sp mDeathNotifier; michael@0: - michael@0: - // helper function to obtain camera service handle michael@0: - static const sp& getCameraService(); michael@0: - michael@0: - sp mCamera; michael@0: - status_t mStatus; michael@0: - michael@0: - sp mListener; michael@0: - sp mRecordingProxyListener; michael@0: - michael@0: - friend class DeathNotifier; michael@0: - michael@0: - static Mutex mLock; michael@0: - static sp mCameraService; michael@0: -}; michael@0: - michael@0: }; // namespace android michael@0: michael@0: #endif michael@0: diff --git a/GonkCameraSource.cpp b/GonkCameraSource.cpp michael@0: index af6b340..9dba596 100644 michael@0: --- a/GonkCameraSource.cpp michael@0: +++ b/GonkCameraSource.cpp michael@0: @@ -14,29 +14,34 @@ michael@0: * limitations under the License. michael@0: */ michael@0: michael@0: -//#define LOG_NDEBUG 0 michael@0: -#define LOG_TAG "CameraSource" michael@0: -#include michael@0: +#include michael@0: +#include "nsDebug.h" michael@0: +#define DOM_CAMERA_LOG_LEVEL 3 michael@0: +#include "CameraCommon.h" michael@0: +#define LOGD DOM_CAMERA_LOGA michael@0: +#define LOGV DOM_CAMERA_LOGI michael@0: +#define LOGI DOM_CAMERA_LOGI michael@0: +#define LOGW DOM_CAMERA_LOGW michael@0: +#define LOGE DOM_CAMERA_LOGE michael@0: michael@0: #include michael@0: -#include michael@0: -#include michael@0: +#include "GonkCameraSource.h" michael@0: +#include "GonkCameraListener.h" michael@0: +#include "GonkCameraHwMgr.h" michael@0: #include michael@0: #include michael@0: #include michael@0: #include michael@0: -#include michael@0: -#include michael@0: -#include michael@0: #include michael@0: #include michael@0: michael@0: +using namespace mozilla; michael@0: namespace android { michael@0: michael@0: static const int64_t CAMERA_SOURCE_TIMEOUT_NS = 3000000000LL; michael@0: michael@0: -struct CameraSourceListener : public CameraListener { michael@0: - CameraSourceListener(const sp &source); michael@0: +struct GonkCameraSourceListener : public GonkCameraListener { michael@0: + GonkCameraSourceListener(const sp &source); michael@0: michael@0: virtual void notify(int32_t msgType, int32_t ext1, int32_t ext2); michael@0: virtual void postData(int32_t msgType, const sp &dataPtr, michael@0: @@ -46,41 +51,41 @@ struct CameraSourceListener : public CameraListener { michael@0: nsecs_t timestamp, int32_t msgType, const sp& dataPtr); michael@0: michael@0: protected: michael@0: - virtual ~CameraSourceListener(); michael@0: + virtual ~GonkCameraSourceListener(); michael@0: michael@0: private: michael@0: - wp mSource; michael@0: + wp mSource; michael@0: michael@0: - CameraSourceListener(const CameraSourceListener &); michael@0: - CameraSourceListener &operator=(const CameraSourceListener &); michael@0: + GonkCameraSourceListener(const GonkCameraSourceListener &); michael@0: + GonkCameraSourceListener &operator=(const GonkCameraSourceListener &); michael@0: }; michael@0: michael@0: -CameraSourceListener::CameraSourceListener(const sp &source) michael@0: +GonkCameraSourceListener::GonkCameraSourceListener(const sp &source) michael@0: : mSource(source) { michael@0: } michael@0: michael@0: -CameraSourceListener::~CameraSourceListener() { michael@0: +GonkCameraSourceListener::~GonkCameraSourceListener() { michael@0: } michael@0: michael@0: -void CameraSourceListener::notify(int32_t msgType, int32_t ext1, int32_t ext2) { michael@0: +void GonkCameraSourceListener::notify(int32_t msgType, int32_t ext1, int32_t ext2) { michael@0: LOGV("notify(%d, %d, %d)", msgType, ext1, ext2); michael@0: } michael@0: michael@0: -void CameraSourceListener::postData(int32_t msgType, const sp &dataPtr, michael@0: +void GonkCameraSourceListener::postData(int32_t msgType, const sp &dataPtr, michael@0: camera_frame_metadata_t *metadata) { michael@0: LOGV("postData(%d, ptr:%p, size:%d)", michael@0: msgType, dataPtr->pointer(), dataPtr->size()); michael@0: michael@0: - sp source = mSource.promote(); michael@0: + sp source = mSource.promote(); michael@0: if (source.get() != NULL) { michael@0: source->dataCallback(msgType, dataPtr); michael@0: } michael@0: } michael@0: michael@0: -void CameraSourceListener::postDataTimestamp( michael@0: +void GonkCameraSourceListener::postDataTimestamp( michael@0: nsecs_t timestamp, int32_t msgType, const sp& dataPtr) { michael@0: michael@0: - sp source = mSource.promote(); michael@0: + sp source = mSource.promote(); michael@0: if (source.get() != NULL) { michael@0: source->dataCallbackTimestamp(timestamp/1000, msgType, dataPtr); michael@0: } michael@0: @@ -114,48 +119,30 @@ static int32_t getColorFormat(const char* colorFormat) { michael@0: } michael@0: michael@0: LOGE("Uknown color format (%s), please add it to " michael@0: - "CameraSource::getColorFormat", colorFormat); michael@0: + "GonkCameraSource::getColorFormat", colorFormat); michael@0: michael@0: CHECK_EQ(0, "Unknown color format"); michael@0: } michael@0: michael@0: -CameraSource *CameraSource::Create() { michael@0: - Size size; michael@0: - size.width = -1; michael@0: - size.height = -1; michael@0: - michael@0: - sp camera; michael@0: - return new CameraSource(camera, NULL, 0, size, -1, NULL, false); michael@0: -} michael@0: - michael@0: -// static michael@0: -CameraSource *CameraSource::CreateFromCamera( michael@0: - const sp& camera, michael@0: - const sp& proxy, michael@0: - int32_t cameraId, michael@0: +GonkCameraSource *GonkCameraSource::Create( michael@0: + int32_t cameraHandle, michael@0: Size videoSize, michael@0: int32_t frameRate, michael@0: - const sp& surface, michael@0: bool storeMetaDataInVideoBuffers) { michael@0: michael@0: - CameraSource *source = new CameraSource(camera, proxy, cameraId, michael@0: - videoSize, frameRate, surface, michael@0: + GonkCameraSource *source = new GonkCameraSource(cameraHandle, michael@0: + videoSize, frameRate, michael@0: storeMetaDataInVideoBuffers); michael@0: return source; michael@0: } michael@0: michael@0: -CameraSource::CameraSource( michael@0: - const sp& camera, michael@0: - const sp& proxy, michael@0: - int32_t cameraId, michael@0: +GonkCameraSource::GonkCameraSource( michael@0: + int32_t cameraHandle, michael@0: Size videoSize, michael@0: int32_t frameRate, michael@0: - const sp& surface, michael@0: bool storeMetaDataInVideoBuffers) michael@0: : mCameraFlags(0), michael@0: mVideoFrameRate(-1), michael@0: - mCamera(0), michael@0: - mSurface(surface), michael@0: mNumFramesReceived(0), michael@0: mLastFrameTimestampUs(0), michael@0: mStarted(false), michael@0: @@ -169,43 +156,19 @@ CameraSource::CameraSource( michael@0: mVideoSize.width = -1; michael@0: mVideoSize.height = -1; michael@0: michael@0: - mInitCheck = init(camera, proxy, cameraId, michael@0: + mCameraHandle = cameraHandle; michael@0: + michael@0: + mInitCheck = init( michael@0: videoSize, frameRate, michael@0: storeMetaDataInVideoBuffers); michael@0: if (mInitCheck != OK) releaseCamera(); michael@0: } michael@0: michael@0: -status_t CameraSource::initCheck() const { michael@0: +status_t GonkCameraSource::initCheck() const { michael@0: return mInitCheck; michael@0: } michael@0: michael@0: -status_t CameraSource::isCameraAvailable( michael@0: - const sp& camera, const sp& proxy, michael@0: - int32_t cameraId) { michael@0: - michael@0: - if (camera == 0) { michael@0: - mCamera = Camera::connect(cameraId); michael@0: - if (mCamera == 0) return -EBUSY; michael@0: - mCameraFlags &= ~FLAGS_HOT_CAMERA; michael@0: - } else { michael@0: - // We get the proxy from Camera, not ICamera. We need to get the proxy michael@0: - // to the remote Camera owned by the application. Here mCamera is a michael@0: - // local Camera object created by us. We cannot use the proxy from michael@0: - // mCamera here. michael@0: - mCamera = Camera::create(camera); michael@0: - if (mCamera == 0) return -EBUSY; michael@0: - mCameraRecordingProxy = proxy; michael@0: - mCameraFlags |= FLAGS_HOT_CAMERA; michael@0: - mDeathNotifier = new DeathNotifier(); michael@0: - // isBinderAlive needs linkToDeath to work. michael@0: - mCameraRecordingProxy->asBinder()->linkToDeath(mDeathNotifier); michael@0: - } michael@0: - michael@0: - mCamera->lock(); michael@0: - michael@0: - return OK; michael@0: -} michael@0: - michael@0: +//TODO: Do we need to reimplement isCameraAvailable? michael@0: michael@0: /* michael@0: * Check to see whether the requested video width and height is one michael@0: @@ -267,7 +230,7 @@ static void getSupportedVideoSizes( michael@0: * @param params CameraParameters to retrieve the information michael@0: * @return OK if no error. michael@0: */ michael@0: -status_t CameraSource::isCameraColorFormatSupported( michael@0: +status_t GonkCameraSource::isCameraColorFormatSupported( michael@0: const CameraParameters& params) { michael@0: mColorFormat = getColorFormat(params.get( michael@0: CameraParameters::KEY_VIDEO_FRAME_FORMAT)); michael@0: @@ -292,7 +255,7 @@ status_t CameraSource::isCameraColorFormatSupported( michael@0: * @param frameRate the target frame rate in frames per second. michael@0: * @return OK if no error. michael@0: */ michael@0: -status_t CameraSource::configureCamera( michael@0: +status_t GonkCameraSource::configureCamera( michael@0: CameraParameters* params, michael@0: int32_t width, int32_t height, michael@0: int32_t frameRate) { michael@0: @@ -347,10 +310,9 @@ status_t CameraSource::configureCamera( michael@0: michael@0: if (isCameraParamChanged) { michael@0: // Either frame rate or frame size needs to be changed. michael@0: - String8 s = params->flatten(); michael@0: - if (OK != mCamera->setParameters(s)) { michael@0: + if (OK != GonkCameraHardware::PushParameters(mCameraHandle,*params)) { michael@0: LOGE("Could not change settings." michael@0: - " Someone else is using camera %p?", mCamera.get()); michael@0: + " Someone else is using camera ?"); michael@0: return -EBUSY; michael@0: } michael@0: } michael@0: @@ -368,7 +330,7 @@ status_t CameraSource::configureCamera( michael@0: * @param the target video frame height in pixels to check against michael@0: * @return OK if no error michael@0: */ michael@0: -status_t CameraSource::checkVideoSize( michael@0: +status_t GonkCameraSource::checkVideoSize( michael@0: const CameraParameters& params, michael@0: int32_t width, int32_t height) { michael@0: michael@0: @@ -420,7 +382,7 @@ status_t CameraSource::checkVideoSize( michael@0: * @param the target video frame rate to check against michael@0: * @return OK if no error. michael@0: */ michael@0: -status_t CameraSource::checkFrameRate( michael@0: +status_t GonkCameraSource::checkFrameRate( michael@0: const CameraParameters& params, michael@0: int32_t frameRate) { michael@0: michael@0: @@ -462,39 +424,17 @@ status_t CameraSource::checkFrameRate( michael@0: * michael@0: * @return OK if no error. michael@0: */ michael@0: -status_t CameraSource::init( michael@0: - const sp& camera, michael@0: - const sp& proxy, michael@0: - int32_t cameraId, michael@0: +status_t GonkCameraSource::init( michael@0: Size videoSize, michael@0: int32_t frameRate, michael@0: bool storeMetaDataInVideoBuffers) { michael@0: michael@0: LOGV("init"); michael@0: status_t err = OK; michael@0: - int64_t token = IPCThreadState::self()->clearCallingIdentity(); michael@0: - err = initWithCameraAccess(camera, proxy, cameraId, michael@0: - videoSize, frameRate, michael@0: - storeMetaDataInVideoBuffers); michael@0: - IPCThreadState::self()->restoreCallingIdentity(token); michael@0: - return err; michael@0: -} michael@0: - michael@0: -status_t CameraSource::initWithCameraAccess( michael@0: - const sp& camera, michael@0: - const sp& proxy, michael@0: - int32_t cameraId, michael@0: - Size videoSize, michael@0: - int32_t frameRate, michael@0: - bool storeMetaDataInVideoBuffers) { michael@0: - LOGV("initWithCameraAccess"); michael@0: - status_t err = OK; michael@0: + //TODO: need to do something here to check the sanity of camera michael@0: michael@0: - if ((err = isCameraAvailable(camera, proxy, cameraId)) != OK) { michael@0: - LOGE("Camera connection could not be established."); michael@0: - return err; michael@0: - } michael@0: - CameraParameters params(mCamera->getParameters()); michael@0: + CameraParameters params; michael@0: + GonkCameraHardware::PullParameters(mCameraHandle, params); michael@0: if ((err = isCameraColorFormatSupported(params)) != OK) { michael@0: return err; michael@0: } michael@0: @@ -508,7 +448,8 @@ status_t CameraSource::initWithCameraAccess( michael@0: } michael@0: michael@0: // Check on video frame size and frame rate. michael@0: - CameraParameters newCameraParams(mCamera->getParameters()); michael@0: + CameraParameters newCameraParams; michael@0: + GonkCameraHardware::PullParameters(mCameraHandle, newCameraParams); michael@0: if ((err = checkVideoSize(newCameraParams, michael@0: videoSize.width, videoSize.height)) != OK) { michael@0: return err; michael@0: @@ -517,15 +458,11 @@ status_t CameraSource::initWithCameraAccess( michael@0: return err; michael@0: } michael@0: michael@0: - // This CHECK is good, since we just passed the lock/unlock michael@0: - // check earlier by calling mCamera->setParameters(). michael@0: - CHECK_EQ(OK, mCamera->setPreviewDisplay(mSurface)); michael@0: - michael@0: // By default, do not store metadata in video buffers michael@0: mIsMetaDataStoredInVideoBuffers = false; michael@0: - mCamera->storeMetaDataInBuffers(false); michael@0: + GonkCameraHardware::StoreMetaDataInBuffers(mCameraHandle, false); michael@0: if (storeMetaDataInVideoBuffers) { michael@0: - if (OK == mCamera->storeMetaDataInBuffers(true)) { michael@0: + if (OK == GonkCameraHardware::StoreMetaDataInBuffers(mCameraHandle, true)) { michael@0: mIsMetaDataStoredInVideoBuffers = true; michael@0: } michael@0: } michael@0: @@ -568,40 +505,28 @@ status_t CameraSource::initWithCameraAccess( michael@0: return OK; michael@0: } michael@0: michael@0: -CameraSource::~CameraSource() { michael@0: +GonkCameraSource::~GonkCameraSource() { michael@0: if (mStarted) { michael@0: stop(); michael@0: } else if (mInitCheck == OK) { michael@0: // Camera is initialized but because start() is never called, michael@0: // the lock on Camera is never released(). This makes sure michael@0: // Camera's lock is released in this case. michael@0: + // TODO: Don't think I need to do this michael@0: releaseCamera(); michael@0: } michael@0: } michael@0: michael@0: -void CameraSource::startCameraRecording() { michael@0: +void GonkCameraSource::startCameraRecording() { michael@0: LOGV("startCameraRecording"); michael@0: - // Reset the identity to the current thread because media server owns the michael@0: - // camera and recording is started by the applications. The applications michael@0: - // will connect to the camera in ICameraRecordingProxy::startRecording. michael@0: - int64_t token = IPCThreadState::self()->clearCallingIdentity(); michael@0: - if (mCameraFlags & FLAGS_HOT_CAMERA) { michael@0: - mCamera->unlock(); michael@0: - mCamera.clear(); michael@0: - CHECK_EQ(OK, mCameraRecordingProxy->startRecording(new ProxyListener(this))); michael@0: - } else { michael@0: - mCamera->setListener(new CameraSourceListener(this)); michael@0: - mCamera->startRecording(); michael@0: - CHECK(mCamera->recordingEnabled()); michael@0: - } michael@0: - IPCThreadState::self()->restoreCallingIdentity(token); michael@0: + CHECK_EQ(OK, GonkCameraHardware::StartRecording(mCameraHandle)); michael@0: } michael@0: michael@0: -status_t CameraSource::start(MetaData *meta) { michael@0: +status_t GonkCameraSource::start(MetaData *meta) { michael@0: LOGV("start"); michael@0: CHECK(!mStarted); michael@0: if (mInitCheck != OK) { michael@0: - LOGE("CameraSource is not initialized yet"); michael@0: + LOGE("GonkCameraSource is not initialized yet"); michael@0: return mInitCheck; michael@0: } michael@0: michael@0: @@ -614,58 +539,34 @@ status_t CameraSource::start(MetaData *meta) { michael@0: mStartTimeUs = 0; michael@0: int64_t startTimeUs; michael@0: if (meta && meta->findInt64(kKeyTime, &startTimeUs)) { michael@0: + LOGV("Metadata enabled, startime: %lld us", startTimeUs); michael@0: mStartTimeUs = startTimeUs; michael@0: } michael@0: michael@0: + // Register a listener with GonkCameraHardware so that we can get callbacks michael@0: + GonkCameraHardware::SetListener(mCameraHandle, new GonkCameraSourceListener(this)); michael@0: + michael@0: startCameraRecording(); michael@0: michael@0: mStarted = true; michael@0: return OK; michael@0: } michael@0: michael@0: -void CameraSource::stopCameraRecording() { michael@0: +void GonkCameraSource::stopCameraRecording() { michael@0: LOGV("stopCameraRecording"); michael@0: - if (mCameraFlags & FLAGS_HOT_CAMERA) { michael@0: - mCameraRecordingProxy->stopRecording(); michael@0: - } else { michael@0: - mCamera->setListener(NULL); michael@0: - mCamera->stopRecording(); michael@0: - } michael@0: + GonkCameraHardware::StopRecording(mCameraHandle); michael@0: } michael@0: michael@0: -void CameraSource::releaseCamera() { michael@0: +void GonkCameraSource::releaseCamera() { michael@0: LOGV("releaseCamera"); michael@0: - if (mCamera != 0) { michael@0: - int64_t token = IPCThreadState::self()->clearCallingIdentity(); michael@0: - if ((mCameraFlags & FLAGS_HOT_CAMERA) == 0) { michael@0: - LOGV("Camera was cold when we started, stopping preview"); michael@0: - mCamera->stopPreview(); michael@0: - mCamera->disconnect(); michael@0: - } michael@0: - mCamera->unlock(); michael@0: - mCamera.clear(); michael@0: - mCamera = 0; michael@0: - IPCThreadState::self()->restoreCallingIdentity(token); michael@0: - } michael@0: - if (mCameraRecordingProxy != 0) { michael@0: - mCameraRecordingProxy->asBinder()->unlinkToDeath(mDeathNotifier); michael@0: - mCameraRecordingProxy.clear(); michael@0: - } michael@0: - mCameraFlags = 0; michael@0: } michael@0: michael@0: -status_t CameraSource::stop() { michael@0: - LOGD("stop: E"); michael@0: +status_t GonkCameraSource::stop() { michael@0: + LOGV("stop: E"); michael@0: Mutex::Autolock autoLock(mLock); michael@0: mStarted = false; michael@0: mFrameAvailableCondition.signal(); michael@0: michael@0: - int64_t token; michael@0: - bool isTokenValid = false; michael@0: - if (mCamera != 0) { michael@0: - token = IPCThreadState::self()->clearCallingIdentity(); michael@0: - isTokenValid = true; michael@0: - } michael@0: releaseQueuedFrames(); michael@0: while (!mFramesBeingEncoded.empty()) { michael@0: if (NO_ERROR != michael@0: @@ -675,11 +576,9 @@ status_t CameraSource::stop() { michael@0: mFramesBeingEncoded.size()); michael@0: } michael@0: } michael@0: + LOGV("Calling stopCameraRecording"); michael@0: stopCameraRecording(); michael@0: releaseCamera(); michael@0: - if (isTokenValid) { michael@0: - IPCThreadState::self()->restoreCallingIdentity(token); michael@0: - } michael@0: michael@0: if (mCollectStats) { michael@0: LOGI("Frames received/encoded/dropped: %d/%d/%d in %lld us", michael@0: @@ -692,22 +591,16 @@ status_t CameraSource::stop() { michael@0: } michael@0: michael@0: CHECK_EQ(mNumFramesReceived, mNumFramesEncoded + mNumFramesDropped); michael@0: - LOGD("stop: X"); michael@0: + LOGV("stop: X"); michael@0: return OK; michael@0: } michael@0: michael@0: -void CameraSource::releaseRecordingFrame(const sp& frame) { michael@0: +void GonkCameraSource::releaseRecordingFrame(const sp& frame) { michael@0: LOGV("releaseRecordingFrame"); michael@0: - if (mCameraRecordingProxy != NULL) { michael@0: - mCameraRecordingProxy->releaseRecordingFrame(frame); michael@0: - } else if (mCamera != NULL) { michael@0: - int64_t token = IPCThreadState::self()->clearCallingIdentity(); michael@0: - mCamera->releaseRecordingFrame(frame); michael@0: - IPCThreadState::self()->restoreCallingIdentity(token); michael@0: - } michael@0: + GonkCameraHardware::ReleaseRecordingFrame(mCameraHandle, frame); michael@0: } michael@0: michael@0: -void CameraSource::releaseQueuedFrames() { michael@0: +void GonkCameraSource::releaseQueuedFrames() { michael@0: List >::iterator it; michael@0: while (!mFramesReceived.empty()) { michael@0: it = mFramesReceived.begin(); michael@0: @@ -717,15 +610,15 @@ void CameraSource::releaseQueuedFrames() { michael@0: } michael@0: } michael@0: michael@0: -sp CameraSource::getFormat() { michael@0: +sp GonkCameraSource::getFormat() { michael@0: return mMeta; michael@0: } michael@0: michael@0: -void CameraSource::releaseOneRecordingFrame(const sp& frame) { michael@0: +void GonkCameraSource::releaseOneRecordingFrame(const sp& frame) { michael@0: releaseRecordingFrame(frame); michael@0: } michael@0: michael@0: -void CameraSource::signalBufferReturned(MediaBuffer *buffer) { michael@0: +void GonkCameraSource::signalBufferReturned(MediaBuffer *buffer) { michael@0: LOGV("signalBufferReturned: %p", buffer->data()); michael@0: Mutex::Autolock autoLock(mLock); michael@0: for (List >::iterator it = mFramesBeingEncoded.begin(); michael@0: @@ -743,7 +636,7 @@ void CameraSource::signalBufferReturned(MediaBuffer *buffer) { michael@0: CHECK_EQ(0, "signalBufferReturned: bogus buffer"); michael@0: } michael@0: michael@0: -status_t CameraSource::read( michael@0: +status_t GonkCameraSource::read( michael@0: MediaBuffer **buffer, const ReadOptions *options) { michael@0: LOGV("read"); michael@0: michael@0: @@ -764,11 +657,7 @@ status_t CameraSource::read( michael@0: if (NO_ERROR != michael@0: mFrameAvailableCondition.waitRelative(mLock, michael@0: mTimeBetweenFrameCaptureUs * 1000LL + CAMERA_SOURCE_TIMEOUT_NS)) { michael@0: - if (mCameraRecordingProxy != 0 && michael@0: - !mCameraRecordingProxy->asBinder()->isBinderAlive()) { michael@0: - LOGW("camera recording proxy is gone"); michael@0: - return ERROR_END_OF_STREAM; michael@0: - } michael@0: + //TODO: check sanity of camera? michael@0: LOGW("Timed out waiting for incoming camera video frames: %lld us", michael@0: mLastFrameTimestampUs); michael@0: } michael@0: @@ -790,9 +679,10 @@ status_t CameraSource::read( michael@0: return OK; michael@0: } michael@0: michael@0: -void CameraSource::dataCallbackTimestamp(int64_t timestampUs, michael@0: +void GonkCameraSource::dataCallbackTimestamp(int64_t timestampUs, michael@0: int32_t msgType, const sp &data) { michael@0: LOGV("dataCallbackTimestamp: timestamp %lld us", timestampUs); michael@0: + //LOGV("dataCallbackTimestamp: data %x size %d", data->pointer(), data->size()); michael@0: Mutex::Autolock autoLock(mLock); michael@0: if (!mStarted || (mNumFramesReceived == 0 && timestampUs < mStartTimeUs)) { michael@0: LOGV("Drop frame at %lld/%lld us", timestampUs, mStartTimeUs); michael@0: @@ -808,7 +698,7 @@ void CameraSource::dataCallbackTimestamp(int64_t timestampUs, michael@0: } michael@0: michael@0: // May need to skip frame or modify timestamp. Currently implemented michael@0: - // by the subclass CameraSourceTimeLapse. michael@0: + // by the subclass GonkCameraSourceTimeLapse. michael@0: if (skipCurrentFrame(timestampUs)) { michael@0: releaseOneRecordingFrame(data); michael@0: return; michael@0: @@ -839,22 +729,9 @@ void CameraSource::dataCallbackTimestamp(int64_t timestampUs, michael@0: mFrameAvailableCondition.signal(); michael@0: } michael@0: michael@0: -bool CameraSource::isMetaDataStoredInVideoBuffers() const { michael@0: +bool GonkCameraSource::isMetaDataStoredInVideoBuffers() const { michael@0: LOGV("isMetaDataStoredInVideoBuffers"); michael@0: return mIsMetaDataStoredInVideoBuffers; michael@0: } michael@0: michael@0: -CameraSource::ProxyListener::ProxyListener(const sp& source) { michael@0: - mSource = source; michael@0: -} michael@0: - michael@0: -void CameraSource::ProxyListener::dataCallbackTimestamp( michael@0: - nsecs_t timestamp, int32_t msgType, const sp& dataPtr) { michael@0: - mSource->dataCallbackTimestamp(timestamp / 1000, msgType, dataPtr); michael@0: -} michael@0: - michael@0: -void CameraSource::DeathNotifier::binderDied(const wp& who) { michael@0: - LOGI("Camera recording proxy died"); michael@0: -} michael@0: - michael@0: -} // namespace android michael@0: +} // namespace android michael@0: diff --git a/GonkCameraSource.h b/GonkCameraSource.h michael@0: index 446720b..fe58f96 100644 michael@0: --- a/GonkCameraSource.h michael@0: +++ b/GonkCameraSource.h michael@0: @@ -14,69 +14,31 @@ michael@0: * limitations under the License. michael@0: */ michael@0: michael@0: -#ifndef CAMERA_SOURCE_H_ michael@0: +#ifndef GONK_CAMERA_SOURCE_H_ michael@0: michael@0: -#define CAMERA_SOURCE_H_ michael@0: +#define GONK_CAMERA_SOURCE_H_ michael@0: michael@0: #include michael@0: #include michael@0: -#include michael@0: -#include michael@0: #include michael@0: #include michael@0: #include michael@0: +#include michael@0: michael@0: namespace android { michael@0: michael@0: class IMemory; michael@0: -class Camera; michael@0: -class Surface; michael@0: +class GonkCameraSourceListener; michael@0: michael@0: -class CameraSource : public MediaSource, public MediaBufferObserver { michael@0: +class GonkCameraSource : public MediaSource, public MediaBufferObserver { michael@0: public: michael@0: - /** michael@0: - * Factory method to create a new CameraSource using the current michael@0: - * settings (such as video size, frame rate, color format, etc) michael@0: - * from the default camera. michael@0: - * michael@0: - * @return NULL on error. michael@0: - */ michael@0: - static CameraSource *Create(); michael@0: michael@0: - /** michael@0: - * Factory method to create a new CameraSource. michael@0: - * michael@0: - * @param camera the video input frame data source. If it is NULL, michael@0: - * we will try to connect to the camera with the given michael@0: - * cameraId. michael@0: - * michael@0: - * @param cameraId the id of the camera that the source will connect michael@0: - * to if camera is NULL; otherwise ignored. michael@0: - * michael@0: - * @param videoSize the dimension (in pixels) of the video frame michael@0: - * @param frameRate the target frames per second michael@0: - * @param surface the preview surface for display where preview michael@0: - * frames are sent to michael@0: - * @param storeMetaDataInVideoBuffers true to request the camera michael@0: - * source to store meta data in video buffers; false to michael@0: - * request the camera source to store real YUV frame data michael@0: - * in the video buffers. The camera source may not support michael@0: - * storing meta data in video buffers, if so, a request michael@0: - * to do that will NOT be honored. To find out whether michael@0: - * meta data is actually being stored in video buffers michael@0: - * during recording, call isMetaDataStoredInVideoBuffers(). michael@0: - * michael@0: - * @return NULL on error. michael@0: - */ michael@0: - static CameraSource *CreateFromCamera(const sp &camera, michael@0: - const sp &proxy, michael@0: - int32_t cameraId, michael@0: - Size videoSize, michael@0: - int32_t frameRate, michael@0: - const sp& surface, michael@0: - bool storeMetaDataInVideoBuffers = false); michael@0: + static GonkCameraSource *Create(int32_t cameraHandle, michael@0: + Size videoSize, michael@0: + int32_t frameRate, michael@0: + bool storeMetaDataInVideoBuffers = false); michael@0: michael@0: - virtual ~CameraSource(); michael@0: + virtual ~GonkCameraSource(); michael@0: michael@0: virtual status_t start(MetaData *params = NULL); michael@0: virtual status_t stop(); michael@0: @@ -84,14 +46,14 @@ public: michael@0: MediaBuffer **buffer, const ReadOptions *options = NULL); michael@0: michael@0: /** michael@0: - * Check whether a CameraSource object is properly initialized. michael@0: + * Check whether a GonkCameraSource object is properly initialized. michael@0: * Must call this method before stop(). michael@0: * @return OK if initialization has successfully completed. michael@0: */ michael@0: virtual status_t initCheck() const; michael@0: michael@0: /** michael@0: - * Returns the MetaData associated with the CameraSource, michael@0: + * Returns the MetaData associated with the GonkCameraSource, michael@0: * including: michael@0: * kKeyColorFormat: YUV color format of the video frames michael@0: * kKeyWidth, kKeyHeight: dimension (in pixels) of the video frames michael@0: @@ -113,22 +75,6 @@ public: michael@0: virtual void signalBufferReturned(MediaBuffer* buffer); michael@0: michael@0: protected: michael@0: - class ProxyListener: public BnCameraRecordingProxyListener { michael@0: - public: michael@0: - ProxyListener(const sp& source); michael@0: - virtual void dataCallbackTimestamp(int64_t timestampUs, int32_t msgType, michael@0: - const sp &data); michael@0: - michael@0: - private: michael@0: - sp mSource; michael@0: - }; michael@0: - michael@0: - // isBinderAlive needs linkToDeath to work. michael@0: - class DeathNotifier: public IBinder::DeathRecipient { michael@0: - public: michael@0: - DeathNotifier() {} michael@0: - virtual void binderDied(const wp& who); michael@0: - }; michael@0: michael@0: enum CameraFlags { michael@0: FLAGS_SET_CAMERA = 1L << 0, michael@0: @@ -141,10 +87,6 @@ protected: michael@0: int32_t mColorFormat; michael@0: status_t mInitCheck; michael@0: michael@0: - sp mCamera; michael@0: - sp mCameraRecordingProxy; michael@0: - sp mDeathNotifier; michael@0: - sp mSurface; michael@0: sp mMeta; michael@0: michael@0: int64_t mStartTimeUs; michael@0: @@ -156,11 +98,9 @@ protected: michael@0: // Time between capture of two frames. michael@0: int64_t mTimeBetweenFrameCaptureUs; michael@0: michael@0: - CameraSource(const sp& camera, const sp& proxy, michael@0: - int32_t cameraId, michael@0: + GonkCameraSource(int32_t cameraHandle, michael@0: Size videoSize, int32_t frameRate, michael@0: - const sp& surface, michael@0: - bool storeMetaDataInVideoBuffers); michael@0: + bool storeMetaDataInVideoBuffers = false); michael@0: michael@0: virtual void startCameraRecording(); michael@0: virtual void stopCameraRecording(); michael@0: @@ -170,6 +110,7 @@ protected: michael@0: // Called from dataCallbackTimestamp. michael@0: virtual bool skipCurrentFrame(int64_t timestampUs) {return false;} michael@0: michael@0: + friend class GonkCameraSourceListener; michael@0: // Callback called when still camera raw data is available. michael@0: virtual void dataCallback(int32_t msgType, const sp &data) {} michael@0: michael@0: @@ -177,7 +118,6 @@ protected: michael@0: const sp &data); michael@0: michael@0: private: michael@0: - friend class CameraSourceListener; michael@0: michael@0: Mutex mLock; michael@0: Condition mFrameAvailableCondition; michael@0: @@ -192,23 +132,13 @@ private: michael@0: int64_t mGlitchDurationThresholdUs; michael@0: bool mCollectStats; michael@0: bool mIsMetaDataStoredInVideoBuffers; michael@0: + int32_t mCameraHandle; michael@0: michael@0: void releaseQueuedFrames(); michael@0: void releaseOneRecordingFrame(const sp& frame); michael@0: michael@0: - michael@0: - status_t init(const sp& camera, const sp& proxy, michael@0: - int32_t cameraId, Size videoSize, int32_t frameRate, michael@0: - bool storeMetaDataInVideoBuffers); michael@0: - michael@0: - status_t initWithCameraAccess( michael@0: - const sp& camera, const sp& proxy, michael@0: - int32_t cameraId, Size videoSize, int32_t frameRate, michael@0: + status_t init(Size videoSize, int32_t frameRate, michael@0: bool storeMetaDataInVideoBuffers); michael@0: - michael@0: - status_t isCameraAvailable(const sp& camera, michael@0: - const sp& proxy, michael@0: - int32_t cameraId); michael@0: status_t isCameraColorFormatSupported(const CameraParameters& params); michael@0: status_t configureCamera(CameraParameters* params, michael@0: int32_t width, int32_t height, michael@0: @@ -222,10 +152,10 @@ private: michael@0: michael@0: void releaseCamera(); michael@0: michael@0: - CameraSource(const CameraSource &); michael@0: - CameraSource &operator=(const CameraSource &); michael@0: + GonkCameraSource(const GonkCameraSource &); michael@0: + GonkCameraSource &operator=(const GonkCameraSource &); michael@0: }; michael@0: michael@0: } // namespace android michael@0: michael@0: -#endif // CAMERA_SOURCE_H_ michael@0: +#endif // GONK_CAMERA_SOURCE_H_ michael@0: diff --git a/GonkRecorder.cpp b/GonkRecorder.cpp michael@0: index b20ca9d..2dc625c 100644 michael@0: --- a/GonkRecorder.cpp michael@0: +++ b/GonkRecorder.cpp michael@0: @@ -16,35 +16,23 @@ michael@0: */ michael@0: michael@0: //#define LOG_NDEBUG 0 michael@0: -#define LOG_TAG "StagefrightRecorder" michael@0: +#define LOG_TAG "GonkRecorder" michael@0: + michael@0: #include michael@0: #include michael@0: -#include "StagefrightRecorder.h" michael@0: - michael@0: -#include michael@0: -#include michael@0: +#include "GonkRecorder.h" michael@0: michael@0: -#include michael@0: #include michael@0: #include michael@0: -#include michael@0: -#include michael@0: -#include michael@0: -#include michael@0: -#include michael@0: #include michael@0: #include michael@0: #include michael@0: #include michael@0: #include michael@0: #include michael@0: -#include michael@0: +#include michael@0: #include michael@0: -#include michael@0: #include michael@0: -#include michael@0: -#include michael@0: -#include michael@0: #include michael@0: michael@0: #include michael@0: @@ -57,51 +45,41 @@ michael@0: #include "ARTPWriter.h" michael@0: michael@0: #include michael@0: +#include "GonkCameraSource.h" michael@0: michael@0: namespace android { michael@0: michael@0: -// To collect the encoder usage for the battery app michael@0: -static void addBatteryData(uint32_t params) { michael@0: - sp binder = michael@0: - defaultServiceManager()->getService(String16("media.player")); michael@0: - sp service = interface_cast(binder); michael@0: - CHECK(service.get() != NULL); michael@0: - michael@0: - service->addBatteryData(params); michael@0: +static sp sOMX = NULL; michael@0: +static sp GetOMX() { michael@0: + if(sOMX.get() == NULL) { michael@0: + sOMX = new OMX; michael@0: + } michael@0: + return sOMX; michael@0: } michael@0: michael@0: - michael@0: -StagefrightRecorder::StagefrightRecorder() michael@0: +GonkRecorder::GonkRecorder() michael@0: : mWriter(NULL), michael@0: mOutputFd(-1), michael@0: mAudioSource(AUDIO_SOURCE_CNT), michael@0: mVideoSource(VIDEO_SOURCE_LIST_END), michael@0: - mStarted(false), mSurfaceMediaSource(NULL), michael@0: + mStarted(false), michael@0: mDisableAudio(false) { michael@0: michael@0: LOGV("Constructor"); michael@0: reset(); michael@0: } michael@0: michael@0: -StagefrightRecorder::~StagefrightRecorder() { michael@0: +GonkRecorder::~GonkRecorder() { michael@0: LOGV("Destructor"); michael@0: stop(); michael@0: } michael@0: michael@0: -status_t StagefrightRecorder::init() { michael@0: +status_t GonkRecorder::init() { michael@0: LOGV("init"); michael@0: return OK; michael@0: } michael@0: michael@0: -// The client side of mediaserver asks it to creat a SurfaceMediaSource michael@0: -// and return a interface reference. The client side will use that michael@0: -// while encoding GL Frames michael@0: -sp StagefrightRecorder::querySurfaceMediaSource() const { michael@0: - LOGV("Get SurfaceMediaSource"); michael@0: - return mSurfaceMediaSource; michael@0: -} michael@0: - michael@0: -status_t StagefrightRecorder::setAudioSource(audio_source_t as) { michael@0: +status_t GonkRecorder::setAudioSource(audio_source_t as) { michael@0: LOGV("setAudioSource: %d", as); michael@0: if (as < AUDIO_SOURCE_DEFAULT || michael@0: as >= AUDIO_SOURCE_CNT) { michael@0: @@ -122,7 +100,7 @@ michael@0: return OK; michael@0: } michael@0: michael@0: -status_t StagefrightRecorder::setVideoSource(video_source vs) { michael@0: +status_t GonkRecorder::setVideoSource(video_source vs) { michael@0: LOGV("setVideoSource: %d", vs); michael@0: if (vs < VIDEO_SOURCE_DEFAULT || michael@0: vs >= VIDEO_SOURCE_LIST_END) { michael@0: @@ -139,7 +117,7 @@ michael@0: return OK; michael@0: } michael@0: michael@0: -status_t StagefrightRecorder::setOutputFormat(output_format of) { michael@0: +status_t GonkRecorder::setOutputFormat(output_format of) { michael@0: LOGV("setOutputFormat: %d", of); michael@0: if (of < OUTPUT_FORMAT_DEFAULT || michael@0: of >= OUTPUT_FORMAT_LIST_END) { michael@0: @@ -156,7 +134,7 @@ michael@0: return OK; michael@0: } michael@0: michael@0: -status_t StagefrightRecorder::setAudioEncoder(audio_encoder ae) { michael@0: +status_t GonkRecorder::setAudioEncoder(audio_encoder ae) { michael@0: LOGV("setAudioEncoder: %d", ae); michael@0: if (ae < AUDIO_ENCODER_DEFAULT || michael@0: ae >= AUDIO_ENCODER_LIST_END) { michael@0: @@ -174,21 +152,10 @@ michael@0: mAudioEncoder = ae; michael@0: } michael@0: michael@0: - // Use default values if appropriate setparam's weren't called. michael@0: - if(mAudioEncoder == AUDIO_ENCODER_AAC) { michael@0: - mSampleRate = mSampleRate ? mSampleRate : 48000; michael@0: - mAudioChannels = mAudioChannels ? mAudioChannels : 2; michael@0: - mAudioBitRate = mAudioBitRate ? mAudioBitRate : 156000; michael@0: - } michael@0: - else{ michael@0: - mSampleRate = mSampleRate ? mSampleRate : 8000; michael@0: - mAudioChannels = mAudioChannels ? mAudioChannels : 1; michael@0: - mAudioBitRate = mAudioBitRate ? mAudioBitRate : 12200; michael@0: - } michael@0: return OK; michael@0: } michael@0: michael@0: -status_t StagefrightRecorder::setVideoEncoder(video_encoder ve) { michael@0: +status_t GonkRecorder::setVideoEncoder(video_encoder ve) { michael@0: LOGV("setVideoEncoder: %d", ve); michael@0: if (ve < VIDEO_ENCODER_DEFAULT || michael@0: ve >= VIDEO_ENCODER_LIST_END) { michael@0: @@ -205,7 +172,7 @@ michael@0: return OK; michael@0: } michael@0: michael@0: -status_t StagefrightRecorder::setVideoSize(int width, int height) { michael@0: +status_t GonkRecorder::setVideoSize(int width, int height) { michael@0: LOGV("setVideoSize: %dx%d", width, height); michael@0: if (width <= 0 || height <= 0) { michael@0: LOGE("Invalid video size: %dx%d", width, height); michael@0: @@ -219,7 +186,7 @@ michael@0: return OK; michael@0: } michael@0: michael@0: -status_t StagefrightRecorder::setVideoFrameRate(int frames_per_second) { michael@0: +status_t GonkRecorder::setVideoFrameRate(int frames_per_second) { michael@0: LOGV("setVideoFrameRate: %d", frames_per_second); michael@0: if ((frames_per_second <= 0 && frames_per_second != -1) || michael@0: frames_per_second > 120) { michael@0: @@ -233,31 +200,7 @@ michael@0: return OK; michael@0: } michael@0: michael@0: -status_t StagefrightRecorder::setCamera(const sp &camera, michael@0: - const sp &proxy) { michael@0: - LOGV("setCamera"); michael@0: - if (camera == 0) { michael@0: - LOGE("camera is NULL"); michael@0: - return BAD_VALUE; michael@0: - } michael@0: - if (proxy == 0) { michael@0: - LOGE("camera proxy is NULL"); michael@0: - return BAD_VALUE; michael@0: - } michael@0: - michael@0: - mCamera = camera; michael@0: - mCameraProxy = proxy; michael@0: - return OK; michael@0: -} michael@0: - michael@0: -status_t StagefrightRecorder::setPreviewSurface(const sp &surface) { michael@0: - LOGV("setPreviewSurface: %p", surface.get()); michael@0: - mPreviewSurface = surface; michael@0: - michael@0: - return OK; michael@0: -} michael@0: - michael@0: -status_t StagefrightRecorder::setOutputFile(const char *path) { michael@0: +status_t GonkRecorder::setOutputFile(const char *path) { michael@0: LOGE("setOutputFile(const char*) must not be called"); michael@0: // We don't actually support this at all, as the media_server process michael@0: // no longer has permissions to create files. michael@0: @@ -265,7 +208,7 @@ michael@0: return -EPERM; michael@0: } michael@0: michael@0: -status_t StagefrightRecorder::setOutputFile(int fd, int64_t offset, int64_t length) { michael@0: +status_t GonkRecorder::setOutputFile(int fd, int64_t offset, int64_t length) { michael@0: LOGV("setOutputFile: %d, %lld, %lld", fd, offset, length); michael@0: // These don't make any sense, do they? michael@0: CHECK_EQ(offset, 0); michael@0: @@ -339,7 +282,7 @@ michael@0: s->setTo(String8(&data[leading_space], i - leading_space)); michael@0: } michael@0: michael@0: -status_t StagefrightRecorder::setParamAudioSamplingRate(int32_t sampleRate) { michael@0: +status_t GonkRecorder::setParamAudioSamplingRate(int32_t sampleRate) { michael@0: LOGV("setParamAudioSamplingRate: %d", sampleRate); michael@0: if (sampleRate <= 0) { michael@0: LOGE("Invalid audio sampling rate: %d", sampleRate); michael@0: @@ -351,7 +294,7 @@ michael@0: return OK; michael@0: } michael@0: michael@0: -status_t StagefrightRecorder::setParamAudioNumberOfChannels(int32_t channels) { michael@0: +status_t GonkRecorder::setParamAudioNumberOfChannels(int32_t channels) { michael@0: LOGV("setParamAudioNumberOfChannels: %d", channels); michael@0: if (channels <= 0 || channels >= 3) { michael@0: LOGE("Invalid number of audio channels: %d", channels); michael@0: @@ -363,7 +306,7 @@ michael@0: return OK; michael@0: } michael@0: michael@0: -status_t StagefrightRecorder::setParamAudioEncodingBitRate(int32_t bitRate) { michael@0: +status_t GonkRecorder::setParamAudioEncodingBitRate(int32_t bitRate) { michael@0: LOGV("setParamAudioEncodingBitRate: %d", bitRate); michael@0: if (bitRate <= 0) { michael@0: LOGE("Invalid audio encoding bit rate: %d", bitRate); michael@0: @@ -378,7 +321,7 @@ michael@0: return OK; michael@0: } michael@0: michael@0: -status_t StagefrightRecorder::setParamVideoEncodingBitRate(int32_t bitRate) { michael@0: +status_t GonkRecorder::setParamVideoEncodingBitRate(int32_t bitRate) { michael@0: LOGV("setParamVideoEncodingBitRate: %d", bitRate); michael@0: if (bitRate <= 0) { michael@0: LOGE("Invalid video encoding bit rate: %d", bitRate); michael@0: @@ -394,7 +337,7 @@ michael@0: } michael@0: michael@0: // Always rotate clockwise, and only support 0, 90, 180 and 270 for now. michael@0: -status_t StagefrightRecorder::setParamVideoRotation(int32_t degrees) { michael@0: +status_t GonkRecorder::setParamVideoRotation(int32_t degrees) { michael@0: LOGV("setParamVideoRotation: %d", degrees); michael@0: if (degrees < 0 || degrees % 90 != 0) { michael@0: LOGE("Unsupported video rotation angle: %d", degrees); michael@0: @@ -404,7 +347,7 @@ michael@0: return OK; michael@0: } michael@0: michael@0: -status_t StagefrightRecorder::setParamMaxFileDurationUs(int64_t timeUs) { michael@0: +status_t GonkRecorder::setParamMaxFileDurationUs(int64_t timeUs) { michael@0: LOGV("setParamMaxFileDurationUs: %lld us", timeUs); michael@0: michael@0: // This is meant for backward compatibility for MediaRecorder.java michael@0: @@ -423,7 +366,7 @@ michael@0: return OK; michael@0: } michael@0: michael@0: -status_t StagefrightRecorder::setParamMaxFileSizeBytes(int64_t bytes) { michael@0: +status_t GonkRecorder::setParamMaxFileSizeBytes(int64_t bytes) { michael@0: LOGV("setParamMaxFileSizeBytes: %lld bytes", bytes); michael@0: michael@0: // This is meant for backward compatibility for MediaRecorder.java michael@0: @@ -449,7 +392,7 @@ michael@0: return OK; michael@0: } michael@0: michael@0: -status_t StagefrightRecorder::setParamInterleaveDuration(int32_t durationUs) { michael@0: +status_t GonkRecorder::setParamInterleaveDuration(int32_t durationUs) { michael@0: LOGV("setParamInterleaveDuration: %d", durationUs); michael@0: if (durationUs <= 500000) { // 500 ms michael@0: // If interleave duration is too small, it is very inefficient to do michael@0: @@ -471,20 +414,20 @@ michael@0: // If seconds < 0, only the first frame is I frame, and rest are all P frames michael@0: // If seconds == 0, all frames are encoded as I frames. No P frames michael@0: // If seconds > 0, it is the time spacing (seconds) between 2 neighboring I frames michael@0: -status_t StagefrightRecorder::setParamVideoIFramesInterval(int32_t seconds) { michael@0: +status_t GonkRecorder::setParamVideoIFramesInterval(int32_t seconds) { michael@0: LOGV("setParamVideoIFramesInterval: %d seconds", seconds); michael@0: mIFramesIntervalSec = seconds; michael@0: return OK; michael@0: } michael@0: michael@0: -status_t StagefrightRecorder::setParam64BitFileOffset(bool use64Bit) { michael@0: +status_t GonkRecorder::setParam64BitFileOffset(bool use64Bit) { michael@0: LOGV("setParam64BitFileOffset: %s", michael@0: use64Bit? "use 64 bit file offset": "use 32 bit file offset"); michael@0: mUse64BitFileOffset = use64Bit; michael@0: return OK; michael@0: } michael@0: michael@0: -status_t StagefrightRecorder::setParamVideoCameraId(int32_t cameraId) { michael@0: +status_t GonkRecorder::setParamVideoCameraId(int32_t cameraId) { michael@0: LOGV("setParamVideoCameraId: %d", cameraId); michael@0: if (cameraId < 0) { michael@0: return BAD_VALUE; michael@0: @@ -493,7 +436,7 @@ michael@0: return OK; michael@0: } michael@0: michael@0: -status_t StagefrightRecorder::setParamTrackTimeStatus(int64_t timeDurationUs) { michael@0: +status_t GonkRecorder::setParamTrackTimeStatus(int64_t timeDurationUs) { michael@0: LOGV("setParamTrackTimeStatus: %lld", timeDurationUs); michael@0: if (timeDurationUs < 20000) { // Infeasible if shorter than 20 ms? michael@0: LOGE("Tracking time duration too short: %lld us", timeDurationUs); michael@0: @@ -503,7 +446,7 @@ michael@0: return OK; michael@0: } michael@0: michael@0: -status_t StagefrightRecorder::setParamVideoEncoderProfile(int32_t profile) { michael@0: +status_t GonkRecorder::setParamVideoEncoderProfile(int32_t profile) { michael@0: LOGV("setParamVideoEncoderProfile: %d", profile); michael@0: michael@0: // Additional check will be done later when we load the encoder. michael@0: @@ -512,7 +455,7 @@ michael@0: return OK; michael@0: } michael@0: michael@0: -status_t StagefrightRecorder::setParamVideoEncoderLevel(int32_t level) { michael@0: +status_t GonkRecorder::setParamVideoEncoderLevel(int32_t level) { michael@0: LOGV("setParamVideoEncoderLevel: %d", level); michael@0: michael@0: // Additional check will be done later when we load the encoder. michael@0: @@ -521,7 +464,7 @@ michael@0: return OK; michael@0: } michael@0: michael@0: -status_t StagefrightRecorder::setParamMovieTimeScale(int32_t timeScale) { michael@0: +status_t GonkRecorder::setParamMovieTimeScale(int32_t timeScale) { michael@0: LOGV("setParamMovieTimeScale: %d", timeScale); michael@0: michael@0: // The range is set to be the same as the audio's time scale range michael@0: @@ -534,7 +477,7 @@ michael@0: return OK; michael@0: } michael@0: michael@0: -status_t StagefrightRecorder::setParamVideoTimeScale(int32_t timeScale) { michael@0: +status_t GonkRecorder::setParamVideoTimeScale(int32_t timeScale) { michael@0: LOGV("setParamVideoTimeScale: %d", timeScale); michael@0: michael@0: // 60000 is chosen to make sure that each video frame from a 60-fps michael@0: @@ -547,7 +490,7 @@ michael@0: return OK; michael@0: } michael@0: michael@0: -status_t StagefrightRecorder::setParamAudioTimeScale(int32_t timeScale) { michael@0: +status_t GonkRecorder::setParamAudioTimeScale(int32_t timeScale) { michael@0: LOGV("setParamAudioTimeScale: %d", timeScale); michael@0: michael@0: // 96000 Hz is the highest sampling rate support in AAC. michael@0: @@ -559,33 +502,7 @@ michael@0: return OK; michael@0: } michael@0: michael@0: -status_t StagefrightRecorder::setParamTimeLapseEnable(int32_t timeLapseEnable) { michael@0: - LOGV("setParamTimeLapseEnable: %d", timeLapseEnable); michael@0: - michael@0: - if(timeLapseEnable == 0) { michael@0: - mCaptureTimeLapse = false; michael@0: - } else if (timeLapseEnable == 1) { michael@0: - mCaptureTimeLapse = true; michael@0: - } else { michael@0: - return BAD_VALUE; michael@0: - } michael@0: - return OK; michael@0: -} michael@0: - michael@0: -status_t StagefrightRecorder::setParamTimeBetweenTimeLapseFrameCapture(int64_t timeUs) { michael@0: - LOGV("setParamTimeBetweenTimeLapseFrameCapture: %lld us", timeUs); michael@0: - michael@0: - // Not allowing time more than a day michael@0: - if (timeUs <= 0 || timeUs > 86400*1E6) { michael@0: - LOGE("Time between time lapse frame capture (%lld) is out of range [0, 1 Day]", timeUs); michael@0: - return BAD_VALUE; michael@0: - } michael@0: - michael@0: - mTimeBetweenTimeLapseFrameCaptureUs = timeUs; michael@0: - return OK; michael@0: -} michael@0: - michael@0: -status_t StagefrightRecorder::setParamGeoDataLongitude( michael@0: +status_t GonkRecorder::setParamGeoDataLongitude( michael@0: int64_t longitudex10000) { michael@0: michael@0: if (longitudex10000 > 1800000 || longitudex10000 < -1800000) { michael@0: @@ -595,7 +512,7 @@ michael@0: return OK; michael@0: } michael@0: michael@0: -status_t StagefrightRecorder::setParamGeoDataLatitude( michael@0: +status_t GonkRecorder::setParamGeoDataLatitude( michael@0: int64_t latitudex10000) { michael@0: michael@0: if (latitudex10000 > 900000 || latitudex10000 < -900000) { michael@0: @@ -605,7 +522,7 @@ michael@0: return OK; michael@0: } michael@0: michael@0: -status_t StagefrightRecorder::setParameter( michael@0: +status_t GonkRecorder::setParameter( michael@0: const String8 &key, const String8 &value) { michael@0: LOGV("setParameter: key (%s) => value (%s)", key.string(), value.string()); michael@0: if (key == "max-duration") { michael@0: @@ -703,24 +620,13 @@ michael@0: if (safe_strtoi32(value.string(), &timeScale)) { michael@0: return setParamVideoTimeScale(timeScale); michael@0: } michael@0: - } else if (key == "time-lapse-enable") { michael@0: - int32_t timeLapseEnable; michael@0: - if (safe_strtoi32(value.string(), &timeLapseEnable)) { michael@0: - return setParamTimeLapseEnable(timeLapseEnable); michael@0: - } michael@0: - } else if (key == "time-between-time-lapse-frame-capture") { michael@0: - int64_t timeBetweenTimeLapseFrameCaptureMs; michael@0: - if (safe_strtoi64(value.string(), &timeBetweenTimeLapseFrameCaptureMs)) { michael@0: - return setParamTimeBetweenTimeLapseFrameCapture( michael@0: - 1000LL * timeBetweenTimeLapseFrameCaptureMs); michael@0: - } michael@0: } else { michael@0: LOGE("setParameter: failed to find key %s", key.string()); michael@0: } michael@0: return BAD_VALUE; michael@0: } michael@0: michael@0: -status_t StagefrightRecorder::setParameters(const String8 ¶ms) { michael@0: +status_t GonkRecorder::setParameters(const String8 ¶ms) { michael@0: LOGV("setParameters: %s", params.string()); michael@0: const char *cparams = params.string(); michael@0: const char *key_start = cparams; michael@0: @@ -755,13 +661,13 @@ michael@0: return OK; michael@0: } michael@0: michael@0: -status_t StagefrightRecorder::setListener(const sp &listener) { michael@0: +status_t GonkRecorder::setListener(const sp &listener) { michael@0: mListener = listener; michael@0: michael@0: return OK; michael@0: } michael@0: michael@0: -status_t StagefrightRecorder::prepare() { michael@0: +status_t GonkRecorder::prepare() { michael@0: LOGV(" %s E", __func__ ); michael@0: michael@0: if(mVideoSource != VIDEO_SOURCE_LIST_END && mVideoEncoder != VIDEO_ENCODER_LIST_END && mVideoHeight && mVideoWidth && /*Video recording*/ michael@0: @@ -776,17 +682,15 @@ michael@0: return OK; michael@0: } michael@0: michael@0: -status_t StagefrightRecorder::start() { michael@0: +status_t GonkRecorder::start() { michael@0: CHECK(mOutputFd >= 0); michael@0: michael@0: if (mWriter != NULL) { michael@0: - LOGE("File writer is not avaialble"); michael@0: + LOGE("File writer is not available"); michael@0: return UNKNOWN_ERROR; michael@0: } michael@0: michael@0: status_t status = OK; michael@0: - if(AUDIO_SOURCE_FM_RX_A2DP == mAudioSource) michael@0: - return startFMA2DPWriter(); michael@0: michael@0: switch (mOutputFormat) { michael@0: case OUTPUT_FORMAT_DEFAULT: michael@0: @@ -800,22 +704,9 @@ michael@0: status = startAMRRecording(); michael@0: break; michael@0: michael@0: - case OUTPUT_FORMAT_AAC_ADIF: michael@0: - case OUTPUT_FORMAT_AAC_ADTS: michael@0: - status = startAACRecording(); michael@0: - break; michael@0: - michael@0: - case OUTPUT_FORMAT_RTP_AVP: michael@0: - status = startRTPRecording(); michael@0: - break; michael@0: - michael@0: case OUTPUT_FORMAT_MPEG2TS: michael@0: status = startMPEG2TSRecording(); michael@0: break; michael@0: - michael@0: - case OUTPUT_FORMAT_QCP: michael@0: - status = startExtendedRecording( ); michael@0: - break; michael@0: default: michael@0: LOGE("Unsupported output file format: %d", mOutputFormat); michael@0: status = UNKNOWN_ERROR; michael@0: @@ -824,22 +715,12 @@ michael@0: michael@0: if ((status == OK) && (!mStarted)) { michael@0: mStarted = true; michael@0: - michael@0: - uint32_t params = IMediaPlayerService::kBatteryDataCodecStarted; michael@0: - if (mAudioSource != AUDIO_SOURCE_CNT) { michael@0: - params |= IMediaPlayerService::kBatteryDataTrackAudio; michael@0: - } michael@0: - if (mVideoSource != VIDEO_SOURCE_LIST_END) { michael@0: - params |= IMediaPlayerService::kBatteryDataTrackVideo; michael@0: - } michael@0: - michael@0: - addBatteryData(params); michael@0: } michael@0: michael@0: return status; michael@0: } michael@0: michael@0: -sp StagefrightRecorder::createAudioSource() { michael@0: +sp GonkRecorder::createAudioSource() { michael@0: michael@0: bool tunneledSource = false; michael@0: const char *tunnelMime; michael@0: @@ -907,12 +788,6 @@ michael@0: case AUDIO_ENCODER_AAC: michael@0: mime = MEDIA_MIMETYPE_AUDIO_AAC; michael@0: break; michael@0: - case AUDIO_ENCODER_EVRC: michael@0: - mime = MEDIA_MIMETYPE_AUDIO_EVRC; michael@0: - break; michael@0: - case AUDIO_ENCODER_QCELP: michael@0: - mime = MEDIA_MIMETYPE_AUDIO_QCELP; michael@0: - break; michael@0: default: michael@0: LOGE("Unknown audio encoder: %d", mAudioEncoder); michael@0: return NULL; michael@0: @@ -931,36 +806,17 @@ michael@0: encMeta->setInt32(kKeyTimeScale, mAudioTimeScale); michael@0: } michael@0: michael@0: - OMXClient client; michael@0: - CHECK_EQ(client.connect(), OK); michael@0: - michael@0: + // use direct OMX interface instead of connecting to michael@0: + // mediaserver over binder calls michael@0: sp audioEncoder = michael@0: - OMXCodec::Create(client.interface(), encMeta, michael@0: + OMXCodec::Create(GetOMX(), encMeta, michael@0: true /* createEncoder */, audioSource); michael@0: mAudioSourceNode = audioSource; michael@0: michael@0: return audioEncoder; michael@0: } michael@0: michael@0: -status_t StagefrightRecorder::startAACRecording() { michael@0: - // FIXME: michael@0: - // Add support for OUTPUT_FORMAT_AAC_ADIF michael@0: - CHECK(mOutputFormat == OUTPUT_FORMAT_AAC_ADTS); michael@0: - michael@0: - CHECK(mAudioEncoder == AUDIO_ENCODER_AAC); michael@0: - CHECK(mAudioSource != AUDIO_SOURCE_CNT); michael@0: - michael@0: - mWriter = new AACWriter(mOutputFd); michael@0: - status_t status = startRawAudioRecording(); michael@0: - if (status != OK) { michael@0: - mWriter.clear(); michael@0: - mWriter = NULL; michael@0: - } michael@0: - michael@0: - return status; michael@0: -} michael@0: - michael@0: -status_t StagefrightRecorder::startAMRRecording() { michael@0: +status_t GonkRecorder::startAMRRecording() { michael@0: CHECK(mOutputFormat == OUTPUT_FORMAT_AMR_NB || michael@0: mOutputFormat == OUTPUT_FORMAT_AMR_WB); michael@0: michael@0: @@ -971,28 +827,12 @@ michael@0: mAudioEncoder); michael@0: return BAD_VALUE; michael@0: } michael@0: - if (mSampleRate != 8000) { michael@0: - LOGE("Invalid sampling rate %d used for AMRNB recording", michael@0: - mSampleRate); michael@0: - return BAD_VALUE; michael@0: - } michael@0: } else { // mOutputFormat must be OUTPUT_FORMAT_AMR_WB michael@0: if (mAudioEncoder != AUDIO_ENCODER_AMR_WB) { michael@0: LOGE("Invlaid encoder %d used for AMRWB recording", michael@0: mAudioEncoder); michael@0: return BAD_VALUE; michael@0: } michael@0: - if (mSampleRate != 16000) { michael@0: - LOGE("Invalid sample rate %d used for AMRWB recording", michael@0: - mSampleRate); michael@0: - return BAD_VALUE; michael@0: - } michael@0: - } michael@0: - michael@0: - if (mAudioChannels != 1) { michael@0: - LOGE("Invalid number of audio channels %d used for amr recording", michael@0: - mAudioChannels); michael@0: - return BAD_VALUE; michael@0: } michael@0: michael@0: mWriter = new AMRWriter(mOutputFd); michael@0: @@ -1004,7 +844,7 @@ michael@0: return status; michael@0: } michael@0: michael@0: -status_t StagefrightRecorder::startRawAudioRecording() { michael@0: +status_t GonkRecorder::startRawAudioRecording() { michael@0: if (mAudioSource >= AUDIO_SOURCE_CNT) { michael@0: LOGE("Invalid audio source: %d", mAudioSource); michael@0: return BAD_VALUE; michael@0: @@ -1035,62 +875,7 @@ michael@0: return OK; michael@0: } michael@0: michael@0: -status_t StagefrightRecorder::startFMA2DPWriter() { michael@0: - /* FM soc outputs at 48k */ michael@0: - mSampleRate = 48000; michael@0: - mAudioChannels = 2; michael@0: - michael@0: - sp meta = new MetaData; michael@0: - meta->setInt32(kKeyChannelCount, mAudioChannels); michael@0: - meta->setInt32(kKeySampleRate, mSampleRate); michael@0: - michael@0: - mWriter = new FMA2DPWriter(); michael@0: - mWriter->setListener(mListener); michael@0: - mWriter->start(meta.get()); michael@0: - return OK; michael@0: -} michael@0: - michael@0: -status_t StagefrightRecorder::startRTPRecording() { michael@0: - CHECK_EQ(mOutputFormat, OUTPUT_FORMAT_RTP_AVP); michael@0: - michael@0: - if ((mAudioSource != AUDIO_SOURCE_CNT michael@0: - && mVideoSource != VIDEO_SOURCE_LIST_END) michael@0: - || (mAudioSource == AUDIO_SOURCE_CNT michael@0: - && mVideoSource == VIDEO_SOURCE_LIST_END)) { michael@0: - // Must have exactly one source. michael@0: - return BAD_VALUE; michael@0: - } michael@0: - michael@0: - if (mOutputFd < 0) { michael@0: - return BAD_VALUE; michael@0: - } michael@0: - michael@0: - sp source; michael@0: - michael@0: - if (mAudioSource != AUDIO_SOURCE_CNT) { michael@0: - source = createAudioSource(); michael@0: - } else { michael@0: - michael@0: - sp mediaSource; michael@0: - status_t err = setupMediaSource(&mediaSource); michael@0: - if (err != OK) { michael@0: - return err; michael@0: - } michael@0: - michael@0: - err = setupVideoEncoder(mediaSource, mVideoBitRate, &source); michael@0: - if (err != OK) { michael@0: - return err; michael@0: - } michael@0: - } michael@0: - michael@0: - mWriter = new ARTPWriter(mOutputFd); michael@0: - mWriter->addSource(source); michael@0: - mWriter->setListener(mListener); michael@0: - michael@0: - return mWriter->start(); michael@0: -} michael@0: - michael@0: -status_t StagefrightRecorder::startMPEG2TSRecording() { michael@0: +status_t GonkRecorder::startMPEG2TSRecording() { michael@0: CHECK_EQ(mOutputFormat, OUTPUT_FORMAT_MPEG2TS); michael@0: michael@0: sp writer = new MPEG2TSWriter(mOutputFd); michael@0: @@ -1141,7 +926,7 @@ michael@0: return mWriter->start(); michael@0: } michael@0: michael@0: -void StagefrightRecorder::clipVideoFrameRate() { michael@0: +void GonkRecorder::clipVideoFrameRate() { michael@0: LOGV("clipVideoFrameRate: encoder %d", mVideoEncoder); michael@0: int minFrameRate = mEncoderProfiles->getVideoEncoderParamByName( michael@0: "enc.vid.fps.min", mVideoEncoder); michael@0: @@ -1158,7 +943,7 @@ michael@0: } michael@0: } michael@0: michael@0: -void StagefrightRecorder::clipVideoBitRate() { michael@0: +void GonkRecorder::clipVideoBitRate() { michael@0: LOGV("clipVideoBitRate: encoder %d", mVideoEncoder); michael@0: int minBitRate = mEncoderProfiles->getVideoEncoderParamByName( michael@0: "enc.vid.bps.min", mVideoEncoder); michael@0: @@ -1175,7 +960,7 @@ michael@0: } michael@0: } michael@0: michael@0: -void StagefrightRecorder::clipVideoFrameWidth() { michael@0: +void GonkRecorder::clipVideoFrameWidth() { michael@0: LOGV("clipVideoFrameWidth: encoder %d", mVideoEncoder); michael@0: int minFrameWidth = mEncoderProfiles->getVideoEncoderParamByName( michael@0: "enc.vid.width.min", mVideoEncoder); michael@0: @@ -1192,8 +977,7 @@ michael@0: } michael@0: } michael@0: michael@0: -status_t StagefrightRecorder::checkVideoEncoderCapabilities() { michael@0: - if (!mCaptureTimeLapse) { michael@0: +status_t GonkRecorder::checkVideoEncoderCapabilities() { michael@0: // Dont clip for time lapse capture as encoder will have enough michael@0: // time to encode because of slow capture rate of time lapse. michael@0: clipVideoBitRate(); michael@0: @@ -1201,13 +985,12 @@ michael@0: clipVideoFrameWidth(); michael@0: clipVideoFrameHeight(); michael@0: setDefaultProfileIfNecessary(); michael@0: - } michael@0: return OK; michael@0: } michael@0: michael@0: // Set to use AVC baseline profile if the encoding parameters matches michael@0: // CAMCORDER_QUALITY_LOW profile; this is for the sake of MMS service. michael@0: -void StagefrightRecorder::setDefaultProfileIfNecessary() { michael@0: +void GonkRecorder::setDefaultProfileIfNecessary() { michael@0: LOGV("setDefaultProfileIfNecessary"); michael@0: michael@0: camcorder_quality quality = CAMCORDER_QUALITY_LOW; michael@0: @@ -1263,14 +1046,14 @@ michael@0: } michael@0: } michael@0: michael@0: -status_t StagefrightRecorder::checkAudioEncoderCapabilities() { michael@0: +status_t GonkRecorder::checkAudioEncoderCapabilities() { michael@0: clipAudioBitRate(); michael@0: clipAudioSampleRate(); michael@0: clipNumberOfAudioChannels(); michael@0: return OK; michael@0: } michael@0: michael@0: -void StagefrightRecorder::clipAudioBitRate() { michael@0: +void GonkRecorder::clipAudioBitRate() { michael@0: LOGV("clipAudioBitRate: encoder %d", mAudioEncoder); michael@0: michael@0: int minAudioBitRate = michael@0: @@ -1292,7 +1075,7 @@ michael@0: } michael@0: } michael@0: michael@0: -void StagefrightRecorder::clipAudioSampleRate() { michael@0: +void GonkRecorder::clipAudioSampleRate() { michael@0: LOGV("clipAudioSampleRate: encoder %d", mAudioEncoder); michael@0: michael@0: int minSampleRate = michael@0: @@ -1314,7 +1097,7 @@ michael@0: } michael@0: } michael@0: michael@0: -void StagefrightRecorder::clipNumberOfAudioChannels() { michael@0: +void GonkRecorder::clipNumberOfAudioChannels() { michael@0: LOGV("clipNumberOfAudioChannels: encoder %d", mAudioEncoder); michael@0: michael@0: int minChannels = michael@0: @@ -1336,7 +1119,7 @@ michael@0: } michael@0: } michael@0: michael@0: -void StagefrightRecorder::clipVideoFrameHeight() { michael@0: +void GonkRecorder::clipVideoFrameHeight() { michael@0: LOGV("clipVideoFrameHeight: encoder %d", mVideoEncoder); michael@0: int minFrameHeight = mEncoderProfiles->getVideoEncoderParamByName( michael@0: "enc.vid.height.min", mVideoEncoder); michael@0: @@ -1354,61 +1137,26 @@ michael@0: } michael@0: michael@0: // Set up the appropriate MediaSource depending on the chosen option michael@0: -status_t StagefrightRecorder::setupMediaSource( michael@0: +status_t GonkRecorder::setupMediaSource( michael@0: sp *mediaSource) { michael@0: if (mVideoSource == VIDEO_SOURCE_DEFAULT michael@0: || mVideoSource == VIDEO_SOURCE_CAMERA) { michael@0: - sp cameraSource; michael@0: + sp cameraSource; michael@0: status_t err = setupCameraSource(&cameraSource); michael@0: if (err != OK) { michael@0: return err; michael@0: } michael@0: *mediaSource = cameraSource; michael@0: } else if (mVideoSource == VIDEO_SOURCE_GRALLOC_BUFFER) { michael@0: - // If using GRAlloc buffers, setup surfacemediasource. michael@0: - // Later a handle to that will be passed michael@0: - // to the client side when queried michael@0: - status_t err = setupSurfaceMediaSource(); michael@0: - if (err != OK) { michael@0: - return err; michael@0: - } michael@0: - *mediaSource = mSurfaceMediaSource; michael@0: + return BAD_VALUE; michael@0: } else { michael@0: return INVALID_OPERATION; michael@0: } michael@0: return OK; michael@0: } michael@0: michael@0: -// setupSurfaceMediaSource creates a source with the given michael@0: -// width and height and framerate. michael@0: -// TODO: This could go in a static function inside SurfaceMediaSource michael@0: -// similar to that in CameraSource michael@0: -status_t StagefrightRecorder::setupSurfaceMediaSource() { michael@0: - status_t err = OK; michael@0: - mSurfaceMediaSource = new SurfaceMediaSource(mVideoWidth, mVideoHeight); michael@0: - if (mSurfaceMediaSource == NULL) { michael@0: - return NO_INIT; michael@0: - } michael@0: - michael@0: - if (mFrameRate == -1) { michael@0: - int32_t frameRate = 0; michael@0: - CHECK (mSurfaceMediaSource->getFormat()->findInt32( michael@0: - kKeyFrameRate, &frameRate)); michael@0: - LOGI("Frame rate is not explicitly set. Use the current frame " michael@0: - "rate (%d fps)", frameRate); michael@0: - mFrameRate = frameRate; michael@0: - } else { michael@0: - err = mSurfaceMediaSource->setFrameRate(mFrameRate); michael@0: - } michael@0: - CHECK(mFrameRate != -1); michael@0: - michael@0: - mIsMetaDataStoredInVideoBuffers = michael@0: - mSurfaceMediaSource->isMetaDataStoredInVideoBuffers(); michael@0: - return err; michael@0: -} michael@0: - michael@0: -status_t StagefrightRecorder::setupCameraSource( michael@0: - sp *cameraSource) { michael@0: +status_t GonkRecorder::setupCameraSource( michael@0: + sp *cameraSource) { michael@0: status_t err = OK; michael@0: if ((err = checkVideoEncoderCapabilities()) != OK) { michael@0: return err; michael@0: @@ -1416,26 +1164,15 @@ michael@0: Size videoSize; michael@0: videoSize.width = mVideoWidth; michael@0: videoSize.height = mVideoHeight; michael@0: - if (mCaptureTimeLapse) { michael@0: - mCameraSourceTimeLapse = CameraSourceTimeLapse::CreateFromCamera( michael@0: - mCamera, mCameraProxy, mCameraId, michael@0: - videoSize, mFrameRate, mPreviewSurface, michael@0: - mTimeBetweenTimeLapseFrameCaptureUs); michael@0: - *cameraSource = mCameraSourceTimeLapse; michael@0: - } else { michael@0: - michael@0: - bool useMeta = true; michael@0: - char value[PROPERTY_VALUE_MAX]; michael@0: - if (property_get("debug.camcorder.disablemeta", value, NULL) && michael@0: + bool useMeta = true; michael@0: + char value[PROPERTY_VALUE_MAX]; michael@0: + if (property_get("debug.camcorder.disablemeta", value, NULL) && michael@0: atoi(value)) { michael@0: - useMeta = false; michael@0: - } michael@0: - *cameraSource = CameraSource::CreateFromCamera( michael@0: - mCamera, mCameraProxy, mCameraId, videoSize, mFrameRate, michael@0: - mPreviewSurface, useMeta); michael@0: + useMeta = false; michael@0: } michael@0: - mCamera.clear(); michael@0: - mCameraProxy.clear(); michael@0: + michael@0: + *cameraSource = GonkCameraSource::Create( michael@0: + mCameraHandle, videoSize, mFrameRate, useMeta); michael@0: if (*cameraSource == NULL) { michael@0: return UNKNOWN_ERROR; michael@0: } michael@0: @@ -1465,7 +1202,7 @@ michael@0: return OK; michael@0: } michael@0: michael@0: -status_t StagefrightRecorder::setupVideoEncoder( michael@0: +status_t GonkRecorder::setupVideoEncoder( michael@0: sp cameraSource, michael@0: int32_t videoBitRate, michael@0: sp *source) { michael@0: @@ -1501,10 +1238,7 @@ michael@0: CHECK(meta->findInt32(kKeyStride, &stride)); michael@0: CHECK(meta->findInt32(kKeySliceHeight, &sliceHeight)); michael@0: CHECK(meta->findInt32(kKeyColorFormat, &colorFormat)); michael@0: - hfr = 0; michael@0: - if (!meta->findInt32(kKeyHFR, &hfr)) { michael@0: - LOGW("hfr not found, default to 0"); michael@0: - } michael@0: + CHECK(meta->findInt32(kKeyHFR, &hfr)); michael@0: michael@0: if(hfr) { michael@0: mMaxFileDurationUs = mMaxFileDurationUs * (hfr/mFrameRate); michael@0: @@ -1598,30 +1332,17 @@ michael@0: enc_meta->setInt32(kKey3D, is3D); michael@0: } michael@0: michael@0: - OMXClient client; michael@0: - CHECK_EQ(client.connect(), OK); michael@0: - michael@0: uint32_t encoder_flags = 0; michael@0: if (mIsMetaDataStoredInVideoBuffers) { michael@0: LOGW("Camera source supports metadata mode, create OMXCodec for metadata"); michael@0: encoder_flags |= OMXCodec::kHardwareCodecsOnly; michael@0: encoder_flags |= OMXCodec::kStoreMetaDataInVideoBuffers; michael@0: - if (property_get("ro.board.platform", value, "0") michael@0: - && (!strncmp(value, "msm7627", sizeof("msm7627") - 1))) { michael@0: - LOGW("msm7627 family of chipsets supports, only one buffer at a time"); michael@0: - encoder_flags |= OMXCodec::kOnlySubmitOneInputBufferAtOneTime; michael@0: - } michael@0: - } michael@0: - michael@0: - // Do not wait for all the input buffers to become available. michael@0: - // This give timelapse video recording faster response in michael@0: - // receiving output from video encoder component. michael@0: - if (mCaptureTimeLapse) { michael@0: encoder_flags |= OMXCodec::kOnlySubmitOneInputBufferAtOneTime; michael@0: } michael@0: michael@0: sp encoder = OMXCodec::Create( michael@0: - client.interface(), enc_meta, michael@0: + GetOMX(), michael@0: + enc_meta, michael@0: true /* createEncoder */, cameraSource, michael@0: NULL, encoder_flags); michael@0: if (encoder == NULL) { michael@0: @@ -1638,7 +1359,7 @@ michael@0: return OK; michael@0: } michael@0: michael@0: -status_t StagefrightRecorder::setupAudioEncoder(const sp& writer) { michael@0: +status_t GonkRecorder::setupAudioEncoder(const sp& writer) { michael@0: status_t status = BAD_VALUE; michael@0: if (OK != (status = checkAudioEncoderCapabilities())) { michael@0: return status; michael@0: @@ -1664,7 +1385,7 @@ michael@0: return OK; michael@0: } michael@0: michael@0: -status_t StagefrightRecorder::setupMPEG4Recording( michael@0: +status_t GonkRecorder::setupMPEG4Recording( michael@0: int outputFd, michael@0: int32_t videoWidth, int32_t videoHeight, michael@0: int32_t videoBitRate, michael@0: @@ -1696,7 +1417,7 @@ michael@0: // Audio source is added at the end if it exists. michael@0: // This help make sure that the "recoding" sound is suppressed for michael@0: // camcorder applications in the recorded files. michael@0: - if (!mCaptureTimeLapse && (mAudioSource != AUDIO_SOURCE_CNT)) { michael@0: + if (mAudioSource != AUDIO_SOURCE_CNT) { michael@0: err = setupAudioEncoder(writer); michael@0: if (err != OK) return err; michael@0: *totalBitRate += mAudioBitRate; michael@0: @@ -1728,7 +1449,7 @@ michael@0: return OK; michael@0: } michael@0: michael@0: -void StagefrightRecorder::setupMPEG4MetaData(int64_t startTimeUs, int32_t totalBitRate, michael@0: +void GonkRecorder::setupMPEG4MetaData(int64_t startTimeUs, int32_t totalBitRate, michael@0: sp *meta) { michael@0: (*meta)->setInt64(kKeyTime, startTimeUs); michael@0: (*meta)->setInt32(kKeyFileType, mOutputFormat); michael@0: @@ -1752,7 +1473,7 @@ michael@0: } michael@0: } michael@0: michael@0: -status_t StagefrightRecorder::startMPEG4Recording() { michael@0: +status_t GonkRecorder::startMPEG4Recording() { michael@0: int32_t totalBitRate; michael@0: status_t err = setupMPEG4Recording( michael@0: mOutputFd, mVideoWidth, mVideoHeight, michael@0: @@ -1761,7 +1482,14 @@ michael@0: return err; michael@0: } michael@0: michael@0: - int64_t startTimeUs = systemTime() / 1000; michael@0: + //systemTime() doesn't give correct time because michael@0: + //HAVE_POSIX_CLOCKS is not defined for utils/Timers.cpp michael@0: + //so, using clock_gettime directly michael@0: +#include michael@0: + struct timespec t; michael@0: + clock_gettime(CLOCK_MONOTONIC, &t); michael@0: + int64_t startTimeUs = int64_t(t.tv_sec)*1000000000LL + t.tv_nsec; michael@0: + startTimeUs = startTimeUs / 1000; michael@0: sp meta = new MetaData; michael@0: setupMPEG4MetaData(startTimeUs, totalBitRate, &meta); michael@0: michael@0: @@ -1773,7 +1501,7 @@ michael@0: return OK; michael@0: } michael@0: michael@0: -status_t StagefrightRecorder::pause() { michael@0: +status_t GonkRecorder::pause() { michael@0: LOGV("pause"); michael@0: if (mWriter == NULL) { michael@0: return UNKNOWN_ERROR; michael@0: @@ -1782,31 +1510,16 @@ michael@0: michael@0: if (mStarted) { michael@0: mStarted = false; michael@0: - michael@0: - uint32_t params = 0; michael@0: - if (mAudioSource != AUDIO_SOURCE_CNT) { michael@0: - params |= IMediaPlayerService::kBatteryDataTrackAudio; michael@0: - } michael@0: - if (mVideoSource != VIDEO_SOURCE_LIST_END) { michael@0: - params |= IMediaPlayerService::kBatteryDataTrackVideo; michael@0: - } michael@0: - michael@0: - addBatteryData(params); michael@0: } michael@0: michael@0: michael@0: return OK; michael@0: } michael@0: michael@0: -status_t StagefrightRecorder::stop() { michael@0: +status_t GonkRecorder::stop() { michael@0: LOGV("stop"); michael@0: status_t err = OK; michael@0: michael@0: - if (mCaptureTimeLapse && mCameraSourceTimeLapse != NULL) { michael@0: - mCameraSourceTimeLapse->startQuickReadReturns(); michael@0: - mCameraSourceTimeLapse = NULL; michael@0: - } michael@0: - michael@0: if (mWriter != NULL) { michael@0: err = mWriter->stop(); michael@0: mWriter.clear(); michael@0: @@ -1819,30 +1532,20 @@ michael@0: michael@0: if (mStarted) { michael@0: mStarted = false; michael@0: - michael@0: - uint32_t params = 0; michael@0: - if (mAudioSource != AUDIO_SOURCE_CNT) { michael@0: - params |= IMediaPlayerService::kBatteryDataTrackAudio; michael@0: - } michael@0: - if (mVideoSource != VIDEO_SOURCE_LIST_END) { michael@0: - params |= IMediaPlayerService::kBatteryDataTrackVideo; michael@0: - } michael@0: - michael@0: - addBatteryData(params); michael@0: } michael@0: michael@0: michael@0: return err; michael@0: } michael@0: michael@0: -status_t StagefrightRecorder::close() { michael@0: +status_t GonkRecorder::close() { michael@0: LOGV("close"); michael@0: stop(); michael@0: michael@0: return OK; michael@0: } michael@0: michael@0: -status_t StagefrightRecorder::reset() { michael@0: +status_t GonkRecorder::reset() { michael@0: LOGV("reset"); michael@0: stop(); michael@0: michael@0: @@ -1858,9 +1561,9 @@ michael@0: mVideoHeight = 144; michael@0: mFrameRate = -1; michael@0: mVideoBitRate = 192000; michael@0: - mSampleRate = 0; michael@0: - mAudioChannels = 0; michael@0: - mAudioBitRate = 0; michael@0: + mSampleRate = 8000; michael@0: + mAudioChannels = 1; michael@0: + mAudioBitRate = 12200; michael@0: mInterleaveDurationUs = 0; michael@0: mIFramesIntervalSec = 2; michael@0: mAudioSourceNode = 0; michael@0: @@ -1875,9 +1578,6 @@ michael@0: mMaxFileDurationUs = 0; michael@0: mMaxFileSizeBytes = 0; michael@0: mTrackEveryTimeDurationUs = 0; michael@0: - mCaptureTimeLapse = false; michael@0: - mTimeBetweenTimeLapseFrameCaptureUs = -1; michael@0: - mCameraSourceTimeLapse = NULL; michael@0: mIsMetaDataStoredInVideoBuffers = false; michael@0: mEncoderProfiles = MediaProfiles::getInstance(); michael@0: mRotationDegrees = 0; michael@0: @@ -1885,6 +1585,11 @@ michael@0: mLongitudex10000 = -3600000; michael@0: michael@0: mOutputFd = -1; michael@0: + mCameraHandle = -1; michael@0: + //TODO: May need to register a listener eventually michael@0: + //if someone is interested in recorder events for now michael@0: + //default to no listener registered michael@0: + mListener = NULL; michael@0: michael@0: // Disable Audio Encoding michael@0: char value[PROPERTY_VALUE_MAX]; michael@0: @@ -1894,7 +1599,7 @@ michael@0: return OK; michael@0: } michael@0: michael@0: -status_t StagefrightRecorder::getMaxAmplitude(int *max) { michael@0: +status_t GonkRecorder::getMaxAmplitude(int *max) { michael@0: LOGV("getMaxAmplitude"); michael@0: michael@0: if (max == NULL) { michael@0: @@ -1911,7 +1616,7 @@ michael@0: return OK; michael@0: } michael@0: michael@0: -status_t StagefrightRecorder::dump( michael@0: +status_t GonkRecorder::dump( michael@0: int fd, const Vector& args) const { michael@0: LOGV("dump"); michael@0: const size_t SIZE = 256; michael@0: @@ -1958,6 +1663,8 @@ michael@0: result.append(buffer); michael@0: snprintf(buffer, SIZE, " Camera Id: %d\n", mCameraId); michael@0: result.append(buffer); michael@0: + snprintf(buffer, SIZE, " Camera Handle: %d\n", mCameraHandle); michael@0: + result.append(buffer); michael@0: snprintf(buffer, SIZE, " Start time offset (ms): %d\n", mStartTimeOffsetMs); michael@0: result.append(buffer); michael@0: snprintf(buffer, SIZE, " Encoder: %d\n", mVideoEncoder); michael@0: @@ -1978,45 +1685,12 @@ michael@0: return OK; michael@0: } michael@0: michael@0: -status_t StagefrightRecorder::startExtendedRecording() { michael@0: - CHECK(mOutputFormat == OUTPUT_FORMAT_QCP); michael@0: - michael@0: - if (mSampleRate != 8000) { michael@0: - LOGE("Invalid sampling rate %d used for recording", michael@0: - mSampleRate); michael@0: - return BAD_VALUE; michael@0: - } michael@0: - if (mAudioChannels != 1) { michael@0: - LOGE("Invalid number of audio channels %d used for recording", michael@0: - mAudioChannels); michael@0: - return BAD_VALUE; michael@0: - } michael@0: - michael@0: - if (mAudioSource >= AUDIO_SOURCE_CNT) { michael@0: - LOGE("Invalid audio source: %d", mAudioSource); michael@0: - return BAD_VALUE; michael@0: - } michael@0: - michael@0: - sp audioEncoder = createAudioSource(); michael@0: - michael@0: - if (audioEncoder == NULL) { michael@0: - LOGE("AudioEncoder NULL"); michael@0: - return UNKNOWN_ERROR; michael@0: - } michael@0: - michael@0: - mWriter = new ExtendedWriter(dup(mOutputFd)); michael@0: - mWriter->addSource(audioEncoder); michael@0: - michael@0: - if (mMaxFileDurationUs != 0) { michael@0: - mWriter->setMaxFileDuration(mMaxFileDurationUs); michael@0: - } michael@0: - if (mMaxFileSizeBytes != 0) { michael@0: - mWriter->setMaxFileSize(mMaxFileSizeBytes); michael@0: - } michael@0: - mWriter->setListener(mListener); michael@0: - mWriter->start(); michael@0: - michael@0: - return OK; michael@0: +status_t GonkRecorder::setCameraHandle(int32_t handle) { michael@0: + if (handle < 0) { michael@0: + return BAD_VALUE; michael@0: + } michael@0: + mCameraHandle = handle; michael@0: + return OK; michael@0: } michael@0: michael@0: } // namespace android michael@0: diff --git a/GonkRecorder.h b/GonkRecorder.h michael@0: index dba6110..fa948af 100644 michael@0: --- a/GonkRecorder.h michael@0: +++ b/GonkRecorder.h michael@0: @@ -14,11 +14,11 @@ michael@0: * limitations under the License. michael@0: */ michael@0: michael@0: -#ifndef STAGEFRIGHT_RECORDER_H_ michael@0: +#ifndef GONK_RECORDER_H_ michael@0: michael@0: -#define STAGEFRIGHT_RECORDER_H_ michael@0: +#define GONK_RECORDER_H_ michael@0: michael@0: -#include michael@0: +#include michael@0: #include michael@0: #include michael@0: michael@0: @@ -26,21 +26,16 @@ michael@0: michael@0: namespace android { michael@0: michael@0: -class Camera; michael@0: -class ICameraRecordingProxy; michael@0: -class CameraSource; michael@0: -class CameraSourceTimeLapse; michael@0: +class GonkCameraSource; michael@0: struct MediaSource; michael@0: struct MediaWriter; michael@0: class MetaData; michael@0: struct AudioSource; michael@0: class MediaProfiles; michael@0: -class ISurfaceTexture; michael@0: -class SurfaceMediaSource; michael@0: michael@0: -struct StagefrightRecorder : public MediaRecorderBase { michael@0: - StagefrightRecorder(); michael@0: - virtual ~StagefrightRecorder(); michael@0: +struct GonkRecorder { michael@0: + GonkRecorder(); michael@0: + virtual ~GonkRecorder(); michael@0: michael@0: virtual status_t init(); michael@0: virtual status_t setAudioSource(audio_source_t as); michael@0: @@ -50,11 +45,10 @@ michael@0: virtual status_t setVideoEncoder(video_encoder ve); michael@0: virtual status_t setVideoSize(int width, int height); michael@0: virtual status_t setVideoFrameRate(int frames_per_second); michael@0: - virtual status_t setCamera(const sp& camera, const sp& proxy); michael@0: - virtual status_t setPreviewSurface(const sp& surface); michael@0: virtual status_t setOutputFile(const char *path); michael@0: virtual status_t setOutputFile(int fd, int64_t offset, int64_t length); michael@0: virtual status_t setParameters(const String8& params); michael@0: + virtual status_t setCameraHandle(int32_t handle); michael@0: virtual status_t setListener(const sp& listener); michael@0: virtual status_t prepare(); michael@0: virtual status_t start(); michael@0: @@ -65,12 +59,8 @@ michael@0: virtual status_t getMaxAmplitude(int *max); michael@0: virtual status_t dump(int fd, const Vector& args) const; michael@0: // Querying a SurfaceMediaSourcer michael@0: - virtual sp querySurfaceMediaSource() const; michael@0: michael@0: private: michael@0: - sp mCamera; michael@0: - sp mCameraProxy; michael@0: - sp mPreviewSurface; michael@0: sp mListener; michael@0: sp mWriter; michael@0: int mOutputFd; michael@0: @@ -104,11 +94,6 @@ michael@0: int32_t mLongitudex10000; michael@0: int32_t mStartTimeOffsetMs; michael@0: michael@0: - bool mCaptureTimeLapse; michael@0: - int64_t mTimeBetweenTimeLapseFrameCaptureUs; michael@0: - sp mCameraSourceTimeLapse; michael@0: - michael@0: - michael@0: String8 mParams; michael@0: michael@0: bool mIsMetaDataStoredInVideoBuffers; michael@0: @@ -119,8 +104,8 @@ michael@0: // An pointer michael@0: // will be sent to the client side using which the michael@0: // frame buffers will be queued and dequeued michael@0: - sp mSurfaceMediaSource; michael@0: bool mDisableAudio; michael@0: + int32_t mCameraHandle; michael@0: michael@0: status_t setupMPEG4Recording( michael@0: int outputFd, michael@0: @@ -132,10 +117,7 @@ michael@0: sp *meta); michael@0: status_t startMPEG4Recording(); michael@0: status_t startAMRRecording(); michael@0: - status_t startFMA2DPWriter(); michael@0: - status_t startAACRecording(); michael@0: status_t startRawAudioRecording(); michael@0: - status_t startRTPRecording(); michael@0: status_t startMPEG2TSRecording(); michael@0: sp createAudioSource(); michael@0: status_t checkVideoEncoderCapabilities(); michael@0: @@ -144,9 +126,8 @@ michael@0: // source (CameraSource or SurfaceMediaSource) michael@0: // depending on the videosource type michael@0: status_t setupMediaSource(sp *mediaSource); michael@0: - status_t setupCameraSource(sp *cameraSource); michael@0: + status_t setupCameraSource(sp *cameraSource); michael@0: // setup the surfacemediasource for the encoder michael@0: - status_t setupSurfaceMediaSource(); michael@0: michael@0: status_t setupAudioEncoder(const sp& writer); michael@0: status_t setupVideoEncoder( michael@0: @@ -160,8 +141,6 @@ michael@0: status_t setParamAudioNumberOfChannels(int32_t channles); michael@0: status_t setParamAudioSamplingRate(int32_t sampleRate); michael@0: status_t setParamAudioTimeScale(int32_t timeScale); michael@0: - status_t setParamTimeLapseEnable(int32_t timeLapseEnable); michael@0: - status_t setParamTimeBetweenTimeLapseFrameCapture(int64_t timeUs); michael@0: status_t setParamVideoEncodingBitRate(int32_t bitRate); michael@0: status_t setParamVideoIFramesInterval(int32_t seconds); michael@0: status_t setParamVideoEncoderProfile(int32_t profile); michael@0: @@ -186,14 +165,10 @@ michael@0: void clipNumberOfAudioChannels(); michael@0: void setDefaultProfileIfNecessary(); michael@0: michael@0: - michael@0: - StagefrightRecorder(const StagefrightRecorder &); michael@0: - StagefrightRecorder &operator=(const StagefrightRecorder &); michael@0: - michael@0: - /* extension */ michael@0: - status_t startExtendedRecording(); michael@0: + GonkRecorder(const GonkRecorder &); michael@0: + GonkRecorder &operator=(const GonkRecorder &); michael@0: }; michael@0: michael@0: } // namespace android michael@0: michael@0: -#endif // STAGEFRIGHT_RECORDER_H_ michael@0: +#endif // GONK_RECORDER_H_