Hello,
Has anyone managed to stream rtmp using MSDK2.0/2.5?
Here are my codes and logs. Can anyone help me?
Logs:
2024-08-10 14:20:55.191 21581-21737 RTMP com.dscrd.dhlautelapp D Rtmp Status : connecting
2024-08-10 14:20:55.476 21581-21737 RTMP_SESSION com.dscrd.dhlautelapp I LibRtmpSession::SendFlvHeader...
2024-08-10 14:20:55.476 21581-21737 RTMP com.dscrd.dhlautelapp D Rtmp Status : connected.
2024-08-10 14:20:55.492 21581-3946 RTMP com.dscrd.dhlautelapp D Rtmp onAudioBriate : 0 KBPS
2024-08-10 14:20:55.592 21581-21737 RTMP com.dscrd.dhlautelapp D Rtmp Status : start publish stream
2024-08-10 14:20:55.613 21581-21737 RTMP com.dscrd.dhlautelapp D Rtmp onVideoBriate : 0 KBPS
2024-08-10 14:20:55.614 21581-21737 RTMP com.dscrd.dhlautelapp D Rtmp onPublishFailed errcode-100
2024-08-10 14:20:56.578 21581-21737 RTMP com.dscrd.dhlautelapp D Rtmp onPublishFailed errcode-100
2024-08-10 14:20:57.120 21581-21737 RTMP com.dscrd.dhlautelapp D Rtmp onPublishFailed errcode-100
2024-08-10 14:20:57.690 21581-21737 RTMP com.dscrd.dhlautelapp D Rtmp onVideoBriate : 82 KBPS
2024-08-10 14:20:57.691 21581-21737 RTMP com.dscrd.dhlautelapp D Rtmp onPublishFailed errcode-100
2024-08-10 14:20:58.586 21581-21737 RTMP com.dscrd.dhlautelapp D Rtmp onPublishFailed errcode-100
MediaMtx Log:
2024/08/10 14:20:55 INF [RTMP] [conn 192.168.0.100:39520] opened
2024/08/10 14:21:15 INF [RTMP] [conn 192.168.0.100:39520] closed: read tcp 192.168.0.101:1935->192.168.0.100:39520: i/o timeout
Actually there is one way to hack this bug. If you open the stream on Autel Entrprise App and close the application without closing the stream. You can now stream using SDK.
Has anyone managed to stream rtmp using MSDK2.0/2.5?
Here are my codes and logs. Can anyone help me?
Java:
import android.util.Log
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.setValue
import androidx.lifecycle.ViewModel
import com.autel.drone.sdk.SDKConstants
import com.autel.drone.sdk.vmodelx.manager.RtmpServiceManager
import com.autel.rtmp.publisher.IPublishListener
import com.autel.rtmp.publisher.RtmpConfig
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
class SettingsPopupViewModel : ViewModel() {
val TAG: String = "RTMP"
private val coroutineScope = CoroutineScope(Dispatchers.Default)
var connectStatus = 0
val rtmpUrl = "rtmp://192.168.0.101:1935/live";
var open by mutableStateOf<Boolean>(false)
var ip by mutableStateOf("10.0.2.2")
fun initRTMP() {
coroutineScope.launch {
RtmpServiceManager.getInstance().setRtmpPublishListener(object : IPublishListener {
override fun onConnecting() {
Log.d(TAG, "Rtmp Status : connecting")
connectStatus = 0;
}
override fun onConnected() {
Log.d(TAG, "Rtmp Status : connected.")
connectStatus = 1;
}
override fun onConnectedFailed(code: Int) {
Log.d(TAG, "Rtmp Status : connected failed code=" + code)
connectStatus = 2;
}
override fun onStartPublish() {
Log.d(TAG, "Rtmp Status : start publish stream")
}
override fun onStopPublish() {
Log.d(TAG, "Rtmp Status : stoppublish now")
}
override fun onFpsStatistic(fps: Int) {
Log.d(TAG, "Rtmp upload fps : " + fps)
}
override fun onRtmpDisconnect() {
Log.d(TAG, "Rtmp Status : disconnect..")
}
override fun onVideoBriate(value: Int) {
Log.d(TAG, "Rtmp onVideoBriate : " + value + " KBPS")
}
override fun onAudioBriate(value: Int) {
Log.d(TAG, "Rtmp onAudioBriate : " + value + " KBPS")
}
override fun onPublishSuccess() {
Log.d(TAG, "Rtmp onPublishSuccess")
}
override fun onPublishFailed(errorCode: Int) {
Log.d(TAG, "Rtmp onPublishFailed errcode" + errorCode)
}
})
}
}
init {
val config = RtmpConfig.ConfigBuilder().withPublishUrl(rtmpUrl).withVideoWidth(1440).withVideoHeight(1088).withBitRate(112000)
.withReConnTimes(100)
.withEnableAudio(true)
RtmpServiceManager.getInstance().initRtmpConfig(
rtmpUrl,
SDKConstants.STREAM_CHANNEL_16110,
config.build()
)
Log.d("SettingsPopupViewModel", "SettingsPopupViewModel: init")
}
fun stopRTSP() {
coroutineScope.launch {
val rtmpManager = RtmpServiceManager.getInstance()
rtmpManager.stopPublishStream{ e -> Log.d(TAG,"Kapandı $e")}
}
}
fun startRTSPStream() {
if (connectStatus == 0) initRTMP()
coroutineScope.launch {
try {
RtmpServiceManager.getInstance().startPublishStream()
} catch (e: Exception) {
Log.d(TAG, "Exception ${e.toString()}")
}
}
}
}
Logs:
2024-08-10 14:20:55.191 21581-21737 RTMP com.dscrd.dhlautelapp D Rtmp Status : connecting
2024-08-10 14:20:55.476 21581-21737 RTMP_SESSION com.dscrd.dhlautelapp I LibRtmpSession::SendFlvHeader...
2024-08-10 14:20:55.476 21581-21737 RTMP com.dscrd.dhlautelapp D Rtmp Status : connected.
2024-08-10 14:20:55.492 21581-3946 RTMP com.dscrd.dhlautelapp D Rtmp onAudioBriate : 0 KBPS
2024-08-10 14:20:55.592 21581-21737 RTMP com.dscrd.dhlautelapp D Rtmp Status : start publish stream
2024-08-10 14:20:55.613 21581-21737 RTMP com.dscrd.dhlautelapp D Rtmp onVideoBriate : 0 KBPS
2024-08-10 14:20:55.614 21581-21737 RTMP com.dscrd.dhlautelapp D Rtmp onPublishFailed errcode-100
2024-08-10 14:20:56.578 21581-21737 RTMP com.dscrd.dhlautelapp D Rtmp onPublishFailed errcode-100
2024-08-10 14:20:57.120 21581-21737 RTMP com.dscrd.dhlautelapp D Rtmp onPublishFailed errcode-100
2024-08-10 14:20:57.690 21581-21737 RTMP com.dscrd.dhlautelapp D Rtmp onVideoBriate : 82 KBPS
2024-08-10 14:20:57.691 21581-21737 RTMP com.dscrd.dhlautelapp D Rtmp onPublishFailed errcode-100
2024-08-10 14:20:58.586 21581-21737 RTMP com.dscrd.dhlautelapp D Rtmp onPublishFailed errcode-100
MediaMtx Log:
2024/08/10 14:20:55 INF [RTMP] [conn 192.168.0.100:39520] opened
2024/08/10 14:21:15 INF [RTMP] [conn 192.168.0.100:39520] closed: read tcp 192.168.0.101:1935->192.168.0.100:39520: i/o timeout
Actually there is one way to hack this bug. If you open the stream on Autel Entrprise App and close the application without closing the stream. You can now stream using SDK.