diff --git a/Live/src/main/java/com/frank/live/stream/CameraHelper.java b/Live/src/main/java/com/frank/live/stream/CameraHelper.java index 6de4a7d..3fa656d 100644 --- a/Live/src/main/java/com/frank/live/stream/CameraHelper.java +++ b/Live/src/main/java/com/frank/live/stream/CameraHelper.java @@ -41,11 +41,8 @@ public class CameraHelper implements SurfaceHolder.Callback, Camera.PreviewCallb private void stopPreview() { if (mCamera != null) { - //预览数据回调接口 mCamera.setPreviewCallback(null); - //停止预览 mCamera.stopPreview(); - //释放摄像头 mCamera.release(); mCamera = null; } @@ -102,7 +99,7 @@ public class CameraHelper implements SurfaceHolder.Callback, Camera.PreviewCallb private void setPreviewSize(Camera.Parameters parameters) { List supportedPreviewSizes = parameters.getSupportedPreviewSizes(); Camera.Size size = supportedPreviewSizes.get(0); - //选择最合适的camera支持分辨率 + //select the best resolution of camera int m = Math.abs(size.height * size.width - mWidth * mHeight); supportedPreviewSizes.remove(0); for (Camera.Size next : supportedPreviewSizes) { @@ -151,8 +148,8 @@ public class CameraHelper implements SurfaceHolder.Callback, Camera.PreviewCallb rotation90(data); break; case Surface.ROTATION_90: - break; case Surface.ROTATION_270: + default: break; } mPreviewCallback.onPreviewFrame(bytes, camera); @@ -163,7 +160,7 @@ public class CameraHelper implements SurfaceHolder.Callback, Camera.PreviewCallb int index = 0; int ySize = mWidth * mHeight; int uvHeight = mHeight / 2; - //后置摄像头顺时针旋转90度 + //back camera rotate 90 deree if (mCameraId == Camera.CameraInfo.CAMERA_FACING_BACK) { for (int i = 0; i < mWidth; i++) { @@ -181,7 +178,7 @@ public class CameraHelper implements SurfaceHolder.Callback, Camera.PreviewCallb } } } else { - //逆时针旋转90度 + //rotate 90 degree for (int i = 0; i < mWidth; i++) { int nPos = mWidth - 1; for (int j = 0; j < mHeight; j++) { diff --git a/Live/src/main/java/com/frank/live/stream/VideoStreamNew.java b/Live/src/main/java/com/frank/live/stream/VideoStreamNew.java index b4a52ff..0dc0c00 100644 --- a/Live/src/main/java/com/frank/live/stream/VideoStreamNew.java +++ b/Live/src/main/java/com/frank/live/stream/VideoStreamNew.java @@ -15,7 +15,7 @@ import com.frank.live.camera2.Camera2Listener; import com.frank.live.param.VideoParam; /** - * 视频推流:使用Camera2 + * Pushing video stream: using Camera2 * Created by frank on 2020/02/12. */ public class VideoStreamNew implements TextureView.SurfaceTextureListener, Camera2Listener { @@ -42,7 +42,7 @@ public class VideoStreamNew implements TextureView.SurfaceTextureListener, Camer } /** - * 开始预览 + * start previewing */ private void startPreview() { int rotateDegree = 0; @@ -85,7 +85,7 @@ public class VideoStreamNew implements TextureView.SurfaceTextureListener, Camer } /** - * 停止预览 + * stop previewing */ private void stopPreview() { if (camera2Helper != null) { @@ -117,7 +117,8 @@ public class VideoStreamNew implements TextureView.SurfaceTextureListener, Camer } /** - * nv21摄像头数据 + * camere preview frame data + * * @param y plane of y * @param u plane of u * @param v plane of v diff --git a/Live/src/main/java/com/frank/live/view/SmartCameraView.java b/Live/src/main/java/com/frank/live/view/SmartCameraView.java index 01eead3..e36a06a 100644 --- a/Live/src/main/java/com/frank/live/view/SmartCameraView.java +++ b/Live/src/main/java/com/frank/live/view/SmartCameraView.java @@ -156,9 +156,9 @@ public class SmartCameraView extends GLSurfaceView implements GLSurfaceView.Rend mGLPreviewBuffer = ByteBuffer.allocate(mPreviewWidth * mPreviewHeight * 4); mInputAspectRatio = mPreviewWidth > mPreviewHeight ? - (float) mPreviewWidth / mPreviewHeight : (float) mPreviewHeight / mPreviewWidth; + (float) mPreviewWidth / mPreviewHeight : (float) mPreviewHeight / mPreviewWidth; - return new int[] { mPreviewWidth, mPreviewHeight }; + return new int[]{mPreviewWidth, mPreviewHeight}; } public boolean setFilter(final MagicFilterType type) { @@ -189,7 +189,7 @@ public class SmartCameraView extends GLSurfaceView implements GLSurfaceView.Rend queueEvent(new Runnable() { @Override public void run() { - GLES20.glDeleteTextures(1, new int[]{ mOESTextureId }, 0); + GLES20.glDeleteTextures(1, new int[]{mOESTextureId}, 0); mOESTextureId = OpenGLUtils.NO_TEXTURE; } }); @@ -311,11 +311,11 @@ public class SmartCameraView extends GLSurfaceView implements GLSurfaceView.Rend Camera.Size psize; for (int i = 0; i < pictureSizes.size(); i++) { psize = pictureSizes.get(i); - Log.i(TAG,psize.width+" x "+psize.height); + Log.i(TAG, psize.width + " x " + psize.height); } for (int i = 0; i < previewSizes.size(); i++) { psize = previewSizes.get(i); - Log.i(TAG,psize.width+" x "+psize.height); + Log.i(TAG, psize.width + " x " + psize.height); } }