Portrait mode.
This commit is contained in:
parent
95070d1345
commit
3c000dca8c
8 changed files with 53 additions and 21 deletions
|
@ -1,7 +1,7 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="menu_videocall_back_to_dialer_title">Display dialer</string>
|
||||
<string name="menu_videocall_change_resolution_when_low_resolution">High resolution</string>
|
||||
<string name="menu_videocall_change_resolution_when_low_resolution">Try High resolution</string>
|
||||
<string name="menu_videocall_change_resolution_when_high_resolution">Low resolution</string>
|
||||
<string name="menu_videocall_change_resolution_title">Change resolution</string>
|
||||
<string name="menu_videocall_toggle_camera_title">Mute/Unmute camera</string>
|
||||
|
|
|
@ -114,8 +114,12 @@ public class BandwidthManager {
|
|||
}
|
||||
|
||||
private VideoSize closestVideoSize(VideoSize vSize) {
|
||||
boolean invert = vSize.getHeight() > vSize.getWidth();
|
||||
int testHeight = invert?vSize.getWidth():vSize.getHeight();
|
||||
int testWidth = invert?vSize.getHeight():vSize.getWidth();
|
||||
|
||||
for (Size s : AndroidCameraRecordManager.getInstance().supportedVideoSizes()) {
|
||||
if (s.height == vSize.getHeight() && s.width == vSize.getWidth()) {
|
||||
if (s.height == testHeight && s.width == testWidth) {
|
||||
return vSize;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -457,15 +457,9 @@ public class DialerActivity extends Activity implements LinphoneCoreListener {
|
|||
} else if (state == LinphoneCall.State.CallEnd) {
|
||||
exitCallMode();
|
||||
} else if (state == LinphoneCall.State.StreamsRunning) {
|
||||
if (LinphoneService.instance().getLinphoneCore().getCurrentCall().getCurrentParamsReadOnly().getVideoEnabled()) {
|
||||
if (!VideoCallActivity.launched && LinphoneService.instance().getLinphoneCore().getCurrentCall().getCurrentParamsReadOnly().getVideoEnabled()) {
|
||||
startVideoView(VIDEO_VIEW_ACTIVITY);
|
||||
}
|
||||
} else if (state == LinphoneCall.State.CallUpdated) {
|
||||
if (LinphoneService.instance().getLinphoneCore().getCurrentCall().getCurrentParamsReadOnly().getVideoEnabled()) {
|
||||
// getVideoManager().invalidateParameters(); // no, when addinv video to audio call the filters are created before callupdated event is received
|
||||
// so the parameters are invalidated and the record is never launched
|
||||
finishActivity(VIDEO_VIEW_ACTIVITY);
|
||||
}
|
||||
}
|
||||
mCurrentCallState = state;
|
||||
}
|
||||
|
|
|
@ -36,8 +36,12 @@ public class VideoCallActivity extends Activity {
|
|||
SurfaceView mVideoView;
|
||||
SurfaceView mVideoCaptureView;
|
||||
AndroidCameraRecordManager recordManager;
|
||||
private static final String tag = "Linphone";
|
||||
public static boolean launched = false;
|
||||
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
Log.d(tag, "onCreate VideoCallActivity");
|
||||
launched = true;
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.videocall);
|
||||
|
||||
|
@ -63,9 +67,9 @@ public class VideoCallActivity extends Activity {
|
|||
|
||||
private void rewriteChangeResolutionItem(MenuItem item) {
|
||||
if (BandwidthManager.getInstance().isUserRestriction()) {
|
||||
item.setTitle(getString(R.string.menu_videocall_change_resolution_when_high_resolution));
|
||||
} else {
|
||||
item.setTitle(getString(R.string.menu_videocall_change_resolution_when_low_resolution));
|
||||
} else {
|
||||
item.setTitle(getString(R.string.menu_videocall_change_resolution_when_high_resolution));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -103,6 +107,10 @@ public class VideoCallActivity extends Activity {
|
|||
break;
|
||||
case R.id.videocall_menu_toggle_camera:
|
||||
recordManager.toggleMute();
|
||||
LinphoneCore lc = LinphoneService.instance().getLinphoneCore();
|
||||
if (lc.isIncall()) {
|
||||
lc.getCurrentCall().enableCamera(!recordManager.isMuted());
|
||||
}
|
||||
rewriteToggleCameraItem(item);
|
||||
break;
|
||||
default:
|
||||
|
@ -121,9 +129,16 @@ public class VideoCallActivity extends Activity {
|
|||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
// TODO Auto-generated method stub
|
||||
Log.d(tag, "onDestroy VideoCallActivity");
|
||||
launched = false;
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
Log.d(tag, "onPause VideoCallActivity");
|
||||
super.onPause();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -77,7 +77,11 @@ public abstract class AndroidCameraRecord {
|
|||
}
|
||||
|
||||
parameters.set("camera-id", params.cameraId);
|
||||
if (!params.videoDimensionsInverted) {
|
||||
parameters.setPreviewSize(params.width, params.height);
|
||||
} else {
|
||||
parameters.setPreviewSize(params.height, params.width);
|
||||
}
|
||||
parameters.setPreviewFrameRate(Math.round(params.fps));
|
||||
if (parameters.getSupportedFocusModes().contains(Camera.Parameters.FOCUS_MODE_AUTO)) {
|
||||
Log.w(tag, "Auto Focus supported by camera device");
|
||||
|
@ -182,6 +186,7 @@ public abstract class AndroidCameraRecord {
|
|||
int cameraId;
|
||||
int rotation;
|
||||
public SurfaceView surfaceView;
|
||||
boolean videoDimensionsInverted;
|
||||
|
||||
public RecorderParams(long ptr) {
|
||||
filterDataNativePtr = ptr;
|
||||
|
|
|
@ -35,17 +35,19 @@ public class AndroidCameraRecordImpl extends AndroidCameraRecord implements Prev
|
|||
private double timeElapsedBetweenFrames = 0;
|
||||
private long lastFrameTime = 0;
|
||||
private final double expectedTimeBetweenFrames;
|
||||
private boolean videoDimensionsInverted;
|
||||
|
||||
public AndroidCameraRecordImpl(RecorderParams parameters) {
|
||||
super(parameters);
|
||||
expectedTimeBetweenFrames = 1d / Math.round(parameters.fps);
|
||||
filterCtxPtr = parameters.filterDataNativePtr;
|
||||
videoDimensionsInverted = parameters.videoDimensionsInverted;
|
||||
|
||||
storePreviewCallBack(this);
|
||||
}
|
||||
|
||||
|
||||
private native void putImage(long filterCtxPtr, byte[] buffer, int orientation);
|
||||
private native void putImage(long filterCtxPtr, byte[] buffer, int orientation, boolean videoDimensionsInverted);
|
||||
|
||||
|
||||
public void onPreviewFrame(byte[] data, Camera camera) {
|
||||
|
@ -69,7 +71,7 @@ public class AndroidCameraRecordImpl extends AndroidCameraRecord implements Prev
|
|||
long curTime = System.currentTimeMillis();
|
||||
if (lastFrameTime == 0) {
|
||||
lastFrameTime = curTime;
|
||||
putImage(filterCtxPtr, data, getOrientationCode());
|
||||
putImage(filterCtxPtr, data, getOrientationCode(), videoDimensionsInverted);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -82,7 +84,7 @@ public class AndroidCameraRecordImpl extends AndroidCameraRecord implements Prev
|
|||
timeElapsedBetweenFrames = currentTimeElapsed;
|
||||
|
||||
// Log.d("onPreviewFrame: ", Integer.toString(data.length));
|
||||
putImage(filterCtxPtr, data, getOrientationCode());
|
||||
putImage(filterCtxPtr, data, getOrientationCode(), videoDimensionsInverted);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -83,14 +83,17 @@ public class AndroidCameraRecordManager {
|
|||
|
||||
private List<Size> supportedVideoSizes;
|
||||
private int rotation;
|
||||
private static final String tag = "Linphone";
|
||||
|
||||
|
||||
public void setParametersFromFilter(long filterDataPtr, int height, int width, float fps) {
|
||||
stopVideoRecording();
|
||||
RecorderParams p = new RecorderParams(filterDataPtr);
|
||||
p.fps = fps;
|
||||
p.width = width;
|
||||
p.height = height;
|
||||
p.cameraId = cameraId;
|
||||
p.videoDimensionsInverted = width < height;
|
||||
parameters = p;
|
||||
}
|
||||
|
||||
|
@ -103,16 +106,20 @@ public class AndroidCameraRecordManager {
|
|||
holder.addCallback(new Callback() {
|
||||
public void surfaceDestroyed(SurfaceHolder holder) {
|
||||
surfaceView = null;
|
||||
Log.d(tag , "Video capture surface destroyed");
|
||||
stopVideoRecording();
|
||||
}
|
||||
|
||||
public void surfaceCreated(SurfaceHolder holder) {
|
||||
surfaceView = sv;
|
||||
Log.d(tag , "Video capture surface created");
|
||||
tryToStartVideoRecording();
|
||||
}
|
||||
|
||||
public void surfaceChanged(SurfaceHolder holder, int format, int width,
|
||||
int height) {}
|
||||
int height) {
|
||||
Log.d(tag , "Video capture surface changed");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -30,6 +30,7 @@ class LinphoneCallImpl implements LinphoneCall {
|
|||
native private long getRemoteAddress(long nativePtr);
|
||||
native private int getState(long nativePtr);
|
||||
private native long getCurrentParams(long nativePtr);
|
||||
private native void enableCamera(long nativePtr, boolean enabled);
|
||||
|
||||
protected LinphoneCallImpl(long aNativePtr) {
|
||||
nativePtr = aNativePtr;
|
||||
|
@ -66,4 +67,8 @@ class LinphoneCallImpl implements LinphoneCall {
|
|||
public LinphoneCallParams getCurrentParamsReadWrite() {
|
||||
return getCurrentParamsReadOnly().copy();
|
||||
}
|
||||
|
||||
public void enableCamera(boolean enabled) {
|
||||
enableCamera(nativePtr, enabled);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue