Skip to content

Commit c0f8da8

Browse files
author
daniel.chen
committed
update 4.15.1
1 parent b0611c5 commit c0f8da8

File tree

3 files changed

+56
-18
lines changed

3 files changed

+56
-18
lines changed

android-videostreamdecodingsample/app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ android {
8080
dependencies {
8181
implementation 'androidx.multidex:multidex:2.0.0'
8282
implementation 'com.squareup:otto:1.3.8'
83-
implementation('com.dji:dji-sdk:4.14-trial1', {
83+
implementation('com.dji:dji-sdk:4.15.1', {
8484
/**
8585
* Uncomment the "library-anti-distortion" if your app does not need Anti Distortion for Mavic 2 Pro and Mavic 2 Zoom.
8686
* Uncomment the "fly-safe-database" if you need database for release, or we will download it when DJISDKManager.getInstance().registerApp
@@ -90,7 +90,7 @@ dependencies {
9090
exclude module: 'library-anti-distortion'
9191
//exclude module: 'fly-safe-database'
9292
})
93-
compileOnly 'com.dji:dji-sdk-provided:4.14-trial1'
93+
compileOnly 'com.dji:dji-sdk-provided:4.15.1'
9494

9595
implementation 'androidx.appcompat:appcompat:1.0.0'
9696
implementation 'androidx.core:core:1.0.0'

android-videostreamdecodingsample/app/src/main/java/com/dji/videostreamdecodingsample/MainActivity.java

Lines changed: 37 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -277,14 +277,27 @@ public void onReceive(byte[] videoBuffer, int size) {
277277
} else {
278278
if (!product.getModel().equals(Model.UNKNOWN_AIRCRAFT)) {
279279
mCamera = product.getCamera();
280-
mCamera.setMode(SettingsDefinitions.CameraMode.SHOOT_PHOTO, new CommonCallbacks.CompletionCallback() {
281-
@Override
282-
public void onResult(DJIError djiError) {
283-
if (djiError != null) {
284-
showToast("can't change mode of camera, error:"+djiError.getDescription());
285-
}
280+
if (mCamera != null) {
281+
if (mCamera.isFlatCameraModeSupported()) {
282+
mCamera.setFlatMode(SettingsDefinitions.FlatCameraMode.PHOTO_SINGLE, new CommonCallbacks.CompletionCallback() {
283+
@Override
284+
public void onResult(DJIError djiError) {
285+
if(djiError!=null){
286+
showToast("can't change flat mode of camera, error:" + djiError.getDescription());
287+
}
288+
}
289+
});
290+
} else {
291+
mCamera.setMode(SettingsDefinitions.CameraMode.SHOOT_PHOTO, new CommonCallbacks.CompletionCallback() {
292+
@Override
293+
public void onResult(DJIError djiError) {
294+
if (djiError != null) {
295+
showToast("can't change mode of camera, error:" + djiError.getDescription());
296+
}
297+
}
298+
});
286299
}
287-
});
300+
}
288301

289302
//When calibration is needed or the fetch key frame is required by SDK, should use the provideTranscodedVideoFeed
290303
//to receive the transcoded video feed from main camera.
@@ -493,7 +506,11 @@ private void oldSaveYuvDataToJPEG(byte[] yuvFrame, int width, int height){
493506
+ DJIVideoStreamDecoder.getInstance().frameIndex
494507
+ ",array length: "
495508
+ bytes.length);
496-
screenShot(bytes, Environment.getExternalStorageDirectory() + "/DJI_ScreenShot", width, height);
509+
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.P) {
510+
screenShot(bytes, getApplicationContext().getExternalFilesDir("DJI").getPath() + "/DJI_ScreenShot", width, height);
511+
} else {
512+
screenShot(bytes, Environment.getExternalStorageDirectory() + "/DJI_ScreenShot", width, height);
513+
}
497514
}
498515

499516
private void newSaveYuvDataToJPEG(byte[] yuvFrame, int width, int height){
@@ -513,7 +530,12 @@ private void newSaveYuvDataToJPEG(byte[] yuvFrame, int width, int height){
513530
yuvFrame[length + 2 * i] = u[i];
514531
yuvFrame[length + 2 * i + 1] = v[i];
515532
}
516-
screenShot(yuvFrame,Environment.getExternalStorageDirectory() + "/DJI_ScreenShot", width, height);
533+
534+
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.P) {
535+
screenShot(yuvFrame, getApplicationContext().getExternalFilesDir("DJI").getPath() + "/DJI_ScreenShot", width, height);
536+
} else {
537+
screenShot(yuvFrame, Environment.getExternalStorageDirectory() + "/DJI_ScreenShot", width, height);
538+
}
517539
}
518540

519541
private void newSaveYuvDataToJPEG420P(byte[] yuvFrame, int width, int height) {
@@ -533,7 +555,12 @@ private void newSaveYuvDataToJPEG420P(byte[] yuvFrame, int width, int height) {
533555
yuvFrame[length + 2 * i] = v[i];
534556
yuvFrame[length + 2 * i + 1] = u[i];
535557
}
536-
screenShot(yuvFrame, Environment.getExternalStorageDirectory() + "/DJI_ScreenShot", width, height);
558+
559+
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.P) {
560+
screenShot(yuvFrame, getApplicationContext().getExternalFilesDir("DJI").getPath() + "/DJI_ScreenShot", width, height);
561+
} else {
562+
screenShot(yuvFrame, Environment.getExternalStorageDirectory() + "/DJI_ScreenShot", width, height);
563+
}
537564
}
538565

539566
/**

android-videostreamdecodingsample/app/src/main/java/com/dji/videostreamdecodingsample/media/DJIVideoStreamDecoder.java

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,21 @@
1313
import android.view.Surface;
1414

1515
import com.dji.videostreamdecodingsample.R;
16-
import dji.common.product.Model;
17-
import dji.log.DJILog;
18-
import dji.midware.data.model.P3.DataCameraGetPushStateInfo;
19-
import dji.sdk.codec.DJICodecManager;
20-
import dji.sdk.products.Aircraft;
21-
import dji.sdk.sdkmanager.DJISDKManager;
16+
2217
import java.io.IOException;
2318
import java.io.InputStream;
2419
import java.nio.ByteBuffer;
2520
import java.util.LinkedList;
2621
import java.util.Queue;
2722
import java.util.concurrent.ArrayBlockingQueue;
2823

24+
import dji.common.product.Model;
25+
import dji.log.DJILog;
26+
import dji.midware.data.model.P3.DataCameraGetPushStateInfo;
2927
import dji.sdk.base.BaseProduct;
28+
import dji.sdk.codec.DJICodecManager;
29+
import dji.sdk.products.Aircraft;
30+
import dji.sdk.sdkmanager.DJISDKManager;
3031

3132
/**
3233
* This class is a helper class for hardware decoding. Please follow the following steps to use it:
@@ -474,6 +475,16 @@ public int getIframeRawId(Model pModel, int width) {
474475
iframeId = -1;
475476
}
476477
break;
478+
479+
case MAVIC_AIR_2:
480+
break;
481+
case MAVIC_2_ENTERPRISE:
482+
case MAVIC_2_ENTERPRISE_DUAL:
483+
iframeId = dji.midware.R.raw.iframe_1280x720_wm220;
484+
break;
485+
case MAVIC_2_ENTERPRISE_ADVANCED:
486+
break;
487+
477488
default: //for P3P, Inspire1, etc/
478489
iframeId = R.raw.iframe_1280x720_ins;
479490
break;

0 commit comments

Comments
 (0)