Skip to content
Merged
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 @@ -17,14 +17,14 @@ package io.github.thibaultbee.srtdroid.core.models

import android.net.Uri
import android.util.Log
import androidx.core.net.toUri
import io.github.thibaultbee.srtdroid.core.Srt
import io.github.thibaultbee.srtdroid.core.enums.SockOpt
import io.github.thibaultbee.srtdroid.core.enums.Transtype
import io.github.thibaultbee.srtdroid.core.extensions.toBoolean
import io.github.thibaultbee.srtdroid.core.extensions.toInt
import io.github.thibaultbee.srtdroid.core.interfaces.ConfigurableSrtSocket
import java.security.InvalidParameterException
import androidx.core.net.toUri

/**
* Extracts [SrtUrl] from a FFmpeg format [String]: srt://hostname:port[?options]
Expand Down Expand Up @@ -116,6 +116,7 @@ internal fun SrtUrl(uri: SrtUri): SrtUrl {
val enableTimestampBasedPacketDelivery =
uri.getQueryParameter(SrtUrl.ENABLE_TIMESTAMP_BASED_PACKET_DELIVERY_QUERY_PARAMETER)
?.toInt()?.toBoolean()
val packetFilter = uri.getQueryParameter(SrtUrl.PACKET_FILTER_QUERY_PARAMETER)

val unknownParameters =
uri.queryParameterNames.find {
Expand Down Expand Up @@ -162,7 +163,8 @@ internal fun SrtUrl(uri: SrtUri): SrtUrl {
enableMessageApi,
transtype,
lingerInS,
enableTimestampBasedPacketDelivery
enableTimestampBasedPacketDelivery,
packetFilter
)
}

Expand Down Expand Up @@ -211,6 +213,7 @@ data class SrtUrl(
val transtype: Transtype? = null,
val lingerInS: Int? = null,
val enableTimestampBasedPacketDelivery: Boolean? = null,
val packetFilter: String? = null
) {
init {
hostname.removePrefix(SRT_PREFIX)
Expand Down Expand Up @@ -447,6 +450,8 @@ data class SrtUrl(
streamId?.let { socket.setSockFlag(SockOpt.STREAMID, it) }
smoother?.let { socket.setSockFlag(SockOpt.CONGESTION, it) }
enableMessageApi?.let { socket.setSockFlag(SockOpt.MESSAGEAPI, it) }

packetFilter?.let { socket.setSockFlag(SockOpt.PACKETFILTER, it) }
}

/**
Expand Down Expand Up @@ -517,6 +522,7 @@ data class SrtUrl(
internal const val TRANSTYPE_QUERY_PARAMETER = "transtype"
internal const val LINGER_QUERY_PARAMETER = "linger"
internal const val ENABLE_TIMESTAMP_BASED_PACKET_DELIVERY_QUERY_PARAMETER = "tsbpd"
internal const val PACKET_FILTER_QUERY_PARAMETER = "packetfilter"

internal val supportedQueryParameterList = listOf(
CONNECTION_TIMEOUT_QUERY_PARAMETER,
Expand Down Expand Up @@ -555,7 +561,8 @@ data class SrtUrl(
ENABLE_MESSAGE_API_QUERY_PARAMETER,
TRANSTYPE_QUERY_PARAMETER,
LINGER_QUERY_PARAMETER,
ENABLE_TIMESTAMP_BASED_PACKET_DELIVERY_QUERY_PARAMETER
ENABLE_TIMESTAMP_BASED_PACKET_DELIVERY_QUERY_PARAMETER,
PACKET_FILTER_QUERY_PARAMETER
)

init {
Expand Down