Feature: move CameraHelper and Camera2Helper together

pull/209/head
xufuji456 3 years ago
parent 87364476da
commit e758ef1635
  1. 2
      AndroidMedia/src/main/java/com/frank/androidmedia/controller/MediaProjectionController.kt
  2. 2
      Live/src/main/java/com/frank/live/LivePusherNew.java
  3. 2
      Live/src/main/java/com/frank/live/camera/Camera2Helper.java
  4. 2
      Live/src/main/java/com/frank/live/camera/Camera2Listener.java
  5. 14
      Live/src/main/java/com/frank/live/camera/CameraHelper.java
  6. 2
      Live/src/main/java/com/frank/live/camera/CameraType.java
  7. 3
      Live/src/main/java/com/frank/live/stream/VideoStream.java
  8. 4
      Live/src/main/java/com/frank/live/stream/VideoStreamNew.java
  9. 4
      app/src/main/java/com/frank/ffmpeg/activity/LiveActivity.kt

@ -176,6 +176,8 @@ open class MediaProjectionController(type: Int) {
fun stopScreenRecord() {
mediaProjection?.stop()
virtualDisplay?.release()
isVideoEncoding = false
encodeThread?.interrupt()
videoEncoder?.release()
}

@ -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;

@ -1,4 +1,4 @@
package com.frank.live.camera2;
package com.frank.live.camera;
import android.Manifest;
import android.annotation.TargetApi;

@ -1,4 +1,4 @@
package com.frank.live.camera2;
package com.frank.live.camera;
import android.util.Size;

@ -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;
}

@ -1,4 +1,4 @@
package com.frank.live.stream;
package com.frank.live.camera;
public enum CameraType {
CAMERA1,

@ -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;

@ -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;

@ -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

Loading…
Cancel
Save