Skip to content

Commit b0611c5

Browse files
committed
fix m300rtk bug
1 parent 77318cc commit b0611c5

File tree

5 files changed

+70
-39
lines changed

5 files changed

+70
-39
lines changed

.gitignore

Lines changed: 27 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,45 @@
1-
# built application files
1+
# Built application files
22
*.apk
33
*.ap_
44

5-
# files for the dex VM
5+
# Files for the ART/Dalvik VM
66
*.dex
77

88
# Java class files
99
*.class
1010

11+
# Generated files
12+
bin/
13+
gen/
14+
out/
15+
1116
# Gradle files
12-
android-videostreamdecodingsample/.gradle/
13-
android-videostreamdecodingsample/gradle/
14-
android-videostreamdecodingsample/build/
15-
android-videostreamdecodingsample/gradlew
16-
android-videostreamdecodingsample/gradlew.bat
17-
18-
# generated files
19-
20-
/bin
21-
/gen
22-
/obj
23-
/build
17+
.gradle/
18+
gradle/
19+
build/
20+
2421
# Local configuration file (sdk path, etc)
2522
local.properties
26-
project.properties
27-
28-
# Eclipse project files
29-
.classpath
30-
.cproject
3123

3224
# Proguard folder generated by Eclipse
3325
proguard/
3426

35-
# Intellij project files
36-
*.ipr
37-
*.iws
38-
.idea/
27+
# Log Files
28+
*.log
29+
30+
# Android Studio Navigation editor temp files
31+
.navigation/
32+
33+
# Android Studio captures folder
34+
captures/
35+
36+
# Intellij
3937
*.iml
38+
.idea/
39+
.idea/*
40+
.idea/libraries
4041

41-
#ant relative files
42-
#build.xml
43-
ant.properties
42+
# Keystore files
43+
*.jks
4444

45-
#backup files
46-
*.bak
45+
.DS_Store

android-videostreamdecodingsample/app/build.gradle

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,19 @@ repositories {
55
}
66

77
android {
8-
compileSdkVersion 28
9-
buildToolsVersion '28.0.3'
8+
compileSdkVersion 29
9+
buildToolsVersion '29.0.3'
1010
useLibrary 'org.apache.http.legacy'
1111

1212
defaultConfig {
1313
applicationId "com.dji.videostreamdecodingsample"
14-
minSdkVersion 16
15-
targetSdkVersion 28
14+
minSdkVersion 19
15+
targetSdkVersion 29
1616
multiDexEnabled true
1717
ndk {
1818
// On x86 devices that run Android API 23 or above, if the application is targeted with API 23 or
1919
// above, FFmpeg lib might lead to runtime crashes or warnings.
20-
abiFilters 'armeabi-v7a', 'x86', 'arm64-v8a'
20+
abiFilters 'armeabi-v7a', 'arm64-v8a'
2121
}
2222
}
2323

@@ -61,7 +61,13 @@ android {
6161
doNotStrip "*/*/libDJICSDKCommon.so"
6262
doNotStrip "*/*/libDJIUpgradeCore.so"
6363
doNotStrip "*/*/libDJIUpgradeJNI.so"
64+
doNotStrip "*/*/libDJIWaypointV2Core.so"
65+
doNotStrip "*/*/libAMapSDK_MAP_v6_9_2.so"
66+
doNotStrip "*/*/libDJIMOP.so"
67+
doNotStrip "*/*/libDJISDKLOGJNI.so"
6468
exclude 'META-INF/rxjava.properties'
69+
exclude 'assets/location_map_gps_locked.png'
70+
exclude 'assets/location_map_gps_3d.png'
6571
}
6672

6773
compileOptions {
@@ -74,7 +80,7 @@ android {
7480
dependencies {
7581
implementation 'androidx.multidex:multidex:2.0.0'
7682
implementation 'com.squareup:otto:1.3.8'
77-
implementation('com.dji:dji-sdk:4.11.1', {
83+
implementation('com.dji:dji-sdk:4.14-trial1', {
7884
/**
7985
* Uncomment the "library-anti-distortion" if your app does not need Anti Distortion for Mavic 2 Pro and Mavic 2 Zoom.
8086
* Uncomment the "fly-safe-database" if you need database for release, or we will download it when DJISDKManager.getInstance().registerApp
@@ -84,7 +90,7 @@ dependencies {
8490
exclude module: 'library-anti-distortion'
8591
//exclude module: 'fly-safe-database'
8692
})
87-
compileOnly 'com.dji:dji-sdk-provided:4.11.1'
93+
compileOnly 'com.dji:dji-sdk-provided:4.14-trial1'
8894

8995
implementation 'androidx.appcompat:appcompat:1.0.0'
9096
implementation 'androidx.core:core:1.0.0'
@@ -96,5 +102,5 @@ dependencies {
96102

97103
// Please uncomment the following code if you use your own sdk version.
98104
// If can't get the file, Try a few times more
99-
apply from : "https://terra-1-g.djicdn.com/71a7d383e71a4fb8887a310eb746b47f/msdk/Android-CommonConfig/config_sample_all.gradle"
105+
//apply from : "https://terra-1-g.djicdn.com/71a7d383e71a4fb8887a310eb746b47f/msdk/Android-CommonConfig/config_sample_all.gradle"
100106

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

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,17 @@
3232
import java.io.OutputStream;
3333
import java.nio.ByteBuffer;
3434

35+
import dji.common.airlink.PhysicalSource;
3536
import dji.common.camera.SettingsDefinitions;
3637
import dji.common.error.DJIError;
3738
import dji.common.product.Model;
3839
import dji.common.util.CommonCallbacks;
40+
import dji.sdk.airlink.OcuSyncLink;
3941
import dji.sdk.base.BaseProduct;
4042
import dji.sdk.camera.Camera;
4143
import dji.sdk.camera.VideoFeeder;
4244
import dji.sdk.codec.DJICodecManager;
45+
import dji.sdk.sdkmanager.DJISDKManager;
4346
import dji.thirdparty.afinal.core.AsyncTask;
4447

4548
public class MainActivity extends Activity implements DJICodecManager.YuvDataCallback {
@@ -141,6 +144,28 @@ protected void onCreate(Bundle savedInstanceState) {
141144

142145
setContentView(R.layout.activity_main);
143146
initUi();
147+
if (isM300Product()) {
148+
OcuSyncLink ocuSyncLink = VideoDecodingApplication.getProductInstance().getAirLink().getOcuSyncLink();
149+
// If your MutltipleLensCamera is set at right or top, you need to change the PhysicalSource to RIGHT_CAM or TOP_CAM.
150+
ocuSyncLink.assignSourceToPrimaryChannel(PhysicalSource.LEFT_CAM, PhysicalSource.FPV_CAM, new CommonCallbacks.CompletionCallback() {
151+
@Override
152+
public void onResult(DJIError error) {
153+
if (error == null) {
154+
showToast("assignSourceToPrimaryChannel success.");
155+
} else {
156+
showToast("assignSourceToPrimaryChannel fail, reason: "+ error.getDescription());
157+
}
158+
}
159+
});
160+
}
161+
}
162+
163+
public static boolean isM300Product() {
164+
if (DJISDKManager.getInstance().getProduct() == null) {
165+
return false;
166+
}
167+
Model model = DJISDKManager.getInstance().getProduct().getModel();
168+
return model == Model.MATRICE_300_RTK;
144169
}
145170

146171
private void showToast(String s) {
@@ -290,6 +315,8 @@ public void onSurfaceTextureAvailable(SurfaceTexture surface, int width, int hei
290315
Log.d(TAG, "real onSurfaceTextureAvailable: width " + videoViewWidth + " height " + videoViewHeight);
291316
if (mCodecManager == null) {
292317
mCodecManager = new DJICodecManager(getApplicationContext(), surface, width, height);
318+
//For M300RTK, you need to actively request an I frame.
319+
mCodecManager.resetKeyFrame();
293320
}
294321
}
295322

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -754,7 +754,6 @@ private void onFrameQueueIn(Message msg) {
754754
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
755755
private void decodeFrame() throws Exception {
756756
DJIFrame inputFrame = frameQueue.poll();
757-
MediaFormat format = MediaFormat.createVideoFormat(VIDEO_ENCODING_FORMAT, width, height);
758757
if (inputFrame == null) {
759758
return;
760759
}
@@ -789,7 +788,7 @@ private void decodeFrame() throws Exception {
789788
yuvDataBuf.position(bufferInfo.offset);
790789
yuvDataBuf.limit(bufferInfo.size - bufferInfo.offset);
791790
if (yuvDataListener != null) {
792-
yuvDataListener.onYuvDataReceived(format, yuvDataBuf, bufferInfo.size - bufferInfo.offset, width, height);
791+
yuvDataListener.onYuvDataReceived(codec.getOutputFormat(), yuvDataBuf, bufferInfo.size - bufferInfo.offset, width, height);
793792
}
794793
}
795794
// All the output buffer must be release no matter whether the yuv data is output or

android-videostreamdecodingsample/gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip

0 commit comments

Comments
 (0)