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
Branches
Tags
No related merge requests found
......@@ -47,21 +47,17 @@ import cx.ring.utils.Log;
public class HardwareServiceImpl extends HardwareService {
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 int cameraFront = 0;
private int cameraBack = 0;
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 Camera previewCamera = null;
private final HashMap<String, VideoParams> mParams = new HashMap<>();
private final LongSparseArray<DeviceParams> mNativeParams = new LongSparseArray<>();
public HardwareServiceImpl(Context mContext) {
this.mContext = mContext;
......@@ -339,7 +335,6 @@ public class HardwareServiceImpl extends HardwareService {
previewParams = videoParams;
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_WIDTH, videoParams.rotWidth);
event.addEventInput(ServiceEvent.EventInput.VIDEO_HEIGHT, videoParams.rotHeight);
......@@ -364,7 +359,6 @@ public class HardwareServiceImpl extends HardwareService {
}
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_WIDTH, params.width);
event.addEventInput(ServiceEvent.EventInput.VIDEO_HEIGHT, params.height);
......@@ -534,27 +528,23 @@ public class HardwareServiceImpl extends HardwareService {
}
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 format;
// size as captured by Android
public int width;
public int height;
//size, rotated, as seen by the daemon
public int rotWidth;
public int rotHeight;
public int rate;
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 {
......
......@@ -345,16 +345,14 @@ public class CallPresenter extends RootPresenter<CallView> implements Observer<S
switch (event.getEventType()) {
case VIDEO_EVENT:
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);
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) {
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)) {
boolean videoStarted = event.getEventInput(ServiceEvent.EventInput.VIDEO_STARTED, Boolean.class, false);
getView().displayVideoSurface(videoStarted);
......
......@@ -110,7 +110,6 @@ public class ServiceEvent {
BUDDY_URI,
LINE_STATE,
VIDEO_START,
VIDEO_CAMERA,
VIDEO_STARTED,
VIDEO_WIDTH,
VIDEO_HEIGHT,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment