diff --git a/MembraneRTC/src/main/java/org/membraneframework/rtc/InternalMembraneRTC.kt b/MembraneRTC/src/main/java/org/membraneframework/rtc/InternalMembraneRTC.kt index a45f13c..b2f2a8d 100644 --- a/MembraneRTC/src/main/java/org/membraneframework/rtc/InternalMembraneRTC.kt +++ b/MembraneRTC/src/main/java/org/membraneframework/rtc/InternalMembraneRTC.kt @@ -248,7 +248,8 @@ internal class InternalMembraneRTC this.remoteEndpoints[it.id] = it for ((trackId, metadata) in it.trackIdToMetadata) { - val context = TrackContext(track = null, endpoint = it, trackId = trackId, metadata = metadata) + val context = + TrackContext(track = null, endpoint = it, trackId = trackId, metadata = metadata ?: mapOf()) this.trackContexts[trackId] = context @@ -295,7 +296,7 @@ internal class InternalMembraneRTC override fun onEndpointUpdated( endpointId: String, - endpointMetadata: Metadata + endpointMetadata: Metadata? ) { val endpoint = remoteEndpoints.remove(endpointId) ?: run { @@ -374,7 +375,7 @@ internal class InternalMembraneRTC override fun onTracksAdded( endpointId: String, - trackIdToMetadata: Map + trackIdToMetadata: Map ) { if (localEndpoint.id == endpointId) return @@ -389,7 +390,8 @@ internal class InternalMembraneRTC remoteEndpoints[updatedEndpoint.id] = updatedEndpoint for ((trackId, metadata) in updatedEndpoint.trackIdToMetadata) { - val context = TrackContext(track = null, endpoint = endpoint, trackId = trackId, metadata = metadata) + val context = + TrackContext(track = null, endpoint = endpoint, trackId = trackId, metadata = metadata ?: mapOf()) this.trackContexts[trackId] = context @@ -424,7 +426,7 @@ internal class InternalMembraneRTC override fun onTrackUpdated( endpointId: String, trackId: String, - metadata: Metadata + metadata: Metadata? ) { val endpoint = remoteEndpoints[endpointId] ?: run { @@ -438,7 +440,7 @@ internal class InternalMembraneRTC return } - context.metadata = metadata + context.metadata = metadata ?: mapOf() val updatedEndpoint = endpoint diff --git a/MembraneRTC/src/main/java/org/membraneframework/rtc/RTCEngineCommunication.kt b/MembraneRTC/src/main/java/org/membraneframework/rtc/RTCEngineCommunication.kt index fefa00b..9bb50d2 100644 --- a/MembraneRTC/src/main/java/org/membraneframework/rtc/RTCEngineCommunication.kt +++ b/MembraneRTC/src/main/java/org/membraneframework/rtc/RTCEngineCommunication.kt @@ -67,7 +67,7 @@ internal class RTCEngineCommunication fun sdpOffer( sdp: String, - trackIdToTrackMetadata: Map, + trackIdToTrackMetadata: Map, midToTrackId: Map ) { sendEvent( diff --git a/MembraneRTC/src/main/java/org/membraneframework/rtc/RTCEngineListener.kt b/MembraneRTC/src/main/java/org/membraneframework/rtc/RTCEngineListener.kt index aa01293..dd446e9 100644 --- a/MembraneRTC/src/main/java/org/membraneframework/rtc/RTCEngineListener.kt +++ b/MembraneRTC/src/main/java/org/membraneframework/rtc/RTCEngineListener.kt @@ -19,7 +19,7 @@ internal interface RTCEngineListener { fun onEndpointUpdated( endpointId: String, - endpointMetadata: Metadata + endpointMetadata: Metadata? = mapOf() ) fun onOfferData( @@ -41,7 +41,7 @@ internal interface RTCEngineListener { fun onTracksAdded( endpointId: String, - trackIdToMetadata: Map + trackIdToMetadata: Map ) fun onTracksRemoved( @@ -52,7 +52,7 @@ internal interface RTCEngineListener { fun onTrackUpdated( endpointId: String, trackId: String, - metadata: Metadata + metadata: Metadata? = mapOf() ) fun onTrackEncodingChanged( diff --git a/MembraneRTC/src/main/java/org/membraneframework/rtc/events/Event.kt b/MembraneRTC/src/main/java/org/membraneframework/rtc/events/Event.kt index cc8a974..d0d4761 100644 --- a/MembraneRTC/src/main/java/org/membraneframework/rtc/events/Event.kt +++ b/MembraneRTC/src/main/java/org/membraneframework/rtc/events/Event.kt @@ -30,13 +30,13 @@ internal inline fun I.convert(): O { sealed class SendableEvent data class Connect(val type: String, val data: Data) : SendableEvent() { - data class Data(val metadata: Metadata) + data class Data(val metadata: Metadata?) - constructor(metadata: Metadata) : this("connect", Data(metadata)) + constructor(metadata: Metadata? = mapOf()) : this("connect", Data(metadata)) } data class SdpOffer(val type: String, val data: Payload) : SendableEvent() { - constructor(sdp: String, trackIdToTrackMetadata: Map, midToTrackId: Map) : + constructor(sdp: String, trackIdToTrackMetadata: Map, midToTrackId: Map) : this( "custom", mapOf( @@ -96,15 +96,18 @@ data class SelectEncoding(val type: String, val data: Payload) : SendableEvent() } data class UpdateEndpointMetadata(val type: String, val data: Data) : SendableEvent() { - data class Data(val metadata: Metadata) + data class Data(val metadata: Metadata?) - constructor(metadata: Metadata) : this("updateEndpointMetadata", Data(metadata)) + constructor(metadata: Metadata? = mapOf()) : this("updateEndpointMetadata", Data(metadata)) } data class UpdateTrackMetadata(val type: String, val data: Data) : SendableEvent() { - data class Data(val trackId: String, val trackMetadata: Metadata) + data class Data(val trackId: String, val trackMetadata: Metadata?) - constructor(trackId: String, trackMetadata: Metadata) : this("updateTrackMetadata", Data(trackId, trackMetadata)) + constructor(trackId: String, trackMetadata: Metadata = mapOf()) : this( + "updateTrackMetadata", + Data(trackId, trackMetadata) + ) } data class Disconnect(val type: String) : SendableEvent() { @@ -231,13 +234,13 @@ data class EndpointAdded(val type: ReceivableEventType, val data: Data) : Receiv data class Data( val id: String, val type: String, - val metadata: Metadata, - val trackIdToMetadata: Map + val metadata: Metadata?, + val trackIdToMetadata: Map ) } data class EndpointUpdated(val type: ReceivableEventType, val data: Data) : ReceivableEvent() { - data class Data(val id: String, val metadata: Metadata) + data class Data(val id: String, val metadata: Metadata?) } data class EndpointRemoved(val type: ReceivableEventType, val data: Data) : ReceivableEvent() { @@ -257,7 +260,7 @@ data class OfferData(val type: ReceivableEventType, val data: Data) : Receivable } data class TracksAdded(val type: ReceivableEventType, val data: Data) : ReceivableEvent() { - data class Data(val endpointId: String, val trackIdToMetadata: Map) + data class Data(val endpointId: String, val trackIdToMetadata: Map) } data class TracksRemoved(val type: ReceivableEventType, val data: Data) : ReceivableEvent() { @@ -265,7 +268,7 @@ data class TracksRemoved(val type: ReceivableEventType, val data: Data) : Receiv } data class TrackUpdated(val type: ReceivableEventType, val data: Data) : ReceivableEvent() { - data class Data(val endpointId: String, val trackId: String, val metadata: Metadata) + data class Data(val endpointId: String, val trackId: String, val metadata: Metadata?) } data class SdpAnswer(val type: ReceivableEventType, val data: Data) : ReceivableEvent() { diff --git a/MembraneRTC/src/main/java/org/membraneframework/rtc/models/Endpoint.kt b/MembraneRTC/src/main/java/org/membraneframework/rtc/models/Endpoint.kt index 3797ca8..0aa2aa2 100644 --- a/MembraneRTC/src/main/java/org/membraneframework/rtc/models/Endpoint.kt +++ b/MembraneRTC/src/main/java/org/membraneframework/rtc/models/Endpoint.kt @@ -6,7 +6,7 @@ data class Endpoint( val id: String, val type: String, val metadata: Metadata? = mapOf(), - val trackIdToMetadata: Map = mapOf() + val trackIdToMetadata: Map = mapOf() ) { fun withTrack( trackId: String, diff --git a/MembraneRTC/src/main/java/org/membraneframework/rtc/models/TrackContext.kt b/MembraneRTC/src/main/java/org/membraneframework/rtc/models/TrackContext.kt index 430c3c0..3ced8e4 100644 --- a/MembraneRTC/src/main/java/org/membraneframework/rtc/models/TrackContext.kt +++ b/MembraneRTC/src/main/java/org/membraneframework/rtc/models/TrackContext.kt @@ -19,7 +19,7 @@ fun interface OnVoiceActivityChangedListener { * @property trackId Track id. It is generated by RTC engine and takes form `endpoint_id:`. * @property metadata Any info that was passed in MembraneWebRTC.createVideoTrack/MembraneWebRTC.createAudioTrack */ -class TrackContext(track: RemoteTrack?, val endpoint: Endpoint, val trackId: String, metadata: Metadata) { +class TrackContext(track: RemoteTrack?, val endpoint: Endpoint, val trackId: String, metadata: Metadata = mapOf()) { private var onTrackEncodingChangeListener: (OnEncodingChangedListener)? = null private var onVadNotificationListener: (OnVoiceActivityChangedListener)? = null