@@ -94,6 +94,7 @@ class RtmpClient(private val connectChecker: ConnectChecker) {
9494 private var reTries = 0
9595 private var checkServerAlive = false
9696 private var publishPermitted = false
97+ private var ignoredCommandReceived: ((String ) -> Unit )? = null
9798
9899 val droppedAudioFrames: Long
99100 get() = rtmpSender.getDroppedAudioFrames()
@@ -144,6 +145,10 @@ class RtmpClient(private val connectChecker: ConnectChecker) {
144145 }
145146 }
146147
148+ fun setIgnoredCommandCallback (callback : ((String ) -> Unit )? ) {
149+ ignoredCommandReceived = callback
150+ }
151+
147152 /* *
148153 * Check periodically if server is alive using Echo protocol.
149154 */
@@ -424,9 +429,7 @@ class RtmpClient(private val connectChecker: ConnectChecker) {
424429 when (commandName) {
425430 " connect" -> {
426431 if (commandsManager.onAuth) {
427- onMainThread {
428- connectChecker.onAuthSuccess()
429- }
432+ onMainThread { connectChecker.onAuthSuccess() }
430433 commandsManager.onAuth = false
431434 }
432435 commandsManager.createStream(socket)
@@ -520,15 +523,19 @@ class RtmpClient(private val connectChecker: ConnectChecker) {
520523 }
521524 }
522525 else -> {
523- Log .i(TAG , " onStatus $code response received from ${commandName ? : " unknown command" } " )
526+ val message = " onStatus $code response received from ${commandName ? : " unknown command" } "
527+ Log .i(TAG , message)
528+ ignoredCommandReceived?.let { onMainThread { it.invoke(message) } }
524529 }
525530 }
526531 } catch (e: ClassCastException ) {
527532 Log .e(TAG , " error parsing onStatus command" , e)
528533 }
529534 }
530535 else -> {
531- Log .i(TAG , " unknown ${command.name} response received from ${commandName ? : " unknown command" } " )
536+ val message = " unknown ${command.name} response received from ${commandName ? : " unknown command" } "
537+ Log .i(TAG , message)
538+ ignoredCommandReceived?.let { onMainThread { it.invoke(message) } }
532539 }
533540 }
534541 }
0 commit comments