Skip to content

Commit

Permalink
ref: Reuse ParticipantInfo.toEndpoint.
Browse files Browse the repository at this point in the history
  • Loading branch information
bgrozev committed Sep 29, 2022
1 parent 93ad804 commit 20b9311
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,19 +77,7 @@ internal class Colibri2Session(
internal fun sendAllocationRequest(participant: ParticipantInfo): StanzaCollector {

val request = createRequest(!created)
val endpoint = Colibri2Endpoint.getBuilder().apply {
setId(participant.id)
setCreate(true)
if (participant.sources.isNotEmpty()) {
setSources(participant.sources.toColibriMediaSources())
}
setStatsId(participant.statsId)
if (participant.supportsSourceNames) {
addCapability(Capability.CAP_SOURCE_NAME_SUPPORT)
}
if (participant.useSsrcRewriting) {
addCapability(Capability.CAP_SSRC_REWRITING_SUPPORT)
}
val endpoint = participant.toEndpoint(create = true, expire = false).apply {
if (participant.audioMuted || participant.videoMuted) {
setForceMute(participant.audioMuted, participant.videoMuted)
}
Expand Down Expand Up @@ -417,7 +405,7 @@ internal class Colibri2Session(
setId(id)
}
val endpoints = Endpoints.getBuilder()
endpoints.addEndpoint(participant.toEndpoint(create = create, expire = false))
endpoints.addEndpoint(participant.toEndpoint(create = create, expire = false).build())
relay.setEndpoints(endpoints.build())
request.addRelay(relay.build())
sendRequest(request.build(), "Relay.updateParticipant")
Expand All @@ -429,7 +417,7 @@ internal class Colibri2Session(
val relay = Colibri2Relay.getBuilder().apply { setId(id) }
val endpoints = Endpoints.getBuilder()

participants.forEach { endpoints.addEndpoint(it.toEndpoint(create = false, expire = true)) }
participants.forEach { endpoints.addEndpoint(it.toEndpoint(create = false, expire = true).build()) }

relay.setEndpoints(endpoints.build())
request.addRelay(relay.build())
Expand Down Expand Up @@ -461,7 +449,7 @@ internal class Colibri2Session(
)

val endpoints = Endpoints.getBuilder()
participants.forEach { endpoints.addEndpoint(it.toEndpoint(create = true, expire = false)) }
participants.forEach { endpoints.addEndpoint(it.toEndpoint(create = true, expire = false).build()) }
relay.setEndpoints(endpoints.build())

relay.setTransport(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ internal fun ParticipantInfo.toEndpoint(
create: Boolean,
/** Whether the request should have the "expire" flag set. */
expire: Boolean
): Colibri2Endpoint = Colibri2Endpoint.getBuilder().apply {
): Colibri2Endpoint.Builder = Colibri2Endpoint.getBuilder().apply {
setId(id)
if (create) {
setCreate(true)
Expand All @@ -124,7 +124,7 @@ internal fun ParticipantInfo.toEndpoint(
if (expire) {
setExpire(true)
}
}.build()
}

internal fun AbstractXMPPConnection.sendIqAndHandleResponseAsync(iq: IQ, block: (IQ?) -> Unit) {
val stanzaCollector = createStanzaCollectorAndSend(iq)
Expand Down

0 comments on commit 20b9311

Please sign in to comment.