Skip to content

Commit e143d27

Browse files
Merge pull request #478 from TakayukiHoshi1984/modify_host_camera_ae_state
AE precapture metering sequence を無効化
2 parents 4cd97c3 + f5fe7ef commit e143d27

2 files changed

Lines changed: 12 additions & 16 deletions

File tree

dConnectDevicePlugin/dConnectDeviceHost/app/src/main/java/org/deviceconnect/android/deviceplugin/host/camera/CameraWrapper.java

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -400,9 +400,6 @@ private void setDefaultCaptureRequest(final CaptureRequest.Builder request,
400400
}
401401
if (hasAutoExposure()) {
402402
request.set(CaptureRequest.CONTROL_AE_MODE, mAutoExposureMode);
403-
if (trigger) {
404-
request.set(CaptureRequest.CONTROL_AE_PRECAPTURE_TRIGGER, CameraMetadata.CONTROL_AE_PRECAPTURE_TRIGGER_START);
405-
}
406403
}
407404
setWhiteBalance(request);
408405
// LightがONの場合は、CONTROL_AE_MODEをCONTROL_AE_MODE_ONにする。
@@ -459,18 +456,16 @@ public synchronized void stopPreview() throws CameraWrapperException {
459456
close();
460457
}
461458
}
462-
463459
public synchronized void startRecording(final Surface recordingSurface,
464460
final boolean isResume) throws CameraWrapperException {
465461
if (mIsRecording && !isResume) {
466462
throw new CameraWrapperException("recording is started already.");
467463
}
468464
mIsRecording = true;
469465
mRecordingSurface = recordingSurface;
470-
if (mCameraDevice != null) {
471-
close();
472-
}
466+
473467
try {
468+
474469
CameraDevice cameraDevice = openCamera();
475470
CameraCaptureSession captureSession = createCaptureSession(cameraDevice);
476471
CaptureRequest.Builder request = cameraDevice.createCaptureRequest(CameraDevice.TEMPLATE_RECORD);
@@ -541,6 +536,7 @@ public synchronized void takeStillImage(final Surface stillImageSurface) throws
541536
CaptureRequest.Builder request = cameraDevice.createCaptureRequest(template);
542537
request.addTarget(stillImageSurface);
543538
setDefaultCaptureRequest(request);
539+
request.set(CaptureRequest.CONTROL_AF_TRIGGER, CameraMetadata.CONTROL_AF_TRIGGER_CANCEL);
544540
mCaptureSession.capture(request.build(), new CameraCaptureSession.CaptureCallback() {
545541
@Override
546542
public void onCaptureStarted(@NonNull CameraCaptureSession session, @NonNull CaptureRequest request, long timestamp, long frameNumber) {
@@ -684,10 +680,12 @@ private void onCaptureResult(final CaptureResult result, final boolean isComplet
684680
}
685681
if (!mIsAeReady) {
686682
Integer aeState = result.get(CaptureResult.CONTROL_AE_STATE);
683+
if (DEBUG) {
684+
Log.d(TAG, "prepareCapture: onCaptureCompleted: aeState=" + aeState);
685+
}
687686
mIsAeReady = aeState == null
688687
|| aeState == CaptureResult.CONTROL_AE_STATE_CONVERGED
689-
|| aeState == CaptureRequest.CONTROL_AE_STATE_FLASH_REQUIRED
690-
|| aeState == CaptureRequest.CONTROL_AE_STATE_PRECAPTURE;
688+
|| aeState == CaptureRequest.CONTROL_AE_STATE_FLASH_REQUIRED;
691689
}
692690
mIsCaptureReady |= isCompleted;
693691
if (DEBUG) {

dConnectDevicePlugin/dConnectDeviceHost/app/src/main/java/org/deviceconnect/android/deviceplugin/host/recorder/camera/Camera2Recorder.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
import java.util.Date;
5555
import java.util.List;
5656
import java.util.Locale;
57+
import java.util.concurrent.CountDownLatch;
5758

5859

5960
public class Camera2Recorder extends AbstractCamera2Recorder implements HostDevicePhotoRecorder, HostDeviceStreamRecorder {
@@ -582,10 +583,12 @@ private long registerVideoThumbnail(final File videoFile, final long videoId) {
582583
Log.d(TAG, "Stored thumbnail file: path=" + thumbnailFilePath);
583584
}
584585
ContentValues values = new ContentValues();
585-
values.put(MediaStore.Video.Thumbnails.DATA, thumbnailFilePath);
586+
values.put(MediaStore.Video.Thumbnails.DATA, videoFilePath);
586587
values.put(MediaStore.Video.Thumbnails.WIDTH, thumbnail.getWidth());
587588
values.put(MediaStore.Video.Thumbnails.HEIGHT, thumbnail.getHeight());
588589
values.put(MediaStore.Video.Thumbnails.KIND, kind);
590+
values.put(MediaStore.Video.Media.MIME_TYPE, "image/jpeg");
591+
589592
values.put(MediaStore.Video.Thumbnails.VIDEO_ID, videoId);
590593
ContentResolver resolver = getContext().getApplicationContext().getContentResolver();
591594
Uri uri = resolver.insert(MediaStore.Video.Thumbnails.EXTERNAL_CONTENT_URI, values);
@@ -606,12 +609,7 @@ private long registerVideoThumbnail(final File videoFile, final long videoId) {
606609
return -1;
607610
}
608611
return Long.parseLong(id);
609-
} catch (IOException e) {
610-
if (DEBUG) {
611-
Log.e(TAG, "Failed to store video thumbnail by FileManager: videoFilePath=" + videoFilePath, e);
612-
}
613-
return -1;
614-
} catch (NumberFormatException e) {
612+
} catch (IOException | NumberFormatException e) {
615613
if (DEBUG) {
616614
Log.e(TAG, "Failed to parse thumbnail ID as long type: videoFilePath=" + videoFilePath);
617615
}

0 commit comments

Comments
 (0)