コード例 #1
0
void ScreenCapture::startVideo()
{
	if (!_recordingActive && _configured) {
		// video recording!
		_err = camera_set_video_property(_handle,
				CAMERA_IMGPROP_FRAMERATE, _frameRate);


        _err = camera_roll_open_video(_handle, &_fd, _filename, CAMERA_ROLL_NAMELEN, CAMERA_ROLL_VIDEO_FMT_MP4);
        if (_err == EOK) {
            qDebug() << "Created video file " << _filename << "!\n";
        } else {
            qDebug() << "Error creating video file: " << strerror(_err) << "\n";
        }
        _videoroll = true;

		_frameCount = 0;
		_err = camera_start_video(_handle,
								 _filename,
								 NULL,
								 //&video_callback,
								 &video_status_callback,
								 (void*)this);
		if (_err != EOK) {
			qDebug() << "Error starting video recording: " << _err << " : " << strerror(_err) << "\n";
		} else {
			qDebug() << "recording video on file " << _filename << "!\n";

			_recordingActive = true;
		}
	}
}
コード例 #2
0
    void ActionRecordVideo::executeCameraAction(ExecutionState* state, std::string action,
            std::string cameraUnitString, std::string appendTime, std::string outFile)
    {
        DataModelLogger* RUNLOG = state->getLogger();

        camera_unit_t cameraUnit;
        if (cameraUnitString == "BACK") {
            cameraUnit = CAMERA_UNIT_REAR;
        } else if (cameraUnitString == "FRONT") {
            cameraUnit = CAMERA_UNIT_FRONT;
        } else if (cameraUnitString == "DESKTOP_PRIMARY") {
            cameraUnit = CAMERA_UNIT_DESKTOP;
        } else if (cameraUnitString == "DESKTOP_SECONDARY") {
            cameraUnit = CAMERA_UNIT_SECONDARY_DESKTOP;
        } else {
            LOG->warning(SSTR("Unknown source selected: " << cameraUnitString));
            RUNLOG->error("Unknown source selected");
            return;
        }

        if (action == "START") {
            if (!state->getRuntimeResources()->isCameraOk(
                    state->getRuntimeResources()->setupCamera(cameraUnit, CAMERA_MODE_RW))) {
                LOG->error("Failed to get camera");
                RUNLOG->error("Failed to get camera");
                return;
            }
            camera_handle_t camera = state->getRuntimeResources()->getCamera();
            if (!state->getRuntimeResources()->isCameraOk(
                    _camera_set_videovf_property(camera, CAMERA_IMGPROP_END))) {
                LOG->error("Failed to set video frame properties");
                RUNLOG->error("Failed to set video frame properties");
                return;
            }
            if (!state->getRuntimeResources()->isCameraOk(
                    _camera_set_video_property(camera, CAMERA_IMGPROP_END))) {
                LOG->error("Failed to set video properties");
                RUNLOG->error("Failed to set video properties");
                return;
            }
            state->getRuntimeResources()->callbackReset();
            if (!state->getRuntimeResources()->isCameraOk(
                    camera_start_video_viewfinder(camera, NULL, viewFinderStatusCallback,
                            (void*) state->getRuntimeResources()))) {
                LOG->error("Failed to start video viewfinder");
                RUNLOG->error("Failed to start video viewfinder");
                return;
            }
            if (!state->getRuntimeResources()->callbackWait(5000)) {
                LOG->warning("Timed out waiting for view finder to start");
            }
            std::string filename;
            if (Statement::isValueTrue(appendTime)) {
                filename = state->getRuntimeResources()->uniqueFilename(outFile);
            } else {
                filename = outFile;
            }
            state->setUserProperty("VIDEO_FILENAME", filename);
            state->getRuntimeResources()->callbackReset();
            if (!state->getRuntimeResources()->isCameraOk(
                    camera_start_video(camera, filename.c_str(), NULL, videoRecordingStatusCallback,
                            (void*) state->getRuntimeResources()))) {
                LOG->error("Failed to start video recording");
                RUNLOG->error("Failed to start video recording");
                return;
            }
            if (!state->getRuntimeResources()->callbackWait(5000)) {
                LOG->warning("Timed out waiting for recording to start");
            }
            RUNLOG->debug("Started video recording");
        } else if (action == "STOP") {
            camera_handle_t camera = state->getRuntimeResources()->getCamera();
            if (!state->getRuntimeResources()->isCameraOk(camera_stop_video(camera))) {
                LOG->error("Failed to stop video recording");
                RUNLOG->error("Failed to stop video recording");
                return;
            }
            if (!state->getRuntimeResources()->isCameraOk(camera_stop_video_viewfinder(camera))) {
                LOG->error("Failed to stop video viewfinder");
                RUNLOG->error("Failed to stop video viewfinder");
                return;
            }
            state->getRuntimeResources()->destroyCamera();
            RUNLOG->debug("Stopped video recording");
        } else {
            RUNLOG->error("Unknown action: " + action);
        }
    }