From e2921e71354855f104160fed1b7d20890f86b7ba Mon Sep 17 00:00:00 2001 From: jiangdongguo <765067602@qq.com> Date: Fri, 10 Nov 2017 15:18:45 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=97=A0=E6=B3=95=E5=B1=8F?= =?UTF-8?q?=E8=94=BD=E5=A3=B0=E9=9F=B3=E9=97=AE=E9=A2=98=EF=BC=8C=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E9=87=8D=E5=90=AFCamera=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../usbcamera/view/USBCameraActivity.java | 17 +++++++++++- .../main/res/layout/activity_usbcamera.xml | 10 +++++++ .../jiangdg/usbcamera/USBCameraManager.java | 27 +++++++++++++++++-- .../usb/common/AbstractUVCCameraHandler.java | 2 +- .../usb/encoder/biz/Mp4MediaMuxer.java | 17 +++++++----- 5 files changed, 62 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/com/jiangdg/usbcamera/view/USBCameraActivity.java b/app/src/main/java/com/jiangdg/usbcamera/view/USBCameraActivity.java index 7c4c2f5..2c2ee4b 100644 --- a/app/src/main/java/com/jiangdg/usbcamera/view/USBCameraActivity.java +++ b/app/src/main/java/com/jiangdg/usbcamera/view/USBCameraActivity.java @@ -48,6 +48,8 @@ public class USBCameraActivity extends AppCompatActivity implements CameraDialog public Button mBtnRecord; @BindView(R.id.btn_update_resolution) public Button mBtnUpdateResultion; + @BindView(R.id.btn_restart_camera) + Button mBtnRestartCamera; private USBCameraManager mUSBManager; private CameraViewInterface mUVCCameraView; @@ -130,10 +132,23 @@ public class USBCameraActivity extends AppCompatActivity implements CameraDialog } } - @OnClick({R.id.camera_view, R.id.btn_capture_pic, R.id.btn_rec_video,R.id.btn_update_resolution}) + @OnClick({R.id.camera_view, R.id.btn_capture_pic, R.id.btn_rec_video,R.id.btn_update_resolution,R.id.btn_restart_camera}) public void onViewClick(View view) { int vId = view.getId(); switch (vId) { + // 重启Camera + case R.id.btn_restart_camera: + if(mUSBManager == null) + return; + mUSBManager.restartUSBCamera(USBCameraActivity.this, mUVCCameraView, new USBCameraManager.OnPreviewListener() { + @Override + public void onPreviewResult(boolean isSuccess) { + if(isSuccess) { + showShortMsg("重启成功"); + } + } + }); + break; // 切换分辨率 case R.id.btn_update_resolution: if(mUSBManager == null) diff --git a/app/src/main/res/layout/activity_usbcamera.xml b/app/src/main/res/layout/activity_usbcamera.xml index b776f17..a737bc6 100644 --- a/app/src/main/res/layout/activity_usbcamera.xml +++ b/app/src/main/res/layout/activity_usbcamera.xml @@ -45,4 +45,14 @@ android:textSize="16sp" android:text="切换分辨率为320x240"/> +