Skip to content

Commit

Permalink
feat: Add an endpointId field to StartEvent. (#207)
Browse files Browse the repository at this point in the history
  • Loading branch information
bgrozev authored Oct 23, 2024
1 parent 175c44b commit a2c5ec1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,12 @@ data class MediaFormat(
)
data class Start(
val tag: String,
val mediaFormat: MediaFormat
val mediaFormat: MediaFormat,
val customParameters: CustomParameters? = null
)

data class CustomParameters(
val endpointId: String?
)

data class Media(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package org.jitsi.mediajson
import com.fasterxml.jackson.databind.exc.InvalidFormatException
import io.kotest.assertions.throwables.shouldThrow
import io.kotest.core.spec.style.ShouldSpec
import io.kotest.matchers.nulls.shouldNotBeNull
import io.kotest.matchers.shouldBe
import io.kotest.matchers.types.shouldBeInstanceOf
import org.json.simple.JSONObject
Expand Down Expand Up @@ -45,6 +46,7 @@ class MediaJsonTest : ShouldSpec() {
val start = parsed["start"]
start.shouldBeInstanceOf<JSONObject>()
start["tag"] shouldBe tag
start["customParameters"] shouldBe null
val mediaFormat = start["mediaFormat"]
mediaFormat.shouldBeInstanceOf<JSONObject>()
mediaFormat["encoding"] shouldBe enc
Expand Down Expand Up @@ -105,7 +107,8 @@ class MediaJsonTest : ShouldSpec() {
"channels": 1
},
"customParameters": {
"text1":"12312"
"text1":"12312",
"endpointId": "abcdabcd"
}
}
}
Expand All @@ -119,6 +122,8 @@ class MediaJsonTest : ShouldSpec() {
parsed.start.mediaFormat.encoding shouldBe "audio/x-mulaw"
parsed.start.mediaFormat.sampleRate shouldBe 8000
parsed.start.mediaFormat.channels shouldBe 1
parsed.start.customParameters.shouldNotBeNull()
parsed.start.customParameters?.endpointId shouldBe "abcdabcd"
}
context("Start with sequence number as int") {
val parsed = Event.parse(
Expand All @@ -134,7 +139,8 @@ class MediaJsonTest : ShouldSpec() {
"channels": 1
},
"customParameters": {
"text1":"12312"
"text1":"12312",
"endpointId":"abcdabcd"
}
}
}
Expand All @@ -143,6 +149,8 @@ class MediaJsonTest : ShouldSpec() {

parsed.shouldBeInstanceOf<StartEvent>()
parsed.sequenceNumber shouldBe 0
parsed.start.customParameters.shouldNotBeNull()
parsed.start.customParameters?.endpointId shouldBe "abcdabcd"
}
context("Media") {
val parsed = Event.parse(
Expand Down

0 comments on commit a2c5ec1

Please sign in to comment.