Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ class RtmpStreamClient(
private val streamClientListener: StreamClientListener?
): StreamBaseClient() {

fun setIgnoredCommandCallback(callback: ((String) -> Unit)?) {
rtmpClient.setIgnoredCommandCallback(callback)
}

/**
* Must be called before start stream or will be ignored.
*
Expand Down
17 changes: 12 additions & 5 deletions rtmp/src/main/java/com/pedro/rtmp/rtmp/RtmpClient.kt
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ class RtmpClient(private val connectChecker: ConnectChecker) {
private var reTries = 0
private var checkServerAlive = false
private var publishPermitted = false
private var ignoredCommandReceived: ((String) -> Unit)? = null

val droppedAudioFrames: Long
get() = rtmpSender.getDroppedAudioFrames()
Expand Down Expand Up @@ -144,6 +145,10 @@ class RtmpClient(private val connectChecker: ConnectChecker) {
}
}

fun setIgnoredCommandCallback(callback: ((String) -> Unit)?) {
ignoredCommandReceived = callback
}

/**
* Check periodically if server is alive using Echo protocol.
*/
Expand Down Expand Up @@ -424,9 +429,7 @@ class RtmpClient(private val connectChecker: ConnectChecker) {
when (commandName) {
"connect" -> {
if (commandsManager.onAuth) {
onMainThread {
connectChecker.onAuthSuccess()
}
onMainThread { connectChecker.onAuthSuccess() }
commandsManager.onAuth = false
}
commandsManager.createStream(socket)
Expand Down Expand Up @@ -520,15 +523,19 @@ class RtmpClient(private val connectChecker: ConnectChecker) {
}
}
else -> {
Log.i(TAG, "onStatus $code response received from ${commandName ?: "unknown command"}")
val message = "onStatus $code response received from ${commandName ?: "unknown command"}"
Log.i(TAG, message)
ignoredCommandReceived?.let { onMainThread { it.invoke(message) } }
}
}
} catch (e: ClassCastException) {
Log.e(TAG, "error parsing onStatus command", e)
}
}
else -> {
Log.i(TAG, "unknown ${command.name} response received from ${commandName ?: "unknown command"}")
val message = "unknown ${command.name} response received from ${commandName ?: "unknown command"}"
Log.i(TAG, message)
ignoredCommandReceived?.let { onMainThread { it.invoke(message) } }
}
}
}
Expand Down