Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recognize jitsi_participant_codecList as an xmpp extension. #104

Merged
merged 2 commits into from
Feb 27, 2024
Merged
Show file tree
Hide file tree
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 @@ -73,6 +73,12 @@ public class ConferenceProperties
*/
public static final String KEY_VISITOR_COUNT = "visitor-count";

/**
* The property key used to indicate the set of video codecs supported by all visitors
* currently in the conference
*/
public static final String KEY_VISITOR_CODECS = "visitor-codecs";

/**
* The property key used to signal support for session restart to the current conference.
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Copyright @ 2023 - present 8x8, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jitsi.xmpp.extensions.jitsimeet

import org.jitsi.xmpp.extensions.AbstractPacketExtension

class JitsiParticipantCodecList : AbstractPacketExtension(NAMESPACE, ELEMENT) {
var codecs: List<String>
get() = text?.lowercase()?.split(',') ?: emptyList()
set(value) {
text = value.joinToString(separator = ",").lowercase()
}

companion object {
const val ELEMENT = "jitsi_participant_codecList"
const val NAMESPACE = "jabber:client"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
/*
* Copyright @ 2023 - present 8x8, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jitsi.xmpp.extensions.jitsimeet

import io.kotest.core.spec.style.ShouldSpec
import io.kotest.matchers.collections.shouldContainExactly
import io.kotest.matchers.shouldBe
import io.kotest.matchers.shouldNotBe
import org.jitsi.xmpp.extensions.DefaultPacketExtensionProvider
import org.jivesoftware.smack.provider.ProviderManager
import org.jivesoftware.smack.util.PacketParserUtils

class JitsiParticipantCodecListTest : ShouldSpec() {
private val sampleXml =
"""
<presence xmlns="jabber:client" xml:lang="en" to="focus@auth.example" from="test@conference.example/deadbeef">
<jitsi_participant_codecList>vp9,vp8,h264</jitsi_participant_codecList>
</presence>
""".trimIndent()

init {
context("Getting a codec list set from its text") {
val codecList = JitsiParticipantCodecList()
codecList.text = "vp9,vp8,h264"
should("Parse as the appropriate list of codecs") {
codecList.codecs.shouldContainExactly("vp9", "vp8", "h264")
}
}
context("codec values in text") {
val codecList = JitsiParticipantCodecList()
codecList.text = "VP9,VP8,H264"
should("be case-normalized when read") {
codecList.codecs.shouldContainExactly("vp9", "vp8", "h264")
}
}
context("Setting a codec list") {
val codecList = JitsiParticipantCodecList()
codecList.codecs = listOf("vp9", "vp8", "h264")
should("Be serialized properly") {
codecList.text shouldBe "vp9,vp8,h264"
}
}
context("Codec values as set") {
val codecList = JitsiParticipantCodecList()
codecList.codecs = listOf("VP9", "VP8", "H264")
should("be case-normalized when serialized") {
codecList.text shouldBe "vp9,vp8,h264"
}
}
context("Parsing a Presence stanza containing a codec list") {
ProviderManager.addExtensionProvider(
JitsiParticipantCodecList.ELEMENT,
JitsiParticipantCodecList.NAMESPACE,
DefaultPacketExtensionProvider(JitsiParticipantCodecList::class.java)
)

val parser = PacketParserUtils.getParserFor(sampleXml)
val presence = PacketParserUtils.parsePresence(parser)
val codecList = presence.getExtension(JitsiParticipantCodecList::class.java)
should("Parse properly") {
codecList shouldNotBe null
codecList.codecs.shouldContainExactly("vp9", "vp8", "h264")
}
}
}
}
Loading