MSDK v5 Livestreaming Lib error
CompletedHey,
I'm trying to implement the live stream feature into my app using the MSDK v5 and RTMP. My RTMP url and the feature is working as expected in the compiled sample app MSDK v5 with the my M300 and my Matrice M300.
I tried to copy the logic in my sample app and I'm correctly viewing the output of the camera on an android surfaceView. As far as i know I need a video decoder and an surfaceView output to start live streaming (from https://sdk-forum.dji.net/hc/en-us/articles/6663305630105-Chapter-6-Live-Streaming: "Both MSDK V5 and V5 do not support live streaming in the background. The current page must have a rendering surface. You cannot minimize the app or redirect to another page.")
Now, I receive the same errors, mentioned in https://sdk-forum.dji.net/hc/en-us/articles/13201276673689-What-happen-if-the-startLiveStream-returns-an-unknown-error- Could you give me a hand with handling this issue?
My logcat:
MRTCLiveShare initVideoConfig start
MRTCLiveShare initVideoConfig end
MRTCLiveShare initAudioConfig start
MRTCLiveShare initAudioConfig end
MRTCLiveShare initMrtcAgent start
LOG_JNI [MRTC-E find_dl_handle_node_by_prot_name: 70]: : can't find dl_node by prot_name dji,rtmp
LOG_JNI [MRTC-E mrtc_agent_init: 190]: : can't find dl_handle_node in lib handle list
MRTCLiveShare init agent error,code = 420478983
MRTCLiveShare initMrtcAgent end
MRTCLiveShare initMrtcAgent error,code = 420478983
my gradle build:
...
android {
compileSdk 33
buildFeatures {
buildConfig = true
}
defaultConfig {
minSdk 23
targetSdk 33
....
}
My Activity to start the Videooutput:
public class VideoPlayActivity extends Activity implements SurfaceHolder.Callback {
private SurfaceView videoSurface;
private IVideoDecoder videoDecoder;
private StreamManager streamManager;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.video_play_activity);
videoSurface = findViewById(R.id.surface_view_videoplayer);
SurfaceHolder holder = videoSurface.getHolder();
holder.addCallback(this);
streamManager = new StreamManager();
}
@Override
public void surfaceCreated(@NonNull SurfaceHolder surfaceHolder) {
videoDecoder = new VideoDecoder(this,VideoChannelType.PRIMARY_STREAM_CHANNEL, DecoderOutputMode.SURFACE_MODE, videoSurface.getHolder(), -1, -1, true);
videoDecoder.onResume();
}
@Override
public void surfaceChanged(@NonNull SurfaceHolder surfaceHolder, int i, int i1, int i2) {
streamManager.startStream();
}
@Override
public void surfaceDestroyed(@NonNull SurfaceHolder surfaceHolder) {
videoDecoder.onPause();
}
}
My Stream manager:
public class StreamManager {
private ILiveStreamManager liveStreamManager;
public StreamManager() {
liveStreamManager = MediaDataCenter.getInstance().getLiveStreamManager();
liveStreamManager.setLiveStreamQuality(StreamQuality.HD);
liveStreamManager.setVideoChannelType(VideoChannelType.PRIMARY_STREAM_CHANNEL);
LiveStreamSettings rtmpUrl = new LiveStreamSettings.Builder()
.setLiveStreamType(LiveStreamType.RTMP)
.setRtmpSettings(
new Builder()
.setUrl("{{privateurl}}")
.build()
).build();
liveStreamManager.addLiveStreamStatusListener(new LiveStreamStatusListener() {
@Override
public void onLiveStreamStatusUpdate(LiveStreamStatus status) {
Log.i(Constants.APP_NAME, "LiveStreamStatusListener: " + status);
}
@Override
public void onError(IDJIError error) {
Log.e(Constants.APP_NAME, "LiveStreamStatusListener: " + error);
}
});
liveStreamManager.setLiveStreamSettings(rtmpUrl);
}
public void startStream() {
liveStreamManager.startStream(new CommonCallbacks.CompletionCallback() {
@Override
public void onSuccess() {
Log.i(Constants.APP_NAME, "Stream started");
}
@Override
public void onFailure(@NonNull IDJIError error) {
Log.e(Constants.APP_NAME, "Stream start failed " + error.description());
}
});
}
public void stopStream(){
liveStreamManager.stopStream(new CommonCallbacks.CompletionCallback() {
@Override
public void onSuccess() {
Log.i(Constants.APP_NAME, "Stream stopped");
}
@Override
public void onFailure(@NonNull IDJIError error) {
Log.e(Constants.APP_NAME, "Stream stop failed " + error.description());
}
});
}
}
-
Took me couple of hours to figure it out: The native lib is not packed within my application.
For newer android application I had to change the build gradle to include the lib.
packagingOptions {
jniLibs {
useLegacyPackaging = true
}
resources {
excludes += '/META-INF/{AL2.0,LGPL2.1}'
}
doNotStrip "*/*/libconstants.so"
doNotStrip "*/*/libdji_innertools.so"
doNotStrip "*/*/libdjibase.so"
doNotStrip "*/*/libDJICSDKCommon.so"
doNotStrip "*/*/libDJIFlySafeCore-CSDK.so"
doNotStrip "*/*/libdjifs_jni-CSDK.so"
doNotStrip "*/*/libDJIRegister.so"
doNotStrip "*/*/libdjisdk_jni.so"
doNotStrip "*/*/libDJIUpgradeCore.so"
doNotStrip "*/*/libDJIUpgradeJNI.so"
doNotStrip "*/*/libDJIWaypointV2Core-CSDK.so"
doNotStrip "*/*/libdjiwpv2-CSDK.so"
doNotStrip "*/*/libffmpeg.so"
doNotStrip "*/*/libFlightRecordEngine.so"
doNotStrip "*/*/libvideo-framing.so"
doNotStrip "*/*/libwaes.so"
doNotStrip "*/*/libagora-rtsa-sdk.so"
doNotStrip "*/*/libc++.so"
doNotStrip "*/*/libc++_shared.so"
doNotStrip "*/*/libmrtc_28181.so"
doNotStrip "*/*/libmrtc_agora.so"
doNotStrip "*/*/libmrtc_core.so"
doNotStrip "*/*/libmrtc_core_jni.so"
doNotStrip "*/*/libmrtc_data.so"
doNotStrip "*/*/libmrtc_log.so"
doNotStrip "*/*/libmrtc_onvif.so"
doNotStrip "*/*/libmrtc_rtmp.so"
doNotStrip "*/*/libmrtc_rtsp.so"
}
}I'm getting another error now when try to connect to RTMP. I used youtube live for demo purpose. See my logcat:
16:38:55.474 I [MRTC-I checkAndConvertUrl: 412]: []RTMP: no @, means no auth in URL
16:38:55.475 I [MRTC-I checkAndConvertUrl: 448]: []RTMP: Converted url is rtmp://a.rtmp.youtube.com/live2/{{censored_token}}
16:38:55.475 E [MRTC-E mt_librtmp_logcallback: 90]: RTMP: RTMP_Init
16:38:55.475 E [MRTC-F mt_librtmp_logcallback: 92]: RTMP: Wrong level(1) log, RTMP_Init, should not happen!
16:38:55.475 E [MRTC-E mt_librtmp_logcallback: 90]: RTMP: RTMP_TLS_Init
16:38:55.475 E [MRTC-F mt_librtmp_logcallback: 92]: RTMP: Wrong level(1) log, RTMP_TLS_Init, should not happen!
16:38:55.477 E [MRTC-E mt_librtmp_logcallback: 90]: RTMP: Parsing...
16:38:55.477 E [MRTC-F mt_librtmp_logcallback: 92]: RTMP: Wrong level(4) log, Parsing..., should not happen!
16:38:55.477 E [MRTC-E mt_librtmp_logcallback: 90]: RTMP: Parsed protocol: 0
16:38:55.477 E [MRTC-F mt_librtmp_logcallback: 92]: RTMP: Wrong level(4) log, Parsed protocol: 0, should not happen!
16:38:55.477 E [MRTC-E mt_librtmp_logcallback: 90]: RTMP: Parsed host : a.rtmp.youtube.com
16:38:55.477 E [MRTC-F mt_librtmp_logcallback: 92]: RTMP: Wrong level(4) log, Parsed host : a.rtmp.youtube.com, should not happen!
16:38:55.477 E [MRTC-E mt_librtmp_logcallback: 90]: RTMP: Parsed app : live2
16:38:55.477 E [MRTC-F mt_librtmp_logcallback: 92]: RTMP: Wrong level(4) log, Parsed app : live2, should not happen!
16:38:55.477 I [MRTC-I mt_rtmp_open: 147]: RTMP: rtmp open rtmp://a.rtmp.youtube.com/live2/{{censored_token}} done
16:38:55.477 I [MRTC-I resetStartTimestamp: 1020]: []RTMP: Reset mStartTimestampMs to 0
16:38:55.477 I [MRTC-I doInit: 104]: []RTMP: add channel(url:rtmp://a.rtmp.youtube.com/live2/{{censored_token}}) done, return stream id 14!
16:38:55.477 I [MRTC-I doCheckNeedMuteDummyAudio: 297]: []RTMP: Target rtmp://a.rtmp.youtube.com/live2/{{censored_token}} must need audio!!!
16:38:55.477 I [MRTC-I doCheckNeedMuteDummyAudio: 297]: []RTMP: Target rtmp://a.rtmp.youtube.com/live2/{{censored_token}} must need audio!!!
16:38:55.477 I [MRTC-I doReconnection: 225]: []RTMP: reconnecting ...
16:38:55.477 I [MRTC-I init: 95]: []ChannelBase: enable dummy audio send, audio.enabled 0, needMuteDummy 1
16:38:55.477 E [MRTC-E mt_librtmp_logcallback: 90]: RTMP: RTMP_Init
16:38:55.477 D current video channel stream id 14
16:38:55.477 D current audio channel stream id 15
16:38:55.477 E [MRTC-F mt_librtmp_logcallback: 92]: RTMP: Wrong level(1) log, RTMP_Init, should not happen!
16:38:55.477 E [MRTC-E mt_librtmp_logcallback: 90]: RTMP: Parsing...
16:38:55.477 E [MRTC-F mt_librtmp_logcallback: 92]: RTMP: Wrong level(4) log, Parsing..., should not happen!
16:38:55.477 D addChannelConfig end
16:38:55.478 E [MRTC-E mt_librtmp_logcallback: 90]: RTMP: Parsed protocol: 0
16:38:55.478 E [MRTC-F mt_librtmp_logcallback: 92]: RTMP: Wrong level(4) log, Parsed protocol: 0, should not happen!
16:38:55.478 E [MRTC-E mt_librtmp_logcallback: 90]: RTMP: Parsed host : a.rtmp.youtube.com -
I hope this message finds you well. I would like to bring to your attention that there appears to be an issue with the RTMP push address you have provided. Would it be possible for you to kindly attempt to utilize our sample code in order to successfully push video stream to this address?
Please sign in to leave a comment.
Comments
3 comments