Skip to content

Commit 4668b29

Browse files
committed
rtmp fail on read is configurable now
1 parent d2c8575 commit 4668b29

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

library/src/main/java/com/pedro/library/util/streamclient/RtmpStreamClient.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,4 +185,11 @@ class RtmpStreamClient(
185185
fun setCustomAmfObject(amfObject: Map<String, Any>) {
186186
rtmpClient.setCustomAmfObject(amfObject)
187187
}
188+
189+
/**
190+
* Should notify onConnectionFailed if read packet from the server failed
191+
*/
192+
fun shouldFailOnRead(enabled: Boolean) {
193+
rtmpClient.shouldFailOnRead = enabled
194+
}
188195
}

rtmp/src/main/java/com/pedro/rtmp/rtmp/RtmpClient.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ class RtmpClient(private val connectChecker: ConnectChecker) {
108108
get() = rtmpSender.bytesSend
109109
var socketType = SocketType.KTOR
110110
var socketTimeout = StreamSocket.DEFAULT_TIMEOUT
111+
var shouldFailOnRead = false
111112

112113
/**
113114
* Add certificates for TLS connection
@@ -317,7 +318,7 @@ class RtmpClient(private val connectChecker: ConnectChecker) {
317318
}.exceptionOrNull()
318319
if (error != null && ConnectionFailed.parse(error.validMessage()) != ConnectionFailed.TIMEOUT) {
319320
scope.cancel()
320-
connectChecker.onConnectionFailed(error.validMessage())
321+
if (shouldFailOnRead) connectChecker.onConnectionFailed(error.validMessage())
321322
}
322323
}
323324
}

0 commit comments

Comments
 (0)