Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Trusted Contributor
JohnWS
Posts: 117
Registered: ‎02-08-2013
My Device: 9900

Open viewfinder sometimes returns error

I am opening viewfinder to record frames from the desktop. 

 

Probably about 50% of the time I am getting error opening the viewfinder - the error is 4100.

 

What could cause this problem?

 

I am closing the camera properly I think using

 

camera_stop_video_viewfinder(BTworker->mCameraHandle);
camera_close(BTworker->mCameraHandle);
BTworker->mCameraHandle = CAMERA_HANDLE_INVALID;

 and I opening the viewfinder using

 

 

int BluetoothWorker::createViewfinder(camera_unit_t cameraUnit,
		const QString &group,
		const QString &id)
{
	qDebug() << "createViewfinder";
	clock_gettime( CLOCK_MONOTONIC, &last_ts );
	if (mCameraHandle != CAMERA_HANDLE_INVALID) {
		qDebug() << "camera already running";
		return EBUSY;
	}
	mCameraUnit = cameraUnit;
	if (camera_open(mCameraUnit,
			CAMERA_MODE_RW | CAMERA_MODE_ROLL,
			&mCameraHandle) != CAMERA_EOK) {
		qDebug() << "could not open camera";
		return EIO;
	}
	qDebug() << "camera opened";
	unsigned int num = 0;
	camera_get_video_vf_resolutions(mCameraHandle, 0, &num, NULL);
	if (!num) {

	} else {
		camera_res_t res[num];
		camera_get_video_vf_resolutions(mCameraHandle, num, &num, res);
		int smallest = 0;
		for (unsigned int i=1; i<num; i++) {
			if (res[i].width * res[i].height < res[smallest].width * res[smallest].height) {
				smallest = i;
			}
		}
		mWidth = res[smallest].width;
		mHeight = res[smallest].height;
		int err = camera_set_videovf_property(mCameraHandle,
				CAMERA_IMGPROP_WIN_GROUPID, group.data(),
				CAMERA_IMGPROP_WIN_ID, id.data(),
				CAMERA_IMGPROP_WIDTH, mWidth,
				CAMERA_IMGPROP_HEIGHT, mHeight);
		if (err) {
		qDebug() << "failed to configure videovf: " << err;
		} else {
			err = camera_set_video_property(mCameraHandle,
					CAMERA_IMGPROP_WIDTH, mWidth,
					CAMERA_IMGPROP_HEIGHT, mHeight);
		}

		qDebug() << "viewfinder configured";

		err = camera_start_video_viewfinder(mCameraHandle, &EncVideoCallBack, NULL, this);
		if (err  == CAMERA_EOK) {
			qDebug() << "viewfinder started";
			return EOK;
		}

		qDebug() << "couldn't start viewfinder" << err;
		camera_close(mCameraHandle);
		mCameraHandle = CAMERA_HANDLE_INVALID;
		return EIO;
	}
}

 

How can I overcome this problem?

 

Trusted Contributor
JohnWS
Posts: 117
Registered: ‎02-08-2013
My Device: 9900

Re: Open viewfinder sometimes returns error

I think I have found the cause for this issue - It occurs when the backlight isn't on and I try to start viewfinder.

 

Any idea what I can do to enable the backlight or is this impossible to do without user interaction?