Skip to content
This repository has been archived by the owner on May 10, 2024. It is now read-only.

Karkakol/add active simulcast encodings #56

Merged
merged 24 commits into from
Jan 25, 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
Empty file modified .githooks/pre-commit
100644 → 100755
Empty file.
10 changes: 2 additions & 8 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
*.iml
.gradle
/local.properties
/.idea/caches
/.idea/libraries
/.idea/modules.xml
/.idea/workspace.xml
/.idea/navEditor.xml
/.idea/assetWizardSettings.xml
/.idea/deploymentTargetDropDown.xml
/.idea/misc.xml

.DS_Store
/build
/captures
.externalNativeBuild
.cxx
/.idea/
3 changes: 0 additions & 3 deletions .idea/.gitignore

This file was deleted.

1 change: 0 additions & 1 deletion .idea/.name

This file was deleted.

122 changes: 0 additions & 122 deletions .idea/codeStyles/Project.xml

This file was deleted.

5 changes: 0 additions & 5 deletions .idea/codeStyles/codeStyleConfig.xml

This file was deleted.

9 changes: 0 additions & 9 deletions .idea/compiler.xml

This file was deleted.

21 changes: 0 additions & 21 deletions .idea/gradle.xml

This file was deleted.

37 changes: 0 additions & 37 deletions .idea/inspectionProfiles/Project_Default.xml

This file was deleted.

35 changes: 0 additions & 35 deletions .idea/jarRepositories.xml

This file was deleted.

6 changes: 0 additions & 6 deletions .idea/kotlinc.xml

This file was deleted.

6 changes: 0 additions & 6 deletions .idea/vcs.xml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import org.membraneframework.rtc.models.EncodingReason
import org.membraneframework.rtc.models.Endpoint
import org.membraneframework.rtc.models.RTCStats
import org.membraneframework.rtc.models.TrackContext
import org.membraneframework.rtc.models.TrackData
import org.membraneframework.rtc.models.VadStatus
import org.membraneframework.rtc.utils.ClosableCoroutineScope
import org.membraneframework.rtc.utils.Metadata
Expand Down Expand Up @@ -49,7 +50,7 @@ internal class InternalMembraneRTC
)

private var localEndpoint: Endpoint =
Endpoint(id = "", type = "webrtc", metadata = mapOf(), trackIdToMetadata = mapOf())
Endpoint(id = "", type = "webrtc", metadata = mapOf(), tracks = mapOf())

// mapping from endpoint's id to the endpoint himself
private val remoteEndpoints = HashMap<String, Endpoint>()
Expand Down Expand Up @@ -247,9 +248,15 @@ internal class InternalMembraneRTC
otherEndpoints.forEach {
this.remoteEndpoints[it.id] = it

for ((trackId, metadata) in it.trackIdToMetadata) {
for ((trackId, trackData) in it.tracks) {
val context =
TrackContext(track = null, endpoint = it, trackId = trackId, metadata = metadata ?: mapOf())
TrackContext(
track = null,
endpoint = it,
trackId = trackId,
metadata = trackData.metadata ?: mapOf(),
simulcastConfig = trackData.simulcastConfig
)

this.trackContexts[trackId] = context

Expand Down Expand Up @@ -283,7 +290,7 @@ internal class InternalMembraneRTC
return
}

val trackIds: List<String> = endpoint.trackIdToMetadata.keys.toList()
val trackIds: List<String> = endpoint.tracks.keys.toList()

trackIds.forEach {
trackContexts.remove(it)?.let { ctx ->
Expand Down Expand Up @@ -319,7 +326,7 @@ internal class InternalMembraneRTC
}
rtcEngineCommunication.sdpOffer(
offer.description,
localEndpoint.trackIdToMetadata,
localEndpoint.tracks.mapValues { it.value.metadata },
offer.midToTrackIdMapping
)
} catch (e: Exception) {
Expand Down Expand Up @@ -375,7 +382,7 @@ internal class InternalMembraneRTC

override fun onTracksAdded(
endpointId: String,
trackIdToMetadata: Map<String, Metadata?>
tracks: Map<String, TrackData>
) {
if (localEndpoint.id == endpointId) return

Expand All @@ -385,13 +392,19 @@ internal class InternalMembraneRTC
return
}

val updatedEndpoint = endpoint.copy(trackIdToMetadata = trackIdToMetadata)
val updatedEndpoint = endpoint.copy(tracks = tracks)

remoteEndpoints[updatedEndpoint.id] = updatedEndpoint

for ((trackId, metadata) in updatedEndpoint.trackIdToMetadata) {
for ((trackId, trackData) in updatedEndpoint.tracks) {
val context =
TrackContext(track = null, endpoint = endpoint, trackId = trackId, metadata = metadata ?: mapOf())
TrackContext(
track = null,
endpoint = endpoint,
trackId = trackId,
metadata = trackData.metadata ?: mapOf(),
simulcastConfig = trackData.simulcastConfig
)

this.trackContexts[trackId] = context

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,11 @@ internal class RTCEngineCommunication
event.data.trackId,
event.data.metadata
)
is TracksAdded -> engineListener.onTracksAdded(event.data.endpointId, event.data.trackIdToMetadata)
is TracksAdded ->
engineListener.onTracksAdded(
event.data.endpointId,
event.data.tracks
)
is TracksRemoved -> engineListener.onTracksRemoved(event.data.endpointId, event.data.trackIds)
is EncodingSwitched ->
engineListener.onTrackEncodingChanged(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package org.membraneframework.rtc

import org.membraneframework.rtc.events.OfferData
import org.membraneframework.rtc.models.Endpoint
import org.membraneframework.rtc.models.TrackData
import org.membraneframework.rtc.utils.Metadata
import org.membraneframework.rtc.utils.SerializedMediaEvent

Expand Down Expand Up @@ -41,7 +42,7 @@ internal interface RTCEngineListener {

fun onTracksAdded(
endpointId: String,
trackIdToMetadata: Map<String, Metadata?>
tracks: Map<String, TrackData>
)

fun onTracksRemoved(
Expand Down
Loading