像这样初始化视频回调
mReceivedVideoDataCallBack = new DJICamera.CameraReceivedVideoDataCallback() {
@Override
public void onResult(byte[] videoBuffer, int size) {
if(mCodecManager != null){
// Send the raw H264 video data to codec manager for decoding
mCodecManager.sendDataToDecoder(videoBuffer, size);
}else {
Log.e(TAG, “mCodecManager is null”);
}
}
}
</code>
让您的活动实现TextureView.SurfaceTextureListener
并且对于TextureView mVideoSurface在初始化之后调用此行:
mVideoSurface.setSurfaceTextureListener(this);
</code>
然后实施:
@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) {
//Normal init for the surface
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();
//Do whatever you want with the bitmap image here on every frame
}
</code>
希望这可以帮助!