From 1aaebbaf47b6cdb99dfa4b4e9b923d5e151ba8db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karol=20K=C4=85kol?= Date: Mon, 10 Jun 2024 13:24:23 +0200 Subject: [PATCH] add more logs --- .../rtc/RTCEngineCommunication.kt | 34 ++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/FishjamClient/src/main/java/org/membraneframework/rtc/RTCEngineCommunication.kt b/FishjamClient/src/main/java/org/membraneframework/rtc/RTCEngineCommunication.kt index e780704..cff1f76 100644 --- a/FishjamClient/src/main/java/org/membraneframework/rtc/RTCEngineCommunication.kt +++ b/FishjamClient/src/main/java/org/membraneframework/rtc/RTCEngineCommunication.kt @@ -1,5 +1,6 @@ package org.membraneframework.rtc +import android.util.Log import com.google.gson.reflect.TypeToken import org.membraneframework.rtc.events.* import org.membraneframework.rtc.models.Endpoint @@ -7,7 +8,7 @@ import org.membraneframework.rtc.utils.Metadata import org.membraneframework.rtc.utils.SerializedMediaEvent import timber.log.Timber import kotlin.math.roundToLong - +const val TA = "RTCEC" internal class RTCEngineCommunication( private val engineListener: RTCEngineListener ) { @@ -16,10 +17,16 @@ internal class RTCEngineCommunication( } fun connect(endpointMetadata: Metadata) { + Log.i(TA, "connect") + Log.i(TA, endpointMetadata.toString()) + Log.i(TA,"") sendEvent(Connect(endpointMetadata)) } fun updateEndpointMetadata(endpointMetadata: Metadata) { + Log.i(TA, "updateEndpointMetadata") + Log.i(TA, endpointMetadata.toString()) + Log.i(TA,"") sendEvent(UpdateEndpointMetadata(endpointMetadata)) } @@ -27,6 +34,9 @@ internal class RTCEngineCommunication( trackId: String, trackMetadata: Metadata ) { + Log.i(TA, "updateTrackMetadata") + Log.i(TA, trackId + " "+ trackMetadata.toString()) + Log.i(TA,"") sendEvent(UpdateTrackMetadata(trackId, trackMetadata)) } @@ -34,6 +44,9 @@ internal class RTCEngineCommunication( trackId: String, encoding: TrackEncoding ) { + Log.i(TA, "setTargetTrackEncoding") + Log.i(TA, trackId + " " + encoding.toString()) + Log.i(TA,"") sendEvent( SelectEncoding( trackId, @@ -43,6 +56,8 @@ internal class RTCEngineCommunication( } fun renegotiateTracks() { + Log.i(TA, "renegotiateTracks") + Log.i(TA,"") sendEvent(RenegotiateTracks()) } @@ -50,6 +65,9 @@ internal class RTCEngineCommunication( sdp: String, sdpMLineIndex: Int ) { + Log.i(TA, "localCandidate") + Log.i(TA, sdp + " " + sdpMLineIndex) + Log.i(TA,"") sendEvent( LocalCandidate( sdp, @@ -63,6 +81,11 @@ internal class RTCEngineCommunication( trackIdToTrackMetadata: Map, midToTrackId: Map ) { + Log.i(TA, "sdpOffer") + Log.i(TA, sdp) + Log.i(TA, trackIdToTrackMetadata.toString()) + Log.i(TA, midToTrackId.toString()) + Log.i(TA,"") sendEvent( SdpOffer( sdp, @@ -73,20 +96,29 @@ internal class RTCEngineCommunication( } fun disconnect() { + Log.i(TA, "disconnect") + Log.i(TA,"") sendEvent(Disconnect()) } private fun sendEvent(event: SendableEvent) { + Log.i(TA, "sendEvent") + Log.i(TA, event.toString()) + Log.i(TA,"") val serializedMediaEvent = gson.toJson(event.serializeToMap()) engineListener.onSendMediaEvent(serializedMediaEvent) } private fun decodeEvent(event: SerializedMediaEvent): ReceivableEvent? { + val type = object : TypeToken>() {}.type val rawMessage: Map = gson.fromJson(event, type) ReceivableEvent.decode(rawMessage)?.let { + Log.i(TA, "decodeEvent") + Log.i(TA, it.toString()) + Log.i(TA,"") return it } ?: run { Timber.d("Failed to decode event $rawMessage")