|
|
@ -1,4 +1,4 @@ |
|
|
|
package com.frank.live.stream; |
|
|
|
package com.frank.live.camera; |
|
|
|
|
|
|
|
|
|
|
|
import android.app.Activity; |
|
|
|
import android.app.Activity; |
|
|
|
import android.graphics.ImageFormat; |
|
|
|
import android.graphics.ImageFormat; |
|
|
@ -10,7 +10,7 @@ import java.util.List; |
|
|
|
|
|
|
|
|
|
|
|
public class CameraHelper implements SurfaceHolder.Callback, Camera.PreviewCallback { |
|
|
|
public class CameraHelper implements SurfaceHolder.Callback, Camera.PreviewCallback { |
|
|
|
|
|
|
|
|
|
|
|
private Activity mActivity; |
|
|
|
private final Activity mActivity; |
|
|
|
private int mHeight; |
|
|
|
private int mHeight; |
|
|
|
private int mWidth; |
|
|
|
private int mWidth; |
|
|
|
private int mCameraId; |
|
|
|
private int mCameraId; |
|
|
@ -22,14 +22,14 @@ public class CameraHelper implements SurfaceHolder.Callback, Camera.PreviewCallb |
|
|
|
private OnChangedSizeListener mOnChangedSizeListener; |
|
|
|
private OnChangedSizeListener mOnChangedSizeListener; |
|
|
|
private byte[] bytes; |
|
|
|
private byte[] bytes; |
|
|
|
|
|
|
|
|
|
|
|
CameraHelper(Activity activity, int cameraId, int width, int height) { |
|
|
|
public CameraHelper(Activity activity, int cameraId, int width, int height) { |
|
|
|
mActivity = activity; |
|
|
|
mActivity = activity; |
|
|
|
mCameraId = cameraId; |
|
|
|
mCameraId = cameraId; |
|
|
|
mWidth = width; |
|
|
|
mWidth = width; |
|
|
|
mHeight = height; |
|
|
|
mHeight = height; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void switchCamera() { |
|
|
|
public void switchCamera() { |
|
|
|
if (mCameraId == Camera.CameraInfo.CAMERA_FACING_BACK) { |
|
|
|
if (mCameraId == Camera.CameraInfo.CAMERA_FACING_BACK) { |
|
|
|
mCameraId = Camera.CameraInfo.CAMERA_FACING_FRONT; |
|
|
|
mCameraId = Camera.CameraInfo.CAMERA_FACING_FRONT; |
|
|
|
} else { |
|
|
|
} else { |
|
|
@ -115,12 +115,12 @@ public class CameraHelper implements SurfaceHolder.Callback, Camera.PreviewCallb |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void setPreviewDisplay(SurfaceHolder surfaceHolder) { |
|
|
|
public void setPreviewDisplay(SurfaceHolder surfaceHolder) { |
|
|
|
mSurfaceHolder = surfaceHolder; |
|
|
|
mSurfaceHolder = surfaceHolder; |
|
|
|
mSurfaceHolder.addCallback(this); |
|
|
|
mSurfaceHolder.addCallback(this); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void setPreviewCallback(Camera.PreviewCallback previewCallback) { |
|
|
|
public void setPreviewCallback(Camera.PreviewCallback previewCallback) { |
|
|
|
mPreviewCallback = previewCallback; |
|
|
|
mPreviewCallback = previewCallback; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -199,7 +199,7 @@ public class CameraHelper implements SurfaceHolder.Callback, Camera.PreviewCallb |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void setOnChangedSizeListener(OnChangedSizeListener listener) { |
|
|
|
public void setOnChangedSizeListener(OnChangedSizeListener listener) { |
|
|
|
mOnChangedSizeListener = listener; |
|
|
|
mOnChangedSizeListener = listener; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|