|
|
@ -9,7 +9,9 @@ import android.graphics.Bitmap; |
|
|
|
import android.hardware.Camera; |
|
|
|
import android.hardware.Camera; |
|
|
|
import android.os.Bundle; |
|
|
|
import android.os.Bundle; |
|
|
|
import android.os.Environment; |
|
|
|
import android.os.Environment; |
|
|
|
|
|
|
|
|
|
|
|
import androidx.annotation.NonNull; |
|
|
|
import androidx.annotation.NonNull; |
|
|
|
|
|
|
|
|
|
|
|
import android.util.Log; |
|
|
|
import android.util.Log; |
|
|
|
import android.view.Surface; |
|
|
|
import android.view.Surface; |
|
|
|
import android.view.SurfaceHolder; |
|
|
|
import android.view.SurfaceHolder; |
|
|
@ -33,34 +35,42 @@ import java.io.IOException; |
|
|
|
import java.nio.ByteBuffer; |
|
|
|
import java.nio.ByteBuffer; |
|
|
|
|
|
|
|
|
|
|
|
public class PushActivity extends Activity implements Callback { |
|
|
|
public class PushActivity extends Activity implements Callback { |
|
|
|
private static String TAG = PushActivity.class.getSimpleName(); |
|
|
|
private static String TAG = PushActivity.class.getSimpleName(); |
|
|
|
|
|
|
|
|
|
|
|
private SmartCameraView mSmartCameraView; |
|
|
|
private SmartCameraView mSmartCameraView; |
|
|
|
|
|
|
|
|
|
|
|
// MagicFilterType magicType = MagicFilterType.SUNRISE;
|
|
|
|
// MagicFilterType magicType = MagicFilterType.SUNRISE;
|
|
|
|
|
|
|
|
|
|
|
|
private Button btnMute; |
|
|
|
private Button btnMute; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private boolean isStart = false; |
|
|
|
|
|
|
|
|
|
|
|
private boolean isStart = false; |
|
|
|
private boolean is_mute = false; |
|
|
|
|
|
|
|
|
|
|
|
private boolean is_mute = false; |
|
|
|
private int mDegree; |
|
|
|
|
|
|
|
|
|
|
|
private int mDegree; |
|
|
|
private Spinner beautyTypeSelector; |
|
|
|
|
|
|
|
|
|
|
|
private Spinner beautyTypeSelector; |
|
|
|
private ImageView img_photo; |
|
|
|
|
|
|
|
|
|
|
|
private ImageView img_photo; |
|
|
|
private boolean takePhoto; |
|
|
|
//拍照
|
|
|
|
|
|
|
|
private boolean takePhoto; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private final static int videoWidth = 640; |
|
|
|
private final static int videoWidth = 640; |
|
|
|
private final static int videoHeight = 360; |
|
|
|
private final static int videoHeight = 360; |
|
|
|
private final static String[] permissions = new String[]{Manifest.permission.CAMERA}; |
|
|
|
private final static String[] permissions = new String[]{Manifest.permission.CAMERA}; |
|
|
|
private final static int CODE_CAMERA = 1001; |
|
|
|
private final static int CODE_CAMERA = 1001; |
|
|
|
|
|
|
|
|
|
|
|
private final static String[] beautySelector = new String[]{"美颜", "冷酷", "日出","素描","白猫", "浪漫", "原图"}; |
|
|
|
private final static String[] beautySelector = new String[]{ |
|
|
|
|
|
|
|
LiveApplication.getInstance().getString(R.string.effect_beauty), |
|
|
|
|
|
|
|
LiveApplication.getInstance().getString(R.string.effect_cool), |
|
|
|
|
|
|
|
LiveApplication.getInstance().getString(R.string.effect_sunrise), |
|
|
|
|
|
|
|
LiveApplication.getInstance().getString(R.string.effect_sketch), |
|
|
|
|
|
|
|
LiveApplication.getInstance().getString(R.string.effect_white), |
|
|
|
|
|
|
|
LiveApplication.getInstance().getString(R.string.effect_romantic), |
|
|
|
|
|
|
|
LiveApplication.getInstance().getString(R.string.effect_raw) |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void onCreate(Bundle savedInstanceState) { |
|
|
|
public void onCreate(Bundle savedInstanceState) { |
|
|
|
|
|
|
|
|
|
|
|
super.onCreate(savedInstanceState); |
|
|
|
super.onCreate(savedInstanceState); |
|
|
@ -71,239 +81,228 @@ public class PushActivity extends Activity implements Callback { |
|
|
|
|
|
|
|
|
|
|
|
setContentView(R.layout.activity_push); |
|
|
|
setContentView(R.layout.activity_push); |
|
|
|
|
|
|
|
|
|
|
|
initView(); |
|
|
|
initView(); |
|
|
|
initListener(); |
|
|
|
initListener(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@TargetApi(23) |
|
|
|
|
|
|
|
private void requestPermissions() { |
|
|
|
|
|
|
|
requestPermissions(permissions, CODE_CAMERA); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@TargetApi(23) |
|
|
|
private void initView() { |
|
|
|
private void requestPermissions(){ |
|
|
|
//SurfaceView
|
|
|
|
requestPermissions(permissions, CODE_CAMERA); |
|
|
|
mSmartCameraView = findViewById(R.id.gl_surfaceview); |
|
|
|
} |
|
|
|
//beauty type
|
|
|
|
|
|
|
|
beautyTypeSelector = findViewById(R.id.beauty_type_selctor); |
|
|
|
private void initView(){ |
|
|
|
//mute
|
|
|
|
//SurfaceView
|
|
|
|
btnMute = findViewById(R.id.button_mute); |
|
|
|
mSmartCameraView = findViewById(R.id.gl_surfaceview); |
|
|
|
//take photo
|
|
|
|
//美颜类型
|
|
|
|
img_photo = findViewById(R.id.img_photo); |
|
|
|
beautyTypeSelector = findViewById(R.id.beauty_type_selctor); |
|
|
|
} |
|
|
|
//静音
|
|
|
|
|
|
|
|
btnMute = findViewById(R.id.button_mute); |
|
|
|
private void initListener() { |
|
|
|
//拍照
|
|
|
|
|
|
|
|
img_photo = findViewById(R.id.img_photo); |
|
|
|
ArrayAdapter<String> adapterBeautyType = new ArrayAdapter<>(this, |
|
|
|
} |
|
|
|
android.R.layout.simple_spinner_item, beautySelector); |
|
|
|
|
|
|
|
adapterBeautyType.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); |
|
|
|
private void initListener(){ |
|
|
|
beautyTypeSelector.setAdapter(adapterBeautyType); |
|
|
|
|
|
|
|
beautyTypeSelector.setOnItemSelectedListener(new OnItemSelectedListener() { |
|
|
|
ArrayAdapter<String> adapterBeautyType = new ArrayAdapter<>(this, |
|
|
|
@Override |
|
|
|
android.R.layout.simple_spinner_item, beautySelector); |
|
|
|
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { |
|
|
|
adapterBeautyType.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); |
|
|
|
|
|
|
|
beautyTypeSelector.setAdapter(adapterBeautyType); |
|
|
|
switch (position) { |
|
|
|
beautyTypeSelector.setOnItemSelectedListener(new OnItemSelectedListener() { |
|
|
|
case 0: |
|
|
|
@Override |
|
|
|
switchCameraFilter(MagicFilterType.BEAUTY); |
|
|
|
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { |
|
|
|
break; |
|
|
|
|
|
|
|
case 1: |
|
|
|
switch (position){ |
|
|
|
switchCameraFilter(MagicFilterType.COOL); |
|
|
|
case 0: |
|
|
|
break; |
|
|
|
switchCameraFilter(MagicFilterType.BEAUTY); |
|
|
|
case 2: |
|
|
|
break; |
|
|
|
switchCameraFilter(MagicFilterType.SUNRISE); |
|
|
|
case 1: |
|
|
|
break; |
|
|
|
switchCameraFilter(MagicFilterType.COOL); |
|
|
|
case 3: |
|
|
|
break; |
|
|
|
switchCameraFilter(MagicFilterType.SKETCH); |
|
|
|
case 2: |
|
|
|
break; |
|
|
|
switchCameraFilter(MagicFilterType.SUNRISE); |
|
|
|
case 4: |
|
|
|
break; |
|
|
|
switchCameraFilter(MagicFilterType.WHITECAT); |
|
|
|
case 3: |
|
|
|
break; |
|
|
|
switchCameraFilter(MagicFilterType.SKETCH); |
|
|
|
case 5: |
|
|
|
break; |
|
|
|
switchCameraFilter(MagicFilterType.ROMANCE); |
|
|
|
case 4: |
|
|
|
break; |
|
|
|
switchCameraFilter(MagicFilterType.WHITECAT); |
|
|
|
default: |
|
|
|
break; |
|
|
|
switchCameraFilter(MagicFilterType.NONE); |
|
|
|
case 5: |
|
|
|
break; |
|
|
|
switchCameraFilter(MagicFilterType.ROMANCE); |
|
|
|
} |
|
|
|
break; |
|
|
|
} |
|
|
|
default: |
|
|
|
|
|
|
|
switchCameraFilter(MagicFilterType.NONE); |
|
|
|
@Override |
|
|
|
break; |
|
|
|
public void onNothingSelected(AdapterView<?> parent) { |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
@Override |
|
|
|
}); |
|
|
|
public void onNothingSelected(AdapterView<?> parent) { |
|
|
|
|
|
|
|
|
|
|
|
btnMute.setOnClickListener(new OnClickListener() { |
|
|
|
} |
|
|
|
@Override |
|
|
|
}); |
|
|
|
public void onClick(View view) { |
|
|
|
|
|
|
|
is_mute = !is_mute; |
|
|
|
btnMute.setOnClickListener(new OnClickListener() { |
|
|
|
|
|
|
|
@Override |
|
|
|
if (is_mute) { |
|
|
|
public void onClick(View view) { |
|
|
|
btnMute.setText(getString(R.string.voice)); |
|
|
|
is_mute = !is_mute; |
|
|
|
} else { |
|
|
|
|
|
|
|
btnMute.setText(getString(R.string.mute)); |
|
|
|
if ( is_mute ) |
|
|
|
} |
|
|
|
btnMute.setText("取消静音"); |
|
|
|
} |
|
|
|
else |
|
|
|
}); |
|
|
|
btnMute.setText("静音"); |
|
|
|
|
|
|
|
} |
|
|
|
//preview data callback(RGBA)
|
|
|
|
}); |
|
|
|
mSmartCameraView.setPreviewCallback(new SmartCameraView.PreviewCallback() { |
|
|
|
|
|
|
|
@Override |
|
|
|
//预览数据回调(RGBA格式)
|
|
|
|
public void onGetRgbaFrame(byte[] data, int width, int height) { |
|
|
|
mSmartCameraView.setPreviewCallback(new SmartCameraView.PreviewCallback() { |
|
|
|
|
|
|
|
@Override |
|
|
|
if (takePhoto) { |
|
|
|
public void onGetRgbaFrame(byte[] data, int width, int height) { |
|
|
|
takePhoto = false; |
|
|
|
|
|
|
|
Log.i(TAG, "takePhoto..."); |
|
|
|
if(takePhoto){ |
|
|
|
doTakePhoto(data, width, height); |
|
|
|
takePhoto = false; |
|
|
|
} |
|
|
|
Log.i(TAG, "takePhoto..."); |
|
|
|
|
|
|
|
doTakePhoto(data, width, height); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
img_photo.setOnClickListener(new OnClickListener() { |
|
|
|
}); |
|
|
|
@Override |
|
|
|
|
|
|
|
public void onClick(View view) { |
|
|
|
img_photo.setOnClickListener(new OnClickListener() { |
|
|
|
takePhoto = true; |
|
|
|
@Override |
|
|
|
} |
|
|
|
public void onClick(View view) { |
|
|
|
}); |
|
|
|
takePhoto = true; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
private void switchCameraFilter(MagicFilterType type) { |
|
|
|
} |
|
|
|
mSmartCameraView.setFilter(type); |
|
|
|
|
|
|
|
} |
|
|
|
private void switchCameraFilter(MagicFilterType type) { |
|
|
|
|
|
|
|
mSmartCameraView.setFilter(type); |
|
|
|
/** |
|
|
|
} |
|
|
|
* take photo |
|
|
|
|
|
|
|
* |
|
|
|
/** |
|
|
|
* @param data preview data |
|
|
|
* 拍照 |
|
|
|
* @param width the width of photo |
|
|
|
* @param data 预览数据 |
|
|
|
* @param height the height of photo |
|
|
|
* @param width 图片宽度 |
|
|
|
*/ |
|
|
|
* @param height 图片高度 |
|
|
|
private void doTakePhoto(byte[] data, int width, int height) { |
|
|
|
*/ |
|
|
|
Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); |
|
|
|
private void doTakePhoto(byte[] data, int width, int height){ |
|
|
|
ByteBuffer buffer = ByteBuffer.wrap(data); |
|
|
|
Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); |
|
|
|
bitmap.copyPixelsFromBuffer(buffer); |
|
|
|
ByteBuffer buffer = ByteBuffer.wrap(data); |
|
|
|
|
|
|
|
bitmap.copyPixelsFromBuffer(buffer); |
|
|
|
Log.i(TAG, "doTakePhoto..."); |
|
|
|
|
|
|
|
FileOutputStream fileOutputStream = null; |
|
|
|
Log.i(TAG, "doTakePhoto..."); |
|
|
|
String PATH = Environment.getExternalStorageDirectory().getPath(); |
|
|
|
FileOutputStream fileOutputStream = null; |
|
|
|
String filePath = PATH + File.separator + "hello" + ".jpg"; |
|
|
|
String PATH = Environment.getExternalStorageDirectory().getPath(); |
|
|
|
|
|
|
|
String filePath = PATH + File.separator + "hello_openGL" + ".jpg"; |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
fileOutputStream = new FileOutputStream(filePath); |
|
|
|
|
|
|
|
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, fileOutputStream); |
|
|
|
|
|
|
|
fileOutputStream.flush(); |
|
|
|
|
|
|
|
} catch (IOException e) { |
|
|
|
|
|
|
|
e.printStackTrace(); |
|
|
|
|
|
|
|
Log.e(TAG, "doTakePhoto error=" + e.toString()); |
|
|
|
|
|
|
|
}finally { |
|
|
|
|
|
|
|
if(fileOutputStream != null){ |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
fileOutputStream.close(); |
|
|
|
|
|
|
|
} catch (IOException e) { |
|
|
|
|
|
|
|
e.printStackTrace(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void surfaceCreated(SurfaceHolder holder) { |
|
|
|
|
|
|
|
Log.i(TAG, "surfaceCreated.."); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { |
|
|
|
|
|
|
|
Log.i(TAG, "surfaceChanged.."); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void surfaceDestroyed(SurfaceHolder holder) { |
|
|
|
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
|
|
|
|
Log.i(TAG, "Surface Destroyed"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void onConfigurationChanged(Configuration newConfig) { |
|
|
|
|
|
|
|
try { |
|
|
|
try { |
|
|
|
super.onConfigurationChanged(newConfig); |
|
|
|
fileOutputStream = new FileOutputStream(filePath); |
|
|
|
Log.i(TAG, "onConfigurationChanged, start:" + isStart); |
|
|
|
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, fileOutputStream); |
|
|
|
|
|
|
|
fileOutputStream.flush(); |
|
|
|
|
|
|
|
} catch (IOException e) { |
|
|
|
|
|
|
|
e.printStackTrace(); |
|
|
|
|
|
|
|
Log.e(TAG, "doTakePhoto error=" + e.toString()); |
|
|
|
|
|
|
|
} finally { |
|
|
|
|
|
|
|
if (fileOutputStream != null) { |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
fileOutputStream.close(); |
|
|
|
|
|
|
|
} catch (IOException e) { |
|
|
|
|
|
|
|
e.printStackTrace(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void surfaceCreated(SurfaceHolder holder) { |
|
|
|
|
|
|
|
Log.i(TAG, "surfaceCreated.."); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
setCameraDisplayOrientation(this, getCameraId()); |
|
|
|
@Override |
|
|
|
|
|
|
|
public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { |
|
|
|
|
|
|
|
Log.i(TAG, "surfaceChanged.."); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
mSmartCameraView.setPreviewOrientation(newConfig.orientation, mDegree); |
|
|
|
@Override |
|
|
|
|
|
|
|
public void surfaceDestroyed(SurfaceHolder holder) { |
|
|
|
|
|
|
|
Log.i(TAG, "Surface Destroyed"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void onConfigurationChanged(Configuration newConfig) { |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
super.onConfigurationChanged(newConfig); |
|
|
|
|
|
|
|
Log.i(TAG, "onConfigurationChanged, start:" + isStart); |
|
|
|
|
|
|
|
setCameraDisplayOrientation(this, getCameraId()); |
|
|
|
|
|
|
|
mSmartCameraView.setPreviewOrientation(newConfig.orientation, mDegree); |
|
|
|
} catch (Exception ex) { |
|
|
|
} catch (Exception ex) { |
|
|
|
Log.e(TAG, "error="+ex.toString()); |
|
|
|
Log.e(TAG, "error=" + ex.toString()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private int getCameraId() { |
|
|
|
private int getCameraId() { |
|
|
|
return mSmartCameraView.getCameraId(); |
|
|
|
return mSmartCameraView.getCameraId(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void setPreviewResolution(int width, int height) { |
|
|
|
public void setPreviewResolution(int width, int height) { |
|
|
|
mSmartCameraView.setPreviewResolution(width, height); |
|
|
|
mSmartCameraView.setPreviewResolution(width, height); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void setCameraDisplayOrientation (Activity activity, int cameraId) { |
|
|
|
private void setCameraDisplayOrientation(Activity activity, int cameraId) { |
|
|
|
Camera.CameraInfo info = new Camera.CameraInfo(); |
|
|
|
Camera.CameraInfo info = new Camera.CameraInfo(); |
|
|
|
Camera.getCameraInfo (cameraId , info); |
|
|
|
Camera.getCameraInfo(cameraId, info); |
|
|
|
int rotation = activity.getWindowManager ().getDefaultDisplay ().getRotation (); |
|
|
|
int rotation = activity.getWindowManager().getDefaultDisplay().getRotation(); |
|
|
|
int degrees = 0; |
|
|
|
int degrees = 0; |
|
|
|
switch (rotation) { |
|
|
|
switch (rotation) { |
|
|
|
case Surface.ROTATION_0: |
|
|
|
case Surface.ROTATION_0: |
|
|
|
degrees = 0; |
|
|
|
degrees = 0; |
|
|
|
break; |
|
|
|
break; |
|
|
|
case Surface.ROTATION_90: |
|
|
|
case Surface.ROTATION_90: |
|
|
|
degrees = 90; |
|
|
|
degrees = 90; |
|
|
|
break; |
|
|
|
break; |
|
|
|
case Surface.ROTATION_180: |
|
|
|
case Surface.ROTATION_180: |
|
|
|
degrees = 180; |
|
|
|
degrees = 180; |
|
|
|
break; |
|
|
|
break; |
|
|
|
case Surface.ROTATION_270: |
|
|
|
case Surface.ROTATION_270: |
|
|
|
degrees = 270; |
|
|
|
degrees = 270; |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
int result; |
|
|
|
int result; |
|
|
|
if (info.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) { |
|
|
|
if (info.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) { |
|
|
|
result = (info.orientation + degrees) % 360; |
|
|
|
result = (info.orientation + degrees) % 360; |
|
|
|
result = (360 - result) % 360; |
|
|
|
result = (360 - result) % 360; |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
// back-facing
|
|
|
|
// back-facing
|
|
|
|
result = ( info.orientation - degrees + 360) % 360; |
|
|
|
result = (info.orientation - degrees + 360) % 360; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
Log.i(TAG, "curDegree: " + result); |
|
|
|
Log.i(TAG, "curDegree: "+ result); |
|
|
|
mDegree = result; |
|
|
|
|
|
|
|
} |
|
|
|
mDegree = result; |
|
|
|
|
|
|
|
} |
|
|
|
@Override |
|
|
|
|
|
|
|
protected void onDestroy() { |
|
|
|
@Override |
|
|
|
if (isStart) { |
|
|
|
protected void onDestroy(){ |
|
|
|
isStart = false; |
|
|
|
|
|
|
|
if (mSmartCameraView != null) { |
|
|
|
if ( isStart ) { |
|
|
|
mSmartCameraView.stopCamera(); |
|
|
|
isStart = false; |
|
|
|
} |
|
|
|
if(mSmartCameraView != null) |
|
|
|
Log.i(TAG, "onDestroy StopPublish"); |
|
|
|
{ |
|
|
|
} |
|
|
|
mSmartCameraView.stopCamera(); |
|
|
|
super.onDestroy(); |
|
|
|
} |
|
|
|
finish(); |
|
|
|
|
|
|
|
} |
|
|
|
Log.i(TAG, "onDestroy StopPublish"); |
|
|
|
|
|
|
|
} |
|
|
|
@Override |
|
|
|
|
|
|
|
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { |
|
|
|
super.onDestroy(); |
|
|
|
super.onRequestPermissionsResult(requestCode, permissions, grantResults); |
|
|
|
finish(); |
|
|
|
if (permissions.length > 0 && grantResults.length > 0) { |
|
|
|
System.exit(0); |
|
|
|
setPreviewResolution(videoWidth, videoHeight); |
|
|
|
} |
|
|
|
if (!mSmartCameraView.startCamera()) { |
|
|
|
|
|
|
|
Log.e(TAG, "startCamera error..."); |
|
|
|
@Override |
|
|
|
} |
|
|
|
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { |
|
|
|
} |
|
|
|
super.onRequestPermissionsResult(requestCode, permissions, grantResults); |
|
|
|
} |
|
|
|
if(permissions.length > 0 && grantResults.length > 0){ |
|
|
|
|
|
|
|
Log.i(TAG, "permission=" + permissions[0] + "----grantResult=" + grantResults[0]); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
setPreviewResolution(videoWidth, videoHeight); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!mSmartCameraView.startCamera()) { |
|
|
|
|
|
|
|
Log.e(TAG, "startCamera error..."); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |