Skip to content

Commit

Permalink
Add telephone-event payload type (#2071)
Browse files Browse the repository at this point in the history
  • Loading branch information
dkirov-dev authored May 29, 2024
1 parent 8de0373 commit 63d7bf8
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,21 @@ enum class PayloadTypeEncoding {
H264,
RED,
RTX,
OPUS;
OPUS,
TELEPHONE_EVENT;

companion object {
private const val TEL_EVENT_TEXT = "telephone-event"

/**
* [valueOf] does not allow for case-insensitivity and can't be overridden, so this
* method should be used when creating an instance of this enum from a string
*/
fun createFrom(value: String): PayloadTypeEncoding {
return try {
if (value.lowercase() == TEL_EVENT_TEXT) {
return TELEPHONE_EVENT
}
valueOf(value.uppercase())
} catch (e: IllegalArgumentException) {
return OTHER
Expand All @@ -94,7 +100,11 @@ enum class PayloadTypeEncoding {
}

override fun toString(): String = with(StringBuffer()) {
append(super.toString())
if (super.equals(TELEPHONE_EVENT)) {
append(TEL_EVENT_TEXT)
} else {
append(super.toString())
}
toString()
}
}
Expand Down Expand Up @@ -145,6 +155,12 @@ class OpusPayloadType(
parameters: PayloadTypeParams = ConcurrentHashMap()
) : AudioPayloadType(pt, PayloadTypeEncoding.OPUS, parameters = parameters)

class TelephoneEventPayloadType(
pt: Byte,
clockRate: Int,
parameters: PayloadTypeParams = ConcurrentHashMap()
) : AudioPayloadType(pt, PayloadTypeEncoding.TELEPHONE_EVENT, clockRate, parameters)

class AudioRedPayloadType(
pt: Byte,
clockRate: Int = 48000,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,11 @@ import org.jitsi.nlj.format.PayloadTypeEncoding.OPUS
import org.jitsi.nlj.format.PayloadTypeEncoding.OTHER
import org.jitsi.nlj.format.PayloadTypeEncoding.RED
import org.jitsi.nlj.format.PayloadTypeEncoding.RTX
import org.jitsi.nlj.format.PayloadTypeEncoding.TELEPHONE_EVENT
import org.jitsi.nlj.format.PayloadTypeEncoding.VP8
import org.jitsi.nlj.format.PayloadTypeEncoding.VP9
import org.jitsi.nlj.format.RtxPayloadType
import org.jitsi.nlj.format.TelephoneEventPayloadType
import org.jitsi.nlj.format.VideoRedPayloadType
import org.jitsi.nlj.format.Vp8PayloadType
import org.jitsi.nlj.format.Vp9PayloadType
Expand Down Expand Up @@ -95,6 +97,7 @@ class PayloadTypeUtil {
H264 -> H264PayloadType(id, parameters, rtcpFeedbackSet)
RTX -> RtxPayloadType(id, parameters)
OPUS -> OpusPayloadType(id, parameters)
TELEPHONE_EVENT -> TelephoneEventPayloadType(id, clockRate, parameters)
RED -> when (mediaType) {
AUDIO -> AudioRedPayloadType(id, clockRate, parameters)
VIDEO -> VideoRedPayloadType(id, clockRate, parameters, rtcpFeedbackSet)
Expand Down

0 comments on commit 63d7bf8

Please sign in to comment.