DJI SDK 5.1.7 RTMP streaming on primary channel crashes main app Android

149 Views Asked by At

I am having trouble with my main app crashing after a few minutes of streaming to my cloud RTMP server. The app crash is attached at bottom of this post.

A little background - the code is for a dji mini 3 running on a samsung galaxy S22 using the sample app from sdk 5.1.7 derived from

https://github.com/dji-sdk/Mobile-SDK-Android-V5/blob/dev-sdk-main/SampleCode-V5/android-sdk-v5-uxsdk/src/main/java/dji/v5/ux/sample/showcase/defaultlayout/DefaultLayoutActivity.java

Here is the code on the main app that runs on a fragment (the home fragment) and is performed onCreateView

 // note this is a listener and when the stream source is updated it gets called
            MediaDataCenter.getInstance().getVideoStreamManager().addStreamSourcesListener
                    (sources -> getActivity().runOnUiThread(() -> updateFPVWidgetSource(sources)));
            primaryFpvWidget.setOnFPVStreamSourceListener((devicePosition, lensType) -> {
                cameraSourceProcessor.onNext(new HomeFragment.CameraSource(devicePosition, lensType));
            });

IVideoChannel primaryChannel =
                MediaDataCenter.getInstance().getVideoStreamManager().getAvailableVideoChannel(VideoChannelType.PRIMARY_STREAM_CHANNEL); if (primaryChannel != null) {
            primaryChannelStateListener = (from, to) -> {
                StreamSource primaryStreamSource = primaryChannel.getStreamSource();
                if (VideoChannelState.ON == to && primaryStreamSource != null) {
                   
                    getActivity().runOnUiThread(() -> primaryFpvWidget.updateVideoSource(primaryStreamSource, VideoChannelType.PRIMARY_STREAM_CHANNEL));

                }
            };
            primaryChannel.addVideoChannelStateChangeListener(primaryChannelStateListener);

After product connect, in a separate worker thread after on product connect, I start the stream like this:

ILiveStreamManager liveStreamManager = MediaDataCenter.getInstance().getLiveStreamManager();

            LiveStreamSettings.Builder lssBuilder = new LiveStreamSettings.Builder();

            RtmpSettings.Builder b = new RtmpSettings.Builder();
            b.setUrl(liveURL);
            RtmpSettings rtmp = b.build();
            lssBuilder.setRtmpSettings(rtmp);
            lssBuilder.setLiveStreamType(LiveStreamType.RTMP);
            LiveStreamSettings lss = lssBuilder.build();

            liveStreamManager.setLiveStreamSettings(lss);

            // the video going to app display is primary - MUST BE PRIMARY!!! or dont see video
            
            liveStreamManager.setVideoChannelType(VideoChannelType.PRIMARY_STREAM_CHANNEL);
            liveStreamManager.setLiveStreamQuality(StreamQuality.SD); // make quality lower? 
            //liveStreamManager.setLiveVideoBitrate(2048); // small
            liveStreamManager.setLiveVideoBitrateMode(LiveVideoBitrateMode.AUTO);

              liveStreamManager.startStream(new CommonCallbacks.CompletionCallback() {...}

What am I doing wrong?

Crash output

2023-11-03 14:42:44.584 14829-14829/? A/DEBUG: Cmdline: com.tbolt.main
2023-11-03 14:42:44.584 14829-14829/? A/DEBUG: pid: 12914, tid: 12914, name: com.tbolt.main  >>> com.tbolt.main <<<
2023-11-03 14:42:44.589 12914-12988/com.tbolt.main E/fdsan: failed to exchange ownership of file descriptor: fd 297 is owned by unique_fd 0x6e6ca9d75c, was expected to be unowned
2023-11-03 14:42:44.620 12914-14680/com.tbolt.main E/co_b: (co_a:86) checkFrame() lastId = 18150 id=18156
2023-11-03 14:42:44.776 12914-12988/com.tbolt.main E/fdsan: attempted to close file descriptor 297, expected to be owned by unique_fd 0x6e6ca9dd9c, actually owned by unique_fd 0x6e6ca9d75c
2023-11-03 14:42:44.963 14834-14834/? A/DEBUG: Cmdline: com.tbolt.main
2023-11-03 14:42:44.963 14834-14834/? A/DEBUG: pid: 12914, tid: 12914, name: com.tbolt.main  >>> com.tbolt.main <<<
2023-11-03 14:42:44.974 12914-14824/com.tbolt.main E/fdsan: failed to exchange ownership of file descriptor: fd 297 is owned by unique_fd 0x6e6ca9d75c, was expected to be unowned
2023-11-03 14:42:45.081 12914-14687/com.tbolt.main W/DJIV5/co_c@1a50a50: (co_b:99) onOutputFrame() frame index:18161
2023-11-03 14:42:45.161 12914-14688/com.tbolt.main E/co_b: (co_a:104) checkFrame()  len=6840 checkLen=11802 seiOffset:6854
2023-11-03 14:42:45.167 12914-12985/com.tbolt.main A/libc: Fatal signal 11 (SIGSEGV), code -6 (SI_TKILL) in tid 12985 (com.tbolt.main), pid 12914 (com.tbolt.main)
2023-11-03 14:42:45.201 12914-14685/com.tbolt.main E/co_b: (co_a:86) checkFrame() lastId = 18163 id=18166
2023-11-03 14:42:45.204 12914-12988/com.tbolt.main E/fdsan: attempted to close file descriptor 297, expected to be owned by unique_fd 0x6e6ca9abdc, actually owned by unique_fd 0x6e6ca9d75c
2023-11-03 14:42:45.332 14840-14840/? A/DEBUG: Cmdline: com.tbolt.main
2023-11-03 14:42:45.332 14840-14840/? A/DEBUG: pid: 12914, tid: 12914, name: com.tbolt.main  >>> com.tbolt.main <<<
2023-11-03 14:42:45.682 14846-14846/? A/DEBUG: Cmdline: com.tbolt.main
2023-11-03 14:42:45.682 14846-14846/? A/DEBUG: pid: 12914, tid: 12914, name: com.tbolt.main  >>> com.tbolt.main <<<
2023-11-03 14:42:45.710 12914-14680/com.tbolt.main E/co_b: (co_a:86) checkFrame() lastId = 18175 id=18178
2023-11-03 14:42:46.049 14852-14852/? A/DEBUG: Cmdline: com.tbolt.main
2023-11-03 14:42:46.049 14852-14852/? A/DEBUG: pid: 12914, tid: 12914, name: com.tbolt.main  >>> com.tbolt.main <<<
2023-11-03 14:42:46.368 12914-14687/com.tbolt.main W/DJIV5/co_c@1a50a50: (co_b:99) onOutputFrame() frame index:18194
2023-11-03 14:42:46.429 14859-14859/? A/DEBUG: Cmdline: com.tbolt.main
2023-11-03 14:42:46.429 14859-14859/? A/DEBUG: pid: 12914, tid: 12914, name: com.tbolt.main  >>> com.tbolt.main <<<
2023-11-03 14:42:46.812 14864-14864/? A/DEBUG: Cmdline: com.tbolt.main
2023-11-03 14:42:46.812 14864-14864/? A/DEBUG: pid: 12914, tid: 12985, name: com.tbolt.main  >>> com.tbolt.main <<<
2023-11-03 14:42:46.856 2299-14876/? W/ActivityManager: crash : com.tbolt.main,10274
2023-11-03 14:42:46.856 2299-14876/? W/ActivityTaskManager:   Force finishing activity com.tbolt.main/.MainActivity
2023-11-03 14:42:46.985 2299-5904/? W/InputManager-JNI: Input channel object 'bebdddd com.tbolt.main/com.tbolt.main.MainActivity (client)' was disposed without first being removed with the input manager!



1

There are 1 best solutions below

2
On

i'm also having issues with msdk v5 sample & RTMP. i saw that in the testing tools section the rtmp works well, maybe there is a way to call the methods in there ?

msdk Version: 5.7.1 Mini 3 pro