Skip to content
Snippets Groups Projects
Commit c61e5444 authored by Loïc Siret's avatar Loïc Siret
Browse files

androidTV: Preview size

Prior this patch the preview size was good only for the camid == 1.
This fixes the size of the preview on device and TV by removing check
on the cam id and applying the good preview size on each Video event.

Change-Id: Icb6eba0baefc6faf6dba8e78c3b26ba2ad8cc958
parent 5ae9419c
No related branches found
No related tags found
No related merge requests found
...@@ -47,21 +47,17 @@ import cx.ring.utils.Log; ...@@ -47,21 +47,17 @@ import cx.ring.utils.Log;
public class HardwareServiceImpl extends HardwareService { public class HardwareServiceImpl extends HardwareService {
public static final String TAG = HardwareServiceImpl.class.getName(); public static final String TAG = HardwareServiceImpl.class.getName();
private static WeakReference<SurfaceHolder> mCameraPreviewSurface = new WeakReference<>(null);
private static Map<String, WeakReference<SurfaceHolder>> videoSurfaces = Collections.synchronizedMap(new HashMap<String, WeakReference<SurfaceHolder>>());
private final Map<String, Shm> videoInputs = new HashMap<>();
private final HashMap<String, VideoParams> mParams = new HashMap<>();
private final LongSparseArray<DeviceParams> mNativeParams = new LongSparseArray<>();
private Context mContext; private Context mContext;
private int cameraFront = 0; private int cameraFront = 0;
private int cameraBack = 0; private int cameraBack = 0;
private int currentCamera = -1; private int currentCamera = -1;
private final Map<String, Shm> videoInputs = new HashMap<>();
private static WeakReference<SurfaceHolder> mCameraPreviewSurface = new WeakReference<>(null);
private static Map<String, WeakReference<SurfaceHolder>> videoSurfaces = Collections.synchronizedMap(new HashMap<String, WeakReference<SurfaceHolder>>());
private VideoParams previewParams = null; private VideoParams previewParams = null;
private Camera previewCamera = null; private Camera previewCamera = null;
private final HashMap<String, VideoParams> mParams = new HashMap<>();
private final LongSparseArray<DeviceParams> mNativeParams = new LongSparseArray<>();
public HardwareServiceImpl(Context mContext) { public HardwareServiceImpl(Context mContext) {
this.mContext = mContext; this.mContext = mContext;
...@@ -339,7 +335,6 @@ public class HardwareServiceImpl extends HardwareService { ...@@ -339,7 +335,6 @@ public class HardwareServiceImpl extends HardwareService {
previewParams = videoParams; previewParams = videoParams;
ServiceEvent event = new ServiceEvent(ServiceEvent.EventType.VIDEO_EVENT); ServiceEvent event = new ServiceEvent(ServiceEvent.EventType.VIDEO_EVENT);
event.addEventInput(ServiceEvent.EventInput.VIDEO_CAMERA, videoParams.id == 1);
event.addEventInput(ServiceEvent.EventInput.VIDEO_STARTED, true); event.addEventInput(ServiceEvent.EventInput.VIDEO_STARTED, true);
event.addEventInput(ServiceEvent.EventInput.VIDEO_WIDTH, videoParams.rotWidth); event.addEventInput(ServiceEvent.EventInput.VIDEO_WIDTH, videoParams.rotWidth);
event.addEventInput(ServiceEvent.EventInput.VIDEO_HEIGHT, videoParams.rotHeight); event.addEventInput(ServiceEvent.EventInput.VIDEO_HEIGHT, videoParams.rotHeight);
...@@ -364,7 +359,6 @@ public class HardwareServiceImpl extends HardwareService { ...@@ -364,7 +359,6 @@ public class HardwareServiceImpl extends HardwareService {
} }
ServiceEvent event = new ServiceEvent(ServiceEvent.EventType.VIDEO_EVENT); ServiceEvent event = new ServiceEvent(ServiceEvent.EventType.VIDEO_EVENT);
event.addEventInput(ServiceEvent.EventInput.VIDEO_CAMERA, params.id == 1);
event.addEventInput(ServiceEvent.EventInput.VIDEO_STARTED, false); event.addEventInput(ServiceEvent.EventInput.VIDEO_STARTED, false);
event.addEventInput(ServiceEvent.EventInput.VIDEO_WIDTH, params.width); event.addEventInput(ServiceEvent.EventInput.VIDEO_WIDTH, params.width);
event.addEventInput(ServiceEvent.EventInput.VIDEO_HEIGHT, params.height); event.addEventInput(ServiceEvent.EventInput.VIDEO_HEIGHT, params.height);
...@@ -534,27 +528,23 @@ public class HardwareServiceImpl extends HardwareService { ...@@ -534,27 +528,23 @@ public class HardwareServiceImpl extends HardwareService {
} }
private static class VideoParams { private static class VideoParams {
public VideoParams(int id, int format, int width, int height, int rate) {
this.id = id;
this.format = format;
this.width = width;
this.height = height;
this.rate = rate;
}
public int id; public int id;
public int format; public int format;
// size as captured by Android // size as captured by Android
public int width; public int width;
public int height; public int height;
//size, rotated, as seen by the daemon //size, rotated, as seen by the daemon
public int rotWidth; public int rotWidth;
public int rotHeight; public int rotHeight;
public int rate; public int rate;
public int rotation; public int rotation;
public VideoParams(int id, int format, int width, int height, int rate) {
this.id = id;
this.format = format;
this.width = width;
this.height = height;
this.rate = rate;
}
} }
private static class DeviceParams { private static class DeviceParams {
......
...@@ -345,16 +345,14 @@ public class CallPresenter extends RootPresenter<CallView> implements Observer<S ...@@ -345,16 +345,14 @@ public class CallPresenter extends RootPresenter<CallView> implements Observer<S
switch (event.getEventType()) { switch (event.getEventType()) {
case VIDEO_EVENT: case VIDEO_EVENT:
boolean videoStart = event.getEventInput(ServiceEvent.EventInput.VIDEO_START, Boolean.class, false); boolean videoStart = event.getEventInput(ServiceEvent.EventInput.VIDEO_START, Boolean.class, false);
boolean camera = event.getEventInput(ServiceEvent.EventInput.VIDEO_CAMERA, Boolean.class, false);
String callId = event.getEventInput(ServiceEvent.EventInput.VIDEO_CALL, String.class); String callId = event.getEventInput(ServiceEvent.EventInput.VIDEO_CALL, String.class);
Log.d(TAG, "VIDEO_EVENT: " + videoStart + " " + camera + " " + callId); Log.d(TAG, "VIDEO_EVENT: " + videoStart + " " + callId);
previewWidth = event.getEventInput(ServiceEvent.EventInput.VIDEO_WIDTH, Integer.class, 0);
previewHeight = event.getEventInput(ServiceEvent.EventInput.VIDEO_HEIGHT, Integer.class, 0);
if (videoStart) { if (videoStart) {
getView().displayVideoSurface(true); getView().displayVideoSurface(true);
} else if (camera) {
previewWidth = event.getEventInput(ServiceEvent.EventInput.VIDEO_WIDTH, Integer.class, 0);
previewHeight = event.getEventInput(ServiceEvent.EventInput.VIDEO_HEIGHT, Integer.class, 0);
} else if (mSipCall != null && callId != null && mSipCall.getCallId().equals(callId)) { } else if (mSipCall != null && callId != null && mSipCall.getCallId().equals(callId)) {
boolean videoStarted = event.getEventInput(ServiceEvent.EventInput.VIDEO_STARTED, Boolean.class, false); boolean videoStarted = event.getEventInput(ServiceEvent.EventInput.VIDEO_STARTED, Boolean.class, false);
getView().displayVideoSurface(videoStarted); getView().displayVideoSurface(videoStarted);
......
...@@ -110,7 +110,6 @@ public class ServiceEvent { ...@@ -110,7 +110,6 @@ public class ServiceEvent {
BUDDY_URI, BUDDY_URI,
LINE_STATE, LINE_STATE,
VIDEO_START, VIDEO_START,
VIDEO_CAMERA,
VIDEO_STARTED, VIDEO_STARTED,
VIDEO_WIDTH, VIDEO_WIDTH,
VIDEO_HEIGHT, VIDEO_HEIGHT,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment