|
|
|
@ -22,12 +22,15 @@ import android.os.Message;
|
|
|
|
|
import android.provider.MediaStore;
|
|
|
|
|
import android.text.TextUtils;
|
|
|
|
|
import android.util.Log;
|
|
|
|
|
import android.view.SurfaceHolder;
|
|
|
|
|
import android.view.View;
|
|
|
|
|
import android.view.Window;
|
|
|
|
|
import android.view.WindowInsets;
|
|
|
|
|
import android.view.WindowManager;
|
|
|
|
|
import android.view.WindowMetrics;
|
|
|
|
|
import android.widget.FrameLayout;
|
|
|
|
|
|
|
|
|
|
import androidx.annotation.NonNull;
|
|
|
|
|
import androidx.appcompat.app.AppCompatActivity;
|
|
|
|
|
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
|
|
|
|
|
|
|
|
|
@ -241,6 +244,14 @@ public class Camera2VideoActivity extends AppCompatActivity {
|
|
|
|
|
mCameraHeight = mVideoHeight;
|
|
|
|
|
|
|
|
|
|
AspectRatioFrameLayout frameLayout = (AspectRatioFrameLayout)findViewById(R.id.wrap_view);
|
|
|
|
|
|
|
|
|
|
frameLayout.setOnSizeChangedListener(new AspectRatioFrameLayout.OnSizeChangeListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onSizeChanged(int width, int height) {
|
|
|
|
|
Log.i("OSD", "width=" + Integer.toString(width));
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
frameLayout.setAspectRatio((float)mVideoWidth / (float)mVideoHeight);
|
|
|
|
|
|
|
|
|
|
mTimeMask = 0;
|
|
|
|
@ -298,6 +309,7 @@ public class Camera2VideoActivity extends AppCompatActivity {
|
|
|
|
|
@Override
|
|
|
|
|
protected void onResume() {
|
|
|
|
|
super.onResume();
|
|
|
|
|
Log.i("OSD", "onResume");
|
|
|
|
|
mHandler.postDelayed(new Runnable() {
|
|
|
|
|
@Override
|
|
|
|
|
public void run() {
|
|
|
|
@ -318,7 +330,16 @@ public class Camera2VideoActivity extends AppCompatActivity {
|
|
|
|
|
@Override
|
|
|
|
|
protected void onStop() {
|
|
|
|
|
super.onStop();
|
|
|
|
|
|
|
|
|
|
Log.i("OSD", "onStop");
|
|
|
|
|
// releaseCamera();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
protected void onDestroy() {
|
|
|
|
|
Log.i("OSD", "onDestroy");
|
|
|
|
|
releaseCamera();
|
|
|
|
|
super.onDestroy();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void initOSD(Bitmap bm, long ts) {
|
|
|
|
@ -602,7 +623,7 @@ public class Camera2VideoActivity extends AppCompatActivity {
|
|
|
|
|
|
|
|
|
|
runOnUiThread(() -> {
|
|
|
|
|
|
|
|
|
|
AspectRatioFrameLayout frameLayout = (AspectRatioFrameLayout)findViewById(R.id.wrap_view);
|
|
|
|
|
final AspectRatioFrameLayout frameLayout = (AspectRatioFrameLayout)findViewById(R.id.wrap_view);
|
|
|
|
|
frameLayout.removeAllViews();
|
|
|
|
|
|
|
|
|
|
mPreviewView = null;
|
|
|
|
@ -612,8 +633,41 @@ public class Camera2VideoActivity extends AppCompatActivity {
|
|
|
|
|
mGPUCameraRecorder.changeManualFocusPoint(event.getX(), event.getY(), width, height);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
mPreviewView.getHolder().addCallback(new SurfaceHolder.Callback() {
|
|
|
|
|
@Override
|
|
|
|
|
public void surfaceCreated(@NonNull SurfaceHolder holder) {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void surfaceChanged(@NonNull SurfaceHolder holder, int format, int width, int height) {
|
|
|
|
|
if (width > 0 && height > 0) {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void surfaceDestroyed(@NonNull SurfaceHolder holder) {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
frameLayout.addView(mPreviewView);
|
|
|
|
|
|
|
|
|
|
frameLayout.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int width = right - left;
|
|
|
|
|
int height = bottom - top;
|
|
|
|
|
|
|
|
|
|
if (width <= 0 || height <= 0) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
frameLayout.removeOnLayoutChangeListener(this);
|
|
|
|
|
|
|
|
|
|
if (!TextUtils.isEmpty(mOSDLeftTop) || !TextUtils.isEmpty(mOSDLeftTop) || !TextUtils.isEmpty(mOSDLeftTop) || !TextUtils.isEmpty(mOSDLeftTop)) {
|
|
|
|
|
mPreviewWidth = frameLayout.getMeasuredWidth();
|
|
|
|
|
mPreviewHeight = frameLayout.getMeasuredHeight();
|
|
|
|
@ -646,6 +700,12 @@ public class Camera2VideoActivity extends AppCompatActivity {
|
|
|
|
|
|
|
|
|
|
mOsdThread.start();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|