Skip to content

Commit a71dc12

Browse files
committed
fix(rtmp): fix few warnings in the media descriptor
1 parent 37c1441 commit a71dc12

1 file changed

Lines changed: 6 additions & 8 deletions

File tree

  • extensions/rtmp/src/main/java/io/github/thibaultbee/streampack/ext/rtmp/configuration/mediadescriptor

extensions/rtmp/src/main/java/io/github/thibaultbee/streampack/ext/rtmp/configuration/mediadescriptor/RtmpMediaDescriptor.kt

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import java.security.InvalidParameterException
2626
/**
2727
* Creates a RTMP connection descriptor from an [descriptor].
2828
* If the descriptor is already a [RtmpMediaDescriptor], it will be returned as is.
29-
* If the descriptor is an [UriMediaDescriptor], it will be converted to a [RtmpMediaDescriptor] with default [TSServiceInfo].
29+
* If the descriptor is an [UriMediaDescriptor], it will be converted to a [RtmpMediaDescriptor].
3030
* Otherwise, an [InvalidParameterException] will be thrown.
3131
*/
3232
fun RtmpMediaDescriptor(descriptor: MediaDescriptor) =
@@ -65,7 +65,7 @@ class RtmpMediaDescriptor(
6565
require(streamKey.isNotBlank()) { "Invalid streamKey $streamKey" }
6666
}
6767

68-
override val uri = Uri.Builder()
68+
override val uri: Uri = Uri.Builder()
6969
.scheme(scheme)
7070
.encodedAuthority("$host:$port")
7171
.apply {
@@ -109,12 +109,10 @@ class RtmpMediaDescriptor(
109109
val port = if (uri.port > 0) {
110110
uri.port
111111
} else {
112-
if ((scheme == RTMPS_SCHEME) || (scheme == RTMPTS_SCHEME)) {
113-
SSL_DEFAULT_PORT
114-
} else if ((scheme == RTMPT_SCHEME) || (scheme == RTMPTE_SCHEME)) {
115-
HTTP_DEFAULT_PORT
116-
} else {
117-
DEFAULT_PORT
112+
when (scheme) {
113+
RTMPS_SCHEME, RTMPTS_SCHEME -> SSL_DEFAULT_PORT
114+
RTMPT_SCHEME, RTMPTE_SCHEME -> HTTP_DEFAULT_PORT
115+
else -> DEFAULT_PORT
118116
}
119117
}
120118
if (uri.pathSegments.isEmpty()) {

0 commit comments

Comments
 (0)