status_t CameraService::Client::startRecordingMode() { LOG1("startRecordingMode"); status_t result = NO_ERROR; // if recording has been enabled, nothing needs to be done if (mHardware->recordingEnabled()) { return NO_ERROR; } // if preview has not been started, start preview first if (!mHardware->previewEnabled()) { result = startPreviewMode(); if (result != NO_ERROR) { return result; } } // start recording mode enableMsgType(CAMERA_MSG_VIDEO_FRAME); mCameraService->playSound(SOUND_RECORDING); result = mHardware->startRecording(); if (result != NO_ERROR) { LOGE("mHardware->startRecording() failed with status %d", result); } return result; }
// start preview or recording status_t CameraClient::startCameraMode(camera_mode mode) { LOG1("startCameraMode(%d)", mode); status_t result = checkPidAndHardware(); if (result != NO_ERROR) return result; switch(mode) { case CAMERA_PREVIEW_MODE: if (mSurface == 0 && mPreviewWindow == 0) { LOG1("mSurface is not set yet."); // still able to start preview in this case. } return startPreviewMode(); case CAMERA_RECORDING_MODE: if (mSurface == 0 && mPreviewWindow == 0) { ALOGE("mSurface or mPreviewWindow must be set before startRecordingMode."); return INVALID_OPERATION; } return startRecordingMode(); default: return UNKNOWN_ERROR; } }