diff --git a/AndroidMedia/src/main/java/com/frank/androidmedia/controller/MediaProjectionController.kt b/AndroidMedia/src/main/java/com/frank/androidmedia/controller/MediaProjectionController.kt index 48e615f..90e2cee 100644 --- a/AndroidMedia/src/main/java/com/frank/androidmedia/controller/MediaProjectionController.kt +++ b/AndroidMedia/src/main/java/com/frank/androidmedia/controller/MediaProjectionController.kt @@ -176,6 +176,8 @@ open class MediaProjectionController(type: Int) { fun stopScreenRecord() { mediaProjection?.stop() virtualDisplay?.release() + isVideoEncoding = false + encodeThread?.interrupt() videoEncoder?.release() } diff --git a/Live/src/main/java/com/frank/live/LivePusherNew.java b/Live/src/main/java/com/frank/live/LivePusherNew.java index 6b9c791..80f99d3 100644 --- a/Live/src/main/java/com/frank/live/LivePusherNew.java +++ b/Live/src/main/java/com/frank/live/LivePusherNew.java @@ -9,7 +9,7 @@ import com.frank.live.listener.OnFrameDataCallback; import com.frank.live.param.AudioParam; import com.frank.live.param.VideoParam; import com.frank.live.stream.AudioStream; -import com.frank.live.stream.CameraType; +import com.frank.live.camera.CameraType; import com.frank.live.stream.VideoStream; import com.frank.live.stream.VideoStreamBase; import com.frank.live.stream.VideoStreamNew; diff --git a/Live/src/main/java/com/frank/live/camera2/Camera2Helper.java b/Live/src/main/java/com/frank/live/camera/Camera2Helper.java similarity index 99% rename from Live/src/main/java/com/frank/live/camera2/Camera2Helper.java rename to Live/src/main/java/com/frank/live/camera/Camera2Helper.java index c49770f..5a3342e 100644 --- a/Live/src/main/java/com/frank/live/camera2/Camera2Helper.java +++ b/Live/src/main/java/com/frank/live/camera/Camera2Helper.java @@ -1,4 +1,4 @@ -package com.frank.live.camera2; +package com.frank.live.camera; import android.Manifest; import android.annotation.TargetApi; diff --git a/Live/src/main/java/com/frank/live/camera2/Camera2Listener.java b/Live/src/main/java/com/frank/live/camera/Camera2Listener.java similarity index 88% rename from Live/src/main/java/com/frank/live/camera2/Camera2Listener.java rename to Live/src/main/java/com/frank/live/camera/Camera2Listener.java index 8f7e5a9..70062a9 100644 --- a/Live/src/main/java/com/frank/live/camera2/Camera2Listener.java +++ b/Live/src/main/java/com/frank/live/camera/Camera2Listener.java @@ -1,4 +1,4 @@ -package com.frank.live.camera2; +package com.frank.live.camera; import android.util.Size; diff --git a/Live/src/main/java/com/frank/live/stream/CameraHelper.java b/Live/src/main/java/com/frank/live/camera/CameraHelper.java similarity index 94% rename from Live/src/main/java/com/frank/live/stream/CameraHelper.java rename to Live/src/main/java/com/frank/live/camera/CameraHelper.java index 3fa656d..728b82e 100644 --- a/Live/src/main/java/com/frank/live/stream/CameraHelper.java +++ b/Live/src/main/java/com/frank/live/camera/CameraHelper.java @@ -1,4 +1,4 @@ -package com.frank.live.stream; +package com.frank.live.camera; import android.app.Activity; import android.graphics.ImageFormat; @@ -10,7 +10,7 @@ import java.util.List; public class CameraHelper implements SurfaceHolder.Callback, Camera.PreviewCallback { - private Activity mActivity; + private final Activity mActivity; private int mHeight; private int mWidth; private int mCameraId; @@ -22,14 +22,14 @@ public class CameraHelper implements SurfaceHolder.Callback, Camera.PreviewCallb private OnChangedSizeListener mOnChangedSizeListener; private byte[] bytes; - CameraHelper(Activity activity, int cameraId, int width, int height) { + public CameraHelper(Activity activity, int cameraId, int width, int height) { mActivity = activity; mCameraId = cameraId; mWidth = width; mHeight = height; } - void switchCamera() { + public void switchCamera() { if (mCameraId == Camera.CameraInfo.CAMERA_FACING_BACK) { mCameraId = Camera.CameraInfo.CAMERA_FACING_FRONT; } 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.addCallback(this); } - void setPreviewCallback(Camera.PreviewCallback previewCallback) { + public void setPreviewCallback(Camera.PreviewCallback 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; } diff --git a/Live/src/main/java/com/frank/live/stream/CameraType.java b/Live/src/main/java/com/frank/live/camera/CameraType.java similarity index 63% rename from Live/src/main/java/com/frank/live/stream/CameraType.java rename to Live/src/main/java/com/frank/live/camera/CameraType.java index ccb7e4e..8f6d889 100644 --- a/Live/src/main/java/com/frank/live/stream/CameraType.java +++ b/Live/src/main/java/com/frank/live/camera/CameraType.java @@ -1,4 +1,4 @@ -package com.frank.live.stream; +package com.frank.live.camera; public enum CameraType { CAMERA1, diff --git a/Live/src/main/java/com/frank/live/stream/VideoStream.java b/Live/src/main/java/com/frank/live/stream/VideoStream.java index 5c5e4c7..84f429a 100644 --- a/Live/src/main/java/com/frank/live/stream/VideoStream.java +++ b/Live/src/main/java/com/frank/live/stream/VideoStream.java @@ -6,14 +6,13 @@ import android.hardware.Camera; import android.view.SurfaceHolder; import android.view.View; +import com.frank.live.camera.CameraHelper; import com.frank.live.listener.OnFrameDataCallback; import com.frank.live.param.VideoParam; - public class VideoStream extends VideoStreamBase implements Camera.PreviewCallback, CameraHelper.OnChangedSizeListener { - private final OnFrameDataCallback mCallback; private final CameraHelper cameraHelper; private final int mBitrate; 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 99c4489..45d8568 100644 --- a/Live/src/main/java/com/frank/live/stream/VideoStreamNew.java +++ b/Live/src/main/java/com/frank/live/stream/VideoStreamNew.java @@ -10,8 +10,8 @@ import android.view.SurfaceHolder; import android.view.TextureView; import android.view.View; -import com.frank.live.camera2.Camera2Helper; -import com.frank.live.camera2.Camera2Listener; +import com.frank.live.camera.Camera2Helper; +import com.frank.live.camera.Camera2Listener; import com.frank.live.listener.OnFrameDataCallback; import com.frank.live.param.VideoParam; diff --git a/app/src/main/java/com/frank/ffmpeg/activity/LiveActivity.kt b/app/src/main/java/com/frank/ffmpeg/activity/LiveActivity.kt index 719473b..c052fe2 100644 --- a/app/src/main/java/com/frank/ffmpeg/activity/LiveActivity.kt +++ b/app/src/main/java/com/frank/ffmpeg/activity/LiveActivity.kt @@ -19,12 +19,12 @@ import android.widget.ToggleButton import com.frank.ffmpeg.R import com.frank.ffmpeg.handler.ConnectionReceiver import com.frank.ffmpeg.listener.OnNetworkChangeListener -import com.frank.live.camera2.Camera2Helper +import com.frank.live.camera.Camera2Helper import com.frank.live.listener.LiveStateChangeListener import com.frank.live.param.AudioParam import com.frank.live.param.VideoParam import com.frank.live.LivePusherNew -import com.frank.live.stream.CameraType +import com.frank.live.camera.CameraType /** * Realtime living with rtmp stream