Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit dcc05ca9 authored by James Dong's avatar James Dong Committed by Android Git Automerger
Browse files

am b30bf6ef: Merge "Use timestamp from camera driver for CameraSource" into kraken

parents 0ab6dd0e b30bf6ef
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@
** limitations under the License.
*/

//#define LOG_NDEBUG 0
#define LOG_TAG "CameraService"
#include <utils/Log.h>

@@ -247,7 +248,7 @@ CameraService::Client::Client(const sp<CameraService>& cameraService,
status_t CameraService::Client::checkPid()
{
    int callingPid = getCallingPid();
    if (mClientPid == callingPid) return NO_ERROR;
    if (mClientPid == callingPid || callingPid == getpid()) return NO_ERROR;
    LOGW("Attempt to use locked camera (client %p) from different process "
        " (old pid %d, new pid %d)",
        getCameraClient()->asBinder().get(), mClientPid, callingPid);
+7 −2
Original line number Diff line number Diff line
@@ -34,7 +34,7 @@ class Camera;
class CameraSource : public MediaSource {
public:
    static CameraSource *Create();
    static CameraSource *CreateFromICamera(const sp<ICamera> &icamera);
    static CameraSource *CreateFromCamera(const sp<Camera> &camera);

    virtual ~CameraSource();

@@ -61,12 +61,17 @@ private:

    int mWidth, mHeight;
    int64_t mFirstFrameTimeUs;
    int64_t mLastFrameTimestampUs;
    int32_t mNumFrames;
    int32_t mNumFramesReleased;
    bool mStarted;

    CameraSource(const sp<Camera> &camera);

    void dataCallback(int32_t msgType, const sp<IMemory> &data);
    void dataCallbackTimestamp(
            int64_t timestampUs, int32_t msgType, const sp<IMemory> &data);

    void releaseQueuedFrames();

    CameraSource(const CameraSource &);
    CameraSource &operator=(const CameraSource &);
+1 −0
Original line number Diff line number Diff line
@@ -37,6 +37,7 @@ LOCAL_SHARED_LIBRARIES := \
	libvorbisidec         			\
	libsonivox            			\
	libmedia              			\
	libcamera_client      			\
	libandroid_runtime    			\
	libstagefright        			\
	libstagefright_omx    			\
+36 −2
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@

#include "StagefrightRecorder.h"

#include <binder/IPCThreadState.h>
#include <media/stagefright/AudioSource.h>
#include <media/stagefright/AMRWriter.h>
#include <media/stagefright/CameraSource.h>
@@ -30,8 +31,11 @@
#include <media/stagefright/OMXClient.h>
#include <media/stagefright/OMXCodec.h>
#include <camera/ICamera.h>
#include <camera/Camera.h>
#include <surfaceflinger/ISurface.h>
#include <utils/Errors.h>
#include <sys/types.h>
#include <unistd.h>

namespace android {

@@ -96,7 +100,25 @@ status_t StagefrightRecorder::setVideoFrameRate(int frames_per_second) {
}

status_t StagefrightRecorder::setCamera(const sp<ICamera> &camera) {
    mCamera = camera;
    LOGV("setCamera: pid %d pid %d", IPCThreadState::self()->getCallingPid(), getpid());
    if (camera == 0) {
        LOGE("camera is NULL");
        return UNKNOWN_ERROR;
    }

    mFlags &= ~ FLAGS_SET_CAMERA | FLAGS_HOT_CAMERA;
    mCamera = Camera::create(camera);
    if (mCamera == 0) {
        LOGE("Unable to connect to camera");
        return UNKNOWN_ERROR;
    }

    LOGV("Connected to camera");
    mFlags |= FLAGS_SET_CAMERA;
    if (mCamera->previewEnabled()) {
        LOGV("camera is hot");
        mFlags |= FLAGS_HOT_CAMERA;
    }

    return OK;
}
@@ -240,7 +262,7 @@ status_t StagefrightRecorder::startMPEG4Recording() {
        CHECK(mCamera != NULL);

        sp<CameraSource> cameraSource =
            CameraSource::CreateFromICamera(mCamera);
            CameraSource::CreateFromCamera(mCamera);

        CHECK(cameraSource != NULL);

@@ -314,6 +336,17 @@ status_t StagefrightRecorder::stop() {
status_t StagefrightRecorder::close() {
    stop();

    if (mCamera != 0) {
        if ((mFlags & FLAGS_HOT_CAMERA) == 0) {
            LOGV("Camera was cold when we started, stopping preview");
            mCamera->stopPreview();
        }
        if (mFlags & FLAGS_SET_CAMERA) {
            LOGV("Unlocking camera");
            mCamera->unlock();
        }
        mFlags = 0;
    }
    return OK;
}

@@ -329,6 +362,7 @@ status_t StagefrightRecorder::reset() {
    mVideoHeight = -1;
    mFrameRate = -1;
    mOutputFd = -1;
    mFlags = 0;

    return OK;
}
+8 −1
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@

namespace android {

class Camera;
struct MediaSource;
struct MediaWriter;

@@ -52,7 +53,12 @@ struct StagefrightRecorder : public MediaRecorderBase {
    virtual status_t getMaxAmplitude(int *max);

private:
    sp<ICamera> mCamera;
    enum CameraFlags {
        FLAGS_SET_CAMERA = 1L << 0,
        FLAGS_HOT_CAMERA = 1L << 1,
    };

    sp<Camera> mCamera;
    sp<ISurface> mPreviewSurface;
    sp<IMediaPlayerClient> mListener;
    sp<MediaWriter> mWriter;
@@ -66,6 +72,7 @@ private:
    int mFrameRate;
    String8 mParams;
    int mOutputFd;
    int32_t mFlags;

    status_t startMPEG4Recording();
    status_t startAMRRecording();
Loading