From a2c5ec1ae6beb7f1ee444788e6528dc03f2ba855 Mon Sep 17 00:00:00 2001 From: bgrozev Date: Tue, 22 Oct 2024 19:15:38 -0500 Subject: [PATCH] feat: Add an endpointId field to StartEvent. (#207) --- .../src/main/kotlin/org/jitsi/mediajson/MediaJson.kt | 7 ++++++- .../test/kotlin/org/jitsi/mediajson/MediaJsonTest.kt | 12 ++++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/jicoco-mediajson/src/main/kotlin/org/jitsi/mediajson/MediaJson.kt b/jicoco-mediajson/src/main/kotlin/org/jitsi/mediajson/MediaJson.kt index c937df8..0499003 100644 --- a/jicoco-mediajson/src/main/kotlin/org/jitsi/mediajson/MediaJson.kt +++ b/jicoco-mediajson/src/main/kotlin/org/jitsi/mediajson/MediaJson.kt @@ -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( diff --git a/jicoco-mediajson/src/test/kotlin/org/jitsi/mediajson/MediaJsonTest.kt b/jicoco-mediajson/src/test/kotlin/org/jitsi/mediajson/MediaJsonTest.kt index 92623d3..c044d63 100644 --- a/jicoco-mediajson/src/test/kotlin/org/jitsi/mediajson/MediaJsonTest.kt +++ b/jicoco-mediajson/src/test/kotlin/org/jitsi/mediajson/MediaJsonTest.kt @@ -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 @@ -45,6 +46,7 @@ class MediaJsonTest : ShouldSpec() { val start = parsed["start"] start.shouldBeInstanceOf() start["tag"] shouldBe tag + start["customParameters"] shouldBe null val mediaFormat = start["mediaFormat"] mediaFormat.shouldBeInstanceOf() mediaFormat["encoding"] shouldBe enc @@ -105,7 +107,8 @@ class MediaJsonTest : ShouldSpec() { "channels": 1 }, "customParameters": { - "text1":"12312" + "text1":"12312", + "endpointId": "abcdabcd" } } } @@ -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( @@ -134,7 +139,8 @@ class MediaJsonTest : ShouldSpec() { "channels": 1 }, "customParameters": { - "text1":"12312" + "text1":"12312", + "endpointId":"abcdabcd" } } } @@ -143,6 +149,8 @@ class MediaJsonTest : ShouldSpec() { parsed.shouldBeInstanceOf() parsed.sequenceNumber shouldBe 0 + parsed.start.customParameters.shouldNotBeNull() + parsed.start.customParameters?.endpointId shouldBe "abcdabcd" } context("Media") { val parsed = Event.parse(