diff --git a/app/src/main/java/com/huawei/cloudapp/ui/CasCloudPhoneActivity.java b/app/src/main/java/com/huawei/cloudapp/ui/CasCloudPhoneActivity.java index 5489d4e2154a029d060ac5aaf54d05213b8e293b..39c931cd72c8ac98a7e8bdb2f124613689810b80 100644 --- a/app/src/main/java/com/huawei/cloudapp/ui/CasCloudPhoneActivity.java +++ b/app/src/main/java/com/huawei/cloudapp/ui/CasCloudPhoneActivity.java @@ -185,6 +185,10 @@ public class CasCloudPhoneActivity extends FragmentActivity implements View.OnCl private volatile boolean mIsStartTaskRunning = false; private ICloudPhone mCloudPhone; + private boolean isLandscapeScreen = false; + private int screenWidth; + private int screenHeight; + RadioGroup.OnCheckedChangeListener qualityCheckedChangeListener = new RadioGroup.OnCheckedChangeListener() { public void onCheckedChanged(RadioGroup group, int checkedId) { if (group.getCheckedRadioButtonId() != checkedId) { @@ -302,7 +306,6 @@ public class CasCloudPhoneActivity extends FragmentActivity implements View.OnCl textCtrl.setOnClickListener(CasCloudPhoneActivity.this); textCtrl.setBackgroundResource(R.drawable.button_sub_action_selector); - setRotation(mOrientation); lagSwitch.setChecked(false); ctrlSwitch.setChecked(true); gAcitivity = this; @@ -333,8 +336,16 @@ public class CasCloudPhoneActivity extends FragmentActivity implements View.OnCl mMediaConfig.put(QUALITY, DEFINITION_MAIN); DisplayMetrics metrics = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getRealMetrics(metrics); - mMediaConfig.put(PHYSICAL_WIDTH, String.valueOf(metrics.widthPixels)); - mMediaConfig.put(PHYSICAL_HEIGHT, String.valueOf(metrics.heightPixels)); + screenWidth = metrics.widthPixels; + screenHeight = metrics.heightPixels; + + if (screenWidth > screenHeight) { + isLandscapeScreen = true; + mOrientation = 8; + } + setRotation(mOrientation); + mMediaConfig.put(PHYSICAL_WIDTH, String.valueOf(isLandscapeScreen ? screenHeight : screenWidth)); + mMediaConfig.put(PHYSICAL_HEIGHT, String.valueOf(isLandscapeScreen ? screenWidth : screenHeight)); mCloudPhone.setMediaConfig(mMediaConfig); @@ -625,27 +636,54 @@ public class CasCloudPhoneActivity extends FragmentActivity implements View.OnCl return; } if (currentRotation != rotation) { + int landscapeWidth = 0, landscapeHeight = 0; switch (rotation) { case 0: setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); + if (isLandscapeScreen) { + landscapeHeight = screenHeight; + landscapeWidth = screenHeight * 9 / 16; + } break; case 1: case 8: setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE); + if (isLandscapeScreen) { + landscapeHeight = screenHeight; + landscapeWidth = screenWidth; + } break; case 2: case 16: setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT); + if (isLandscapeScreen) { + landscapeHeight = screenHeight; + landscapeWidth = screenHeight * 9 / 16; + } break; case 3: case 24: setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE); + if (isLandscapeScreen) { + landscapeHeight = screenHeight; + landscapeWidth = screenWidth; + } break; default: setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); + if (isLandscapeScreen) { + landscapeHeight = screenHeight; + landscapeWidth = screenHeight * 9 / 16; + } break; } currentRotation = rotation; + + if (isLandscapeScreen) { + FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(landscapeWidth, landscapeHeight); + layoutParams.gravity = Gravity.CENTER; + mFrameLayout.setLayoutParams(layoutParams); + } } } diff --git a/cloudphone/src/main/cpp/cas_decoder/CasDecoder.cpp b/cloudphone/src/main/cpp/cas_decoder/CasDecoder.cpp index 2259a62831e3362f18b5b8e229547db22dcc3229..870c69bfe405b6db3ab9e7b2c564f88c169075ad 100644 --- a/cloudphone/src/main/cpp/cas_decoder/CasDecoder.cpp +++ b/cloudphone/src/main/cpp/cas_decoder/CasDecoder.cpp @@ -26,8 +26,8 @@ namespace { enum MediaCodecResolution { - KEY_WIDTH = 720, - KEY_HEIGHT = 1280 + KEY_WIDTH = 1080, + KEY_HEIGHT = 1920 }; const char *MIME_TYPE_H264 = "video/avc"; const char *MIME_TYPE_H265 = "video/hevc"; diff --git a/cloudphone/src/main/java/com/huawei/cloudphone/apiimpl/CloudPhoneImpl.java b/cloudphone/src/main/java/com/huawei/cloudphone/apiimpl/CloudPhoneImpl.java index be01a76852472a90d677f3fbafe7718e99d406a9..c6cb0b517dbdbe20639190fb32133cabe46ec6cd 100644 --- a/cloudphone/src/main/java/com/huawei/cloudphone/apiimpl/CloudPhoneImpl.java +++ b/cloudphone/src/main/java/com/huawei/cloudphone/apiimpl/CloudPhoneImpl.java @@ -381,7 +381,7 @@ public class CloudPhoneImpl implements ICloudPhone { public void surfaceDestroyed(SurfaceHolder holder) { synchronized (mCloudPhoneLock) { CASLog.i(TAG, "surfaceDestroyed..."); - if (mCASClient.getState() != JNIState.JNI_STOPPED) { + if (mCASClient != null && mCASClient.getState() != JNIState.JNI_STOPPED) { mCASClient.stop(true); } if (mCmdHandler != null) { @@ -665,6 +665,8 @@ public class CloudPhoneImpl implements ICloudPhone { CASLog.e(TAG, "get orientation failed. " + e.getMessage()); return true; } + } else { + return false; } switch (orientation) {