Skip to content

Instantly share code, notes, and snippets.

@keivanh
Created May 2, 2020 21:16
Show Gist options
  • Save keivanh/2d4309f5fa88dc520264c21cd10bbb43 to your computer and use it in GitHub Desktop.
Save keivanh/2d4309f5fa88dc520264c21cd10bbb43 to your computer and use it in GitHub Desktop.
public class foo{
private DJICodecManager.YuvDataCallback frameListener;
private DJICodecManager codecManager = null;
private void createCodecManager(){
frameListener = new DJICodecManager.YuvDataCallback() {
@Override
public void onYuvDataReceived(MediaFormat mediaFormat, ByteBuffer byteBuffer, int i, int i1, int i2) {
// You have your frame byteBuffer here (it is indirect buffer)
// To get bitmap you have to decode YUV frame
}
}
// mContext is activity or application context, you should pass it here somehow (I use the constructor)
// Ignore DJIYVUWidth and DJIYVUHeight, whatever you pass SDK ignores it!
codecManager = new DJICodecManager(mContext, null, DJIYVUWidth, DJIYVUHeight, UsbAccessoryService.VideoStreamSource.Camera);
codecManager.enabledYuvData(true);
codecManager.setYuvDataCallback(frameListener);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment