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

Commit

Permalink
add more logs
Browse files Browse the repository at this point in the history
  • Loading branch information
karkakol committed Jun 10, 2024
1 parent b27d60f commit 1aaebba
Showing 1 changed file with 33 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
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
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
) {
Expand All @@ -16,24 +17,36 @@ 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))
}

fun updateTrackMetadata(
trackId: String,
trackMetadata: Metadata
) {
Log.i(TA, "updateTrackMetadata")
Log.i(TA, trackId + " "+ trackMetadata.toString())
Log.i(TA,"")
sendEvent(UpdateTrackMetadata(trackId, trackMetadata))
}

fun setTargetTrackEncoding(
trackId: String,
encoding: TrackEncoding
) {
Log.i(TA, "setTargetTrackEncoding")
Log.i(TA, trackId + " " + encoding.toString())
Log.i(TA,"")
sendEvent(
SelectEncoding(
trackId,
Expand All @@ -43,13 +56,18 @@ internal class RTCEngineCommunication(
}

fun renegotiateTracks() {
Log.i(TA, "renegotiateTracks")
Log.i(TA,"")
sendEvent(RenegotiateTracks())
}

fun localCandidate(
sdp: String,
sdpMLineIndex: Int
) {
Log.i(TA, "localCandidate")
Log.i(TA, sdp + " " + sdpMLineIndex)
Log.i(TA,"")
sendEvent(
LocalCandidate(
sdp,
Expand All @@ -63,6 +81,11 @@ internal class RTCEngineCommunication(
trackIdToTrackMetadata: Map<String, Metadata?>,
midToTrackId: Map<String, String>
) {
Log.i(TA, "sdpOffer")
Log.i(TA, sdp)
Log.i(TA, trackIdToTrackMetadata.toString())
Log.i(TA, midToTrackId.toString())
Log.i(TA,"")
sendEvent(
SdpOffer(
sdp,
Expand All @@ -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<Map<String, Any?>>() {}.type

val rawMessage: Map<String, Any?> = 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")
Expand Down

0 comments on commit 1aaebba

Please sign in to comment.