Skip to content

Commit

Permalink
- Fix Stop Stats sending on every peer release
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacakakpo1 committed Aug 6, 2024
1 parent d0c7588 commit 8b7082a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 16 deletions.
24 changes: 9 additions & 15 deletions telnyx_rtc/src/main/java/com/telnyx/webrtc/sdk/Call.kt
Original file line number Diff line number Diff line change
Expand Up @@ -41,27 +41,27 @@ import kotlin.concurrent.timerTask
*/

data class CustomHeaders(val name: String, val value: String)
data class Call(
data class Call(
val context: Context,
val client: TelnyxClient,
var socket: TxSocket,
val sessionId: String,
val audioManager: AudioManager,
val providedTurn: String = Config.DEFAULT_TURN,
val providedStun: String = Config.DEFAULT_STUN,
) {
) {

companion object {
const val ICE_CANDIDATE_DELAY: Long = 400
}

internal var peerConnection: Peer? = null


internal var earlySDP = false

var inviteResponse:InviteResponse? = null
var answerResponse:AnswerResponse? = null

var inviteResponse: InviteResponse? = null
var answerResponse: AnswerResponse? = null
lateinit var callId: UUID

internal var telnyxSessionId: UUID? = null
Expand All @@ -85,19 +85,18 @@ data class CustomHeaders(val name: String, val value: String)
loudSpeakerLiveData.postValue(audioManager.isSpeakerphoneOn)
}

fun startDebug(){
fun startDebug() {
Timber.d("Peer connection debug started")

peerConnection?.startTimer()
}

fun stopDebug(){
fun stopDebug() {
Timber.d("Peer connection debug stopped")
peerConnection?.stopTimer()
}



/**
* Initiates a new call invitation
* @param callerName, the name to appear on the invitation
Expand Down Expand Up @@ -142,7 +141,7 @@ data class CustomHeaders(val name: String, val value: String)
destinationNumber: String,
customHeaders: Map<String, String>? = null
) {
client.acceptCall(callId, destinationNumber, customHeaders)
client.acceptCall(callId, destinationNumber, customHeaders)

}

Expand Down Expand Up @@ -183,7 +182,7 @@ data class CustomHeaders(val name: String, val value: String)
* @see [Call]
*/
fun endCall(callId: UUID) {
client.endCall(callId)
client.endCall(callId)
}

/**
Expand Down Expand Up @@ -220,7 +219,6 @@ data class CustomHeaders(val name: String, val value: String)
}



/**
* Either places a call on hold, or unholds a call based on the current [holdLiveData] value
* @param callId, the unique UUID of the call you want to place or remove from hold with the [sendHoldModifier] method
Expand Down Expand Up @@ -337,8 +335,6 @@ data class CustomHeaders(val name: String, val value: String)
}




fun JsonArray.toCustomHeaders(): ArrayList<CustomHeaders> {
val customHeaders = arrayListOf<CustomHeaders>()
return try {
Expand All @@ -355,8 +351,6 @@ data class CustomHeaders(val name: String, val value: String)
}




fun setCallRecovering() {
callStateLiveData.postValue(CallState.RECOVERING)
}
Expand Down
6 changes: 5 additions & 1 deletion telnyx_rtc/src/main/java/com/telnyx/webrtc/sdk/peer/Peer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ internal class Peer(
}

private val rootEglBase: EglBase = EglBase.create()
private var isDebugStats = false

internal var debugStatsId = UUID.randomUUID()

Expand Down Expand Up @@ -173,6 +174,7 @@ internal class Peer(
}

internal fun startTimer() {
isDebugStats = true
if (!client.debugReportStarted){
debugStatsId = UUID.randomUUID()
client.startStats(debugStatsId)
Expand Down Expand Up @@ -384,7 +386,9 @@ internal class Peer(
disconnect()
peerConnectionFactory.dispose()
}
stopTimer()
if (isDebugStats){
stopTimer()
}
}

init {
Expand Down

0 comments on commit 8b7082a

Please sign in to comment.