set surfaceHolder when not null

pull/209/head
xufuji456 3 years ago
parent 69e6eb7763
commit 2ca0bd97a5
  1. 6
      Live/src/main/java/com/frank/live/camera/CameraHelper.java
  2. 5
      app/src/main/java/com/frank/ffmpeg/activity/LiveActivity.kt

@ -114,7 +114,6 @@ public class CameraHelper implements SurfaceHolder.Callback, Camera.PreviewCallb
parameters.setPreviewSize(mWidth, mHeight);
}
public void setPreviewDisplay(SurfaceHolder surfaceHolder) {
mSurfaceHolder = surfaceHolder;
mSurfaceHolder.addCallback(this);
@ -160,7 +159,7 @@ public class CameraHelper implements SurfaceHolder.Callback, Camera.PreviewCallb
int index = 0;
int ySize = mWidth * mHeight;
int uvHeight = mHeight / 2;
//back camera rotate 90 deree
//back camera
if (mCameraId == Camera.CameraInfo.CAMERA_FACING_BACK) {
for (int i = 0; i < mWidth; i++) {
@ -177,8 +176,7 @@ public class CameraHelper implements SurfaceHolder.Callback, Camera.PreviewCallb
bytes[index++] = data[ySize + mWidth * j + i + 1];
}
}
} else {
//rotate 90 degree
} else { // front camera
for (int i = 0; i < mWidth; i++) {
int nPos = mWidth - 1;
for (int j = 0; j < mHeight; j++) {

@ -83,12 +83,11 @@ open class LiveActivity : BaseActivity(), CompoundButton.OnCheckedChangeListener
val audioParam = AudioParam(sampleRate, channelConfig, audioFormat, numChannels)
// Camera1: SurfaceView Camera2: TextureView
livePusher = LivePusherNew(this, videoParam, audioParam, liveView, CameraType.CAMERA2)
var holder :SurfaceHolder ?= null
if (liveView is SurfaceView) {
holder = (liveView as SurfaceView).holder
}
val holder: SurfaceHolder = (liveView as SurfaceView).holder
livePusher!!.setPreviewDisplay(holder)
}
}
private fun registerBroadcast(networkChangeListener: OnNetworkChangeListener) {
connectionReceiver = ConnectionReceiver(networkChangeListener)

Loading…
Cancel
Save