Skip to content

Commit

Permalink
Camera2: Fix for unsupported resolutions by codec.
Browse files Browse the repository at this point in the history
Currently, logic for unsupported resolution for a codec is
hardcoded and is limited to only H263 and 1280x720 resolution.
Ideally, we should read capabilities of each codec from
mediaprofiles.xml and check it against selected profile.
Toast message is posted if any unsupported resolution is
selected.

Also skip setparameter call to HAL during recording,
when orientation gets changed.

Change-Id: Ife7dde725882d8217fadff7b56687cdad2c72ae4
  • Loading branch information
Sai Kumar Sanagavarapu authored and hyperb1iss committed Jan 2, 2014
1 parent d8f3ede commit d1fc90e
Showing 1 changed file with 25 additions and 8 deletions.
33 changes: 25 additions & 8 deletions src/com/android/camera/VideoModule.java
Expand Up @@ -54,6 +54,8 @@
import android.view.View;
import android.view.WindowManager;
import android.widget.Toast;
import android.media.EncoderCapabilities;
import android.media.EncoderCapabilities.VideoEncoderCap;

import com.android.camera.CameraManager.CameraAFCallback;
import com.android.camera.CameraManager.CameraPictureCallback;
Expand Down Expand Up @@ -582,10 +584,9 @@ public void onOrientationChanged(int orientation) {
if (mOrientation != newOrientation) {
mOrientation = newOrientation;
Log.v(TAG, "onOrientationChanged, update parameters");
if ((mParameters != null) && (true == mPreviewing)){
if ((mParameters != null) && (true == mPreviewing) && !mMediaRecorderRecording){
setCameraParameters();
}

}

// Show the toast after getting the first orientation changed.
Expand Down Expand Up @@ -1241,12 +1242,28 @@ private void initializeRecorder() {
videoHeight = mProfile.videoFrameHeight;
mUnsupportedResolution = false;

if (mVideoEncoder == MediaRecorder.VideoEncoder.H263) {
if (videoWidth >= 1280 && videoHeight >= 720) {
mUnsupportedResolution = true;
Toast.makeText(mActivity, R.string.error_app_unsupported,
Toast.LENGTH_LONG).show();
return;
//check if codec supports the resolution, otherwise throw toast
List<VideoEncoderCap> videoEncoders = EncoderCapabilities.getVideoEncoders();
for (VideoEncoderCap videoEncoder: videoEncoders) {
if (videoEncoder.mCodec == mVideoEncoder){
if (videoWidth > videoEncoder.mMaxFrameWidth ||
videoWidth < videoEncoder.mMinFrameWidth ||
videoHeight > videoEncoder.mMaxFrameHeight ||
videoHeight < videoEncoder.mMinFrameHeight){
Log.e(TAG,"Selected codec "+mVideoEncoder+
" does not support "+ videoWidth + "x" + videoHeight
+" resolution");
Log.e(TAG, "Codec capabilities: " +
"mMinFrameWidth = " + videoEncoder.mMinFrameWidth + " , "+
"mMinFrameHeight = " + videoEncoder.mMinFrameHeight + " , "+
"mMaxFrameWidth = " + videoEncoder.mMaxFrameWidth + " , "+
"mMaxFrameHeight = " + videoEncoder.mMaxFrameHeight);
mUnsupportedResolution = true;
Toast.makeText(mActivity, R.string.error_app_unsupported,
Toast.LENGTH_LONG).show();
return;
}
break;
}
}

Expand Down

0 comments on commit d1fc90e

Please sign in to comment.