Skip to content

Commit

Permalink
remove unnecesary methods
Browse files Browse the repository at this point in the history
  • Loading branch information
pedroSG94 committed Aug 7, 2024
1 parent 251ca13 commit 7c23f14
Showing 1 changed file with 7 additions and 23 deletions.
30 changes: 7 additions & 23 deletions library/src/main/java/com/pedro/library/generic/GenericStream.kt
Original file line number Diff line number Diff line change
Expand Up @@ -108,42 +108,26 @@ class GenericStream(
streamClient.connecting(endPoint)
if (endPoint.startsWith("rtmp", ignoreCase = true)) {
connectedType = ClientType.RTMP
startStreamRtpRtmp(endPoint)
val resolution = super.getVideoResolution()
rtmpClient.setVideoResolution(resolution.width, resolution.height)
rtmpClient.setFps(super.getVideoFps())
rtmpClient.connect(endPoint)
} else if (endPoint.startsWith("rtsp", ignoreCase = true)) {
connectedType = ClientType.RTSP
startStreamRtpRtsp(endPoint)
rtspClient.connect(endPoint)
} else if (endPoint.startsWith("srt", ignoreCase = true)) {
connectedType = ClientType.SRT
startStreamRtpSrt(endPoint)
srtClient.connect(endPoint)
} else if (endPoint.startsWith("udp", ignoreCase = true)) {
connectedType = ClientType.UDP
startStreamRtpUdp(endPoint)
udpClient.connect(endPoint)
} else {
onMainThreadHandler {
connectChecker.onConnectionFailed("Unsupported protocol. Only support rtmp, rtsp and srt")
}
}
}

private fun startStreamRtpRtmp(endPoint: String) {
val resolution = super.getVideoResolution()
rtmpClient.setVideoResolution(resolution.width, resolution.height)
rtmpClient.setFps(super.getVideoFps())
rtmpClient.connect(endPoint)
}

private fun startStreamRtpRtsp(endPoint: String) {
rtspClient.connect(endPoint)
}

private fun startStreamRtpSrt(endPoint: String) {
srtClient.connect(endPoint)
}

private fun startStreamRtpUdp(endPoint: String) {
udpClient.connect(endPoint)
}

override fun stopStreamImp() {
when (connectedType) {
ClientType.RTMP -> rtmpClient.disconnect()
Expand Down

0 comments on commit 7c23f14

Please sign in to comment.