Skip to content
Snippets Groups Projects
Commit f759800d authored by vkuzub's avatar vkuzub Committed by Leo Ma
Browse files

Added startTorch and stopTorch methods (#462)

parent a8c36e3b
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -191,6 +191,7 @@ public class SrsCameraView extends GLSurfaceView implements GLSurfaceView.Render
}
 
public void setCameraId(int id) {
stopTorch();
mCamId = id;
setPreviewOrientation(mPreviewOrientation);
}
Loading
Loading
@@ -320,6 +321,7 @@ public class SrsCameraView extends GLSurfaceView implements GLSurfaceView.Render
public void stopCamera() {
disableEncoding();
 
stopTorch();
if (mCamera != null) {
mCamera.stopPreview();
mCamera.release();
Loading
Loading
@@ -388,6 +390,29 @@ public class SrsCameraView extends GLSurfaceView implements GLSurfaceView.Render
return closestRange;
}
 
public boolean startTorch() {
if (mCamera != null) {
Camera.Parameters params = mCamera.getParameters();
List<String> supportedFlashModes = params.getSupportedFlashModes();
if (supportedFlashModes != null && !supportedFlashModes.isEmpty()) {
if (supportedFlashModes.contains(Camera.Parameters.FLASH_MODE_TORCH)) {
params.setFlashMode(Camera.Parameters.FLASH_MODE_TORCH);
mCamera.setParameters(params);
return true;
}
}
}
return false;
}
public void stopTorch() {
if (mCamera != null) {
Camera.Parameters params = mCamera.getParameters();
params.setFlashMode(Camera.Parameters.FLASH_MODE_OFF);
mCamera.setParameters(params);
}
}
public interface PreviewCallback {
 
void onGetRgbaFrame(byte[] data, int width, int height);
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment