像这样初始化视频回调
mReceivedVideoDataCallBack = new DJICamera.CameraReceivedVideoDataCallback() {
@Override
public void onResult(byte[] videoBuffer, int size) {
if(mCodecManager != null){
mCodecManager.sendDataToDecoder(videoBuffer, size);
}else {
Log.e(TAG, "mCodecManager is null");
}
}
}
让您的活动实现TextureView.SurfaceTextureListener,并在TextureView mVideoSurface初始化后调用此行:
mVideoSurface.setSurfaceTextureListener(this)
然后实现:
@Override
public void onSurfaceTextureAvailable(SurfaceTexture surface, int width, int height) {
Log.v(TAG, "onSurfaceTextureAvailable");
DJICamera camera = FPVDemoApplication.getCameraInstance();
if (mCodecManager == null && surface != null && camera != null) {
mCodecManager = new DJICodecManager(this, surface, width, height);
Log.v(TAG, "Initialized CodecManager");
}
}
@Override
public void onSurfaceTextureSizeChanged(SurfaceTexture surface, int width, int height) {
Log.v(TAG, "onSurfaceTextureSizeChanged");
}
@Override
public boolean onSurfaceTextureDestroyed(SurfaceTexture surface) {
Log.v(TAG, "onSurfaceTextureDestroyed");
if (mCodecManager != null) {
mCodecManager.cleanSurface();
mCodecManager = null;
}
return false;
}
@Override
public void onSurfaceTextureUpdated(SurfaceTexture surface) {
final Bitmap image = mVideoSurface.getBitmap();
}
希望这有帮助!