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"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<resources>
|
<resources>
|
||||||
<string name="menu_videocall_back_to_dialer_title">Display dialer</string>
|
<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_when_high_resolution">Low resolution</string>
|
||||||
<string name="menu_videocall_change_resolution_title">Change resolution</string>
|
<string name="menu_videocall_change_resolution_title">Change resolution</string>
|
||||||
<string name="menu_videocall_toggle_camera_title">Mute/Unmute camera</string>
|
<string name="menu_videocall_toggle_camera_title">Mute/Unmute camera</string>
|
||||||
|
|
|
@ -114,8 +114,12 @@ public class BandwidthManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
private VideoSize closestVideoSize(VideoSize vSize) {
|
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()) {
|
for (Size s : AndroidCameraRecordManager.getInstance().supportedVideoSizes()) {
|
||||||
if (s.height == vSize.getHeight() && s.width == vSize.getWidth()) {
|
if (s.height == testHeight && s.width == testWidth) {
|
||||||
return vSize;
|
return vSize;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -457,15 +457,9 @@ public class DialerActivity extends Activity implements LinphoneCoreListener {
|
||||||
} else if (state == LinphoneCall.State.CallEnd) {
|
} else if (state == LinphoneCall.State.CallEnd) {
|
||||||
exitCallMode();
|
exitCallMode();
|
||||||
} else if (state == LinphoneCall.State.StreamsRunning) {
|
} 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);
|
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;
|
mCurrentCallState = state;
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,8 +36,12 @@ public class VideoCallActivity extends Activity {
|
||||||
SurfaceView mVideoView;
|
SurfaceView mVideoView;
|
||||||
SurfaceView mVideoCaptureView;
|
SurfaceView mVideoCaptureView;
|
||||||
AndroidCameraRecordManager recordManager;
|
AndroidCameraRecordManager recordManager;
|
||||||
|
private static final String tag = "Linphone";
|
||||||
|
public static boolean launched = false;
|
||||||
|
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
Log.d(tag, "onCreate VideoCallActivity");
|
||||||
|
launched = true;
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.videocall);
|
setContentView(R.layout.videocall);
|
||||||
|
|
||||||
|
@ -63,9 +67,9 @@ public class VideoCallActivity extends Activity {
|
||||||
|
|
||||||
private void rewriteChangeResolutionItem(MenuItem item) {
|
private void rewriteChangeResolutionItem(MenuItem item) {
|
||||||
if (BandwidthManager.getInstance().isUserRestriction()) {
|
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));
|
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;
|
break;
|
||||||
case R.id.videocall_menu_toggle_camera:
|
case R.id.videocall_menu_toggle_camera:
|
||||||
recordManager.toggleMute();
|
recordManager.toggleMute();
|
||||||
|
LinphoneCore lc = LinphoneService.instance().getLinphoneCore();
|
||||||
|
if (lc.isIncall()) {
|
||||||
|
lc.getCurrentCall().enableCamera(!recordManager.isMuted());
|
||||||
|
}
|
||||||
rewriteToggleCameraItem(item);
|
rewriteToggleCameraItem(item);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -121,9 +129,16 @@ public class VideoCallActivity extends Activity {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onDestroy() {
|
protected void onDestroy() {
|
||||||
// TODO Auto-generated method stub
|
Log.d(tag, "onDestroy VideoCallActivity");
|
||||||
|
launched = false;
|
||||||
super.onDestroy();
|
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);
|
parameters.set("camera-id", params.cameraId);
|
||||||
|
if (!params.videoDimensionsInverted) {
|
||||||
parameters.setPreviewSize(params.width, params.height);
|
parameters.setPreviewSize(params.width, params.height);
|
||||||
|
} else {
|
||||||
|
parameters.setPreviewSize(params.height, params.width);
|
||||||
|
}
|
||||||
parameters.setPreviewFrameRate(Math.round(params.fps));
|
parameters.setPreviewFrameRate(Math.round(params.fps));
|
||||||
if (parameters.getSupportedFocusModes().contains(Camera.Parameters.FOCUS_MODE_AUTO)) {
|
if (parameters.getSupportedFocusModes().contains(Camera.Parameters.FOCUS_MODE_AUTO)) {
|
||||||
Log.w(tag, "Auto Focus supported by camera device");
|
Log.w(tag, "Auto Focus supported by camera device");
|
||||||
|
@ -182,6 +186,7 @@ public abstract class AndroidCameraRecord {
|
||||||
int cameraId;
|
int cameraId;
|
||||||
int rotation;
|
int rotation;
|
||||||
public SurfaceView surfaceView;
|
public SurfaceView surfaceView;
|
||||||
|
boolean videoDimensionsInverted;
|
||||||
|
|
||||||
public RecorderParams(long ptr) {
|
public RecorderParams(long ptr) {
|
||||||
filterDataNativePtr = ptr;
|
filterDataNativePtr = ptr;
|
||||||
|
|
|
@ -35,17 +35,19 @@ public class AndroidCameraRecordImpl extends AndroidCameraRecord implements Prev
|
||||||
private double timeElapsedBetweenFrames = 0;
|
private double timeElapsedBetweenFrames = 0;
|
||||||
private long lastFrameTime = 0;
|
private long lastFrameTime = 0;
|
||||||
private final double expectedTimeBetweenFrames;
|
private final double expectedTimeBetweenFrames;
|
||||||
|
private boolean videoDimensionsInverted;
|
||||||
|
|
||||||
public AndroidCameraRecordImpl(RecorderParams parameters) {
|
public AndroidCameraRecordImpl(RecorderParams parameters) {
|
||||||
super(parameters);
|
super(parameters);
|
||||||
expectedTimeBetweenFrames = 1d / Math.round(parameters.fps);
|
expectedTimeBetweenFrames = 1d / Math.round(parameters.fps);
|
||||||
filterCtxPtr = parameters.filterDataNativePtr;
|
filterCtxPtr = parameters.filterDataNativePtr;
|
||||||
|
videoDimensionsInverted = parameters.videoDimensionsInverted;
|
||||||
|
|
||||||
storePreviewCallBack(this);
|
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) {
|
public void onPreviewFrame(byte[] data, Camera camera) {
|
||||||
|
@ -69,7 +71,7 @@ public class AndroidCameraRecordImpl extends AndroidCameraRecord implements Prev
|
||||||
long curTime = System.currentTimeMillis();
|
long curTime = System.currentTimeMillis();
|
||||||
if (lastFrameTime == 0) {
|
if (lastFrameTime == 0) {
|
||||||
lastFrameTime = curTime;
|
lastFrameTime = curTime;
|
||||||
putImage(filterCtxPtr, data, getOrientationCode());
|
putImage(filterCtxPtr, data, getOrientationCode(), videoDimensionsInverted);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,7 +84,7 @@ public class AndroidCameraRecordImpl extends AndroidCameraRecord implements Prev
|
||||||
timeElapsedBetweenFrames = currentTimeElapsed;
|
timeElapsedBetweenFrames = currentTimeElapsed;
|
||||||
|
|
||||||
// Log.d("onPreviewFrame: ", Integer.toString(data.length));
|
// 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 List<Size> supportedVideoSizes;
|
||||||
private int rotation;
|
private int rotation;
|
||||||
|
private static final String tag = "Linphone";
|
||||||
|
|
||||||
|
|
||||||
public void setParametersFromFilter(long filterDataPtr, int height, int width, float fps) {
|
public void setParametersFromFilter(long filterDataPtr, int height, int width, float fps) {
|
||||||
|
stopVideoRecording();
|
||||||
RecorderParams p = new RecorderParams(filterDataPtr);
|
RecorderParams p = new RecorderParams(filterDataPtr);
|
||||||
p.fps = fps;
|
p.fps = fps;
|
||||||
p.width = width;
|
p.width = width;
|
||||||
p.height = height;
|
p.height = height;
|
||||||
p.cameraId = cameraId;
|
p.cameraId = cameraId;
|
||||||
|
p.videoDimensionsInverted = width < height;
|
||||||
parameters = p;
|
parameters = p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -103,16 +106,20 @@ public class AndroidCameraRecordManager {
|
||||||
holder.addCallback(new Callback() {
|
holder.addCallback(new Callback() {
|
||||||
public void surfaceDestroyed(SurfaceHolder holder) {
|
public void surfaceDestroyed(SurfaceHolder holder) {
|
||||||
surfaceView = null;
|
surfaceView = null;
|
||||||
|
Log.d(tag , "Video capture surface destroyed");
|
||||||
stopVideoRecording();
|
stopVideoRecording();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void surfaceCreated(SurfaceHolder holder) {
|
public void surfaceCreated(SurfaceHolder holder) {
|
||||||
surfaceView = sv;
|
surfaceView = sv;
|
||||||
|
Log.d(tag , "Video capture surface created");
|
||||||
tryToStartVideoRecording();
|
tryToStartVideoRecording();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void surfaceChanged(SurfaceHolder holder, int format, int width,
|
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 long getRemoteAddress(long nativePtr);
|
||||||
native private int getState(long nativePtr);
|
native private int getState(long nativePtr);
|
||||||
private native long getCurrentParams(long nativePtr);
|
private native long getCurrentParams(long nativePtr);
|
||||||
|
private native void enableCamera(long nativePtr, boolean enabled);
|
||||||
|
|
||||||
protected LinphoneCallImpl(long aNativePtr) {
|
protected LinphoneCallImpl(long aNativePtr) {
|
||||||
nativePtr = aNativePtr;
|
nativePtr = aNativePtr;
|
||||||
|
@ -66,4 +67,8 @@ class LinphoneCallImpl implements LinphoneCall {
|
||||||
public LinphoneCallParams getCurrentParamsReadWrite() {
|
public LinphoneCallParams getCurrentParamsReadWrite() {
|
||||||
return getCurrentParamsReadOnly().copy();
|
return getCurrentParamsReadOnly().copy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void enableCamera(boolean enabled) {
|
||||||
|
enableCamera(nativePtr, enabled);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue