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
Developer
Posts: 178
Registered: ‎04-16-2011
My Device: torch 9800
My Carrier: verizon
Accepted Solution

Another Camera problem!

Hi,

 

I have discovered a bug in my code which causes videos recorded in landscape to display incorrectly rotated (sideways) when played with native media player.

 

I have just been going through hellovideocamera and can't find any differences between my code and the sample.

 

What I have realised though is that mVideoAngle and mVfAngle are always both 0 (when creating viewfinder) initially after calling 

 

if (camera_get_video_property(mCameraHandle,
			CAMERA_IMGPROP_ROTATION, &mVideoAngle) == CAMERA_EOK) {
		cout << "\n initial video angle" << mVideoAngle;
	}
	if (camera_get_videovf_property(mCameraHandle,
			CAMERA_IMGPROP_ROTATION, &mVfAngle) == CAMERA_EOK) {
		cout << "\n initial video viewfinder angle" << mVfAngle;
	}

 

I did managed to get something other than 0 for the above code when replacing camera_get_video_property with camera_get_photo_property (I get 270) but then the video is upside down.

 

Please see the full createViewfinder code below.

 

int MuteCamera::createViewfinder(camera_unit_t cameraUnit,
		const QString &group,
		const QString &id)
{
	mVideoFileDescriptor = -1;
	cout << "\n createViewfinder";
	cout.flush();
	mCameraHandle = CAMERA_HANDLE_INVALID;;
	if (mCameraHandle != CAMERA_HANDLE_INVALID) {
		cout << "camera already running";
		cout.flush();
		return EBUSY;
	}
	mCameraUnit = cameraUnit;
	
	
	camera_error_t  rc = camera_open(mCameraUnit,
			CAMERA_MODE_RW | CAMERA_MODE_ROLL,
			&mCameraHandle);
	
	
	if (rc != CAMERA_EOK) {
		cout << "could not open camera " << rc << "\n";
		return EIO;
	}
	cout << "\n camera opened";
	cout.flush();

	mShouldMirror = (mCameraUnit == CAMERA_UNIT_FRONT);
	querySupportedRotationsVideo();
	
	if (camera_get_video_property(mCameraHandle,
			CAMERA_IMGPROP_ROTATION, &mVideoAngle) == CAMERA_EOK) {
		cout << "\n initial video angle" << mVideoAngle;
	}
	if (camera_get_videovf_property(mCameraHandle,
			CAMERA_IMGPROP_ROTATION, &mVfAngle) == CAMERA_EOK) {
		cout << "\n initial video viewfinder angle" << mVfAngle;
	}
	if (camera_set_videovf_property(mCameraHandle,
			CAMERA_IMGPROP_WIN_GROUPID, group.toStdString().c_str(),
			CAMERA_IMGPROP_WIN_ID, id.toStdString().c_str()) == CAMERA_EOK) {
		cout << "viewfinder configured";
		if (camera_start_video_viewfinder(mCameraHandle, NULL, &status_callback_video, this) == CAMERA_EOK) {

			cout << "viewfinder started \n";
			cout.flush();
			return EOK;
		}
	}
	cout << "couldn't start viewfinder";
	cout.flush();
	camera_close(mCameraHandle);
	mCameraHandle = CAMERA_HANDLE_INVALID;
	return EIO;
}

 

Really stumped with this - any help appreciated.

Developer
Posts: 178
Registered: ‎04-16-2011
My Device: torch 9800
My Carrier: verizon

Re: Another Camera problem!

It turned out I was initialising variables after creating camera page rather than before.

BlackBerry Development Advisor
Posts: 683
Registered: ‎11-29-2011
My Device: PRIV
My Carrier: Rogers

Re: Another Camera problem!

I think you are now the expert on rotation Smiley Happy