Getting LiveStreamManager error -3 in DJI Mobile SDK when trying to stream to custom RTMP?

Marcello Moreira :

I'm trying to implement a app that sends live video from drone to my custom rtmp server. When I use de LiveStreamManager from DJI Mobile SDK it gives me error code -3, and the stream do not start. How can I use this API?

My app registers successfully, I can setup missions, and get telemetry from drone. But when I try to use the LiveStreamManeger it won't work no matter what. Even by implementing exactly the way it is implemented in Sample Code, it does not work. Documentation in DJI API reference seems to be missing a few methods as well.

Here is my implementation

    private void setupLiveStream() {
        DJISDKManager.getInstance().getLiveStreamManager().registerListener(listener);
        initListener();
        DJISDKManager.getInstance().getLiveStreamManager().setAudioStreamingEnabled(false);
        DJISDKManager.getInstance().getLiveStreamManager().setVideoSource(LiveStreamManager.LiveStreamVideoSource.Primary);
        liveURL = "rtmp://mycustomrtmp.com/drone/live_testDJI";
    }

    private void initListener() {
        listener = new LiveStreamManager.OnLiveChangeListener() {
            @Override
            public void onStatusChanged(int i) {
                setResultToToast("status changed : " + i);
            }
        };
    }
    private void StartStreaming(){
        if (!isLiveStreamManagerOn()) {
            return;
        }
        if (DJISDKManager.getInstance().getLiveStreamManager().isStreaming()) {
            setResultToToast("already started the Stream!");
            return;
        }
        new Thread() {
            @Override
            public void run() {
                DJISDKManager.getInstance().getLiveStreamManager().setLiveUrl(liveURL);// + vehicleID);
                int result = DJISDKManager.getInstance().getLiveStreamManager().startStream();
                DJISDKManager.getInstance().getLiveStreamManager().setStartTime();
                setResultToToast("LiveStream Start: " + result +
                        "\n isVideoStreamSpeedConfigurable:" + DJISDKManager.getInstance().getLiveStreamManager().isVideoStreamSpeedConfigurable() +
                        "\n isLiveAudioEnabled:" + DJISDKManager.getInstance().getLiveStreamManager().isLiveAudioEnabled());
            }
        }.start();
    }

I always get a return code -3. When I use the sample code I can get it to work. The only diference is then I call the function isVideoStreamSpeedConfigurable(), it returns true on my code, and false on sample code. But I did not see where I can set this thing to false. How should I implement LiveStreamingManager?

Marcello Moreira :

Answering my own question...

I've managed to solve the issue. Apparently, to be able to use the LiveStreamManager you must first call the function VideoFeeder.getPrimaryVideoFeed() somewhere in your code or it will give error code -3.

Using the Sample Code there is a class in internal.utils.VideoFeedView that can be used to this purpose

I have first declared a private property VideoFeedView.

Then on my class constructor I call the initUI function.

private VideoFeedView primaryVideoFeed;

private void initUI() {
   primaryVideoFeed.registerLiveVideo(VideoFeeder.getInstance().getPrimaryVideoFeed(),true);
   startStreaming();

}

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=150014&siteId=1