Skip to content

Commit

Permalink
Is/fix/native crash fix (#331)
Browse files Browse the repository at this point in the history
* - Native Crash Fix for Cancelling calls multiple times

* - Version Bump

* Added google-services.json file

* - Added Set Media Comment.
- Set Default Ringback volume to 1.0

* - Fix Code Format
  • Loading branch information
isaacakakpo1 authored Oct 10, 2023
1 parent 010e11f commit 65f4a7a
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 17 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,3 @@ lint/generated/
lint/outputs/
lint/tmp/
# lint/reports/
google-services.json
5 changes: 3 additions & 2 deletions app/src/main/java/com/telnyx/webrtc/sdk/ui/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ import kotlinx.android.synthetic.main.include_login_section.*
import kotlinx.android.synthetic.main.include_login_token_section.*
import timber.log.Timber
import java.io.IOException
import java.sql.Time
import java.util.*
import javax.inject.Inject

Expand Down Expand Up @@ -408,7 +409,7 @@ class MainActivity : AppCompatActivity() {
userManager.callerIdNumber,
userManager.callerIdNumber,
userManager.fcmToken,
RingtoneManager.getDefaultUri(RingtoneManager.TYPE_RINGTONE),
RingtoneManager.getDefaultUri(RingtoneManager.TYPE_RINGTONE),// or ringtone,
R.raw.ringback_tone,
LogLevel.ALL
)
Expand Down Expand Up @@ -441,7 +442,7 @@ class MainActivity : AppCompatActivity() {
sipCallerName,
sipCallerNumber,
fcmToken,
ringtone,
RingtoneManager.getDefaultUri(RingtoneManager.TYPE_RINGTONE), // or ringtone,
ringBackTone,
LogLevel.ALL
)
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/java/com/telnyx/webrtc/sdk/ui/MainViewModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import com.telnyx.webrtc.sdk.model.TxServerConfiguration
import com.telnyx.webrtc.sdk.verto.receive.ReceivedMessageBody
import com.telnyx.webrtc.sdk.verto.receive.SocketResponse
import dagger.hilt.android.lifecycle.HiltViewModel
import timber.log.Timber
import java.util.*
import javax.inject.Inject

Expand Down Expand Up @@ -86,6 +87,7 @@ class MainViewModel @Inject constructor(

fun doLoginWithCredentials(credentialConfig: CredentialConfig) {
telnyxClient?.credentialLogin(credentialConfig)
Timber.e("token_ ${credentialConfig.fcmToken}")
}

fun doLoginWithToken(tokenConfig: TokenConfig) {
Expand Down
4 changes: 2 additions & 2 deletions telnyx_rtc/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ apply plugin: 'maven-publish'
apply plugin: "com.bugsnag.android.gradle"

def getVersionName = { ->
return "v1.2.5"
return "1.2.6"
}

def getArtifactId = { ->
Expand Down Expand Up @@ -178,7 +178,7 @@ dependencies {
implementation deps.material
implementation deps.constraint_layout

implementation "io.getstream:stream-webrtc-android:1.0.0"
implementation "io.getstream:stream-webrtc-android:1.0.4"

implementation deps.gson
implementation deps.retrofit.runtime
Expand Down
4 changes: 2 additions & 2 deletions telnyx_rtc/src/main/java/com/telnyx/webrtc/sdk/Call.kt
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ class Call(
callerIdNumber = callerNumber,
clientState = clientState.encodeBase64(),
callId = inviteCallId,
destinationNumber = destinationNumber,
destinationNumber = destinationNumber
)
)
)
Expand Down Expand Up @@ -474,9 +474,9 @@ class Call(
val sdp = SessionDescription(SessionDescription.Type.ANSWER, stringSdp)

peerConnection?.onRemoteSessionReceived(sdp)

// Set internal flag for early retrieval of SDP - generally occurs when a ringback setting is applied in inbound call settings
earlySDP = true

} else {
// There was no SDP in the response, there was an error.
callStateLiveData.postValue(CallState.DONE)
Expand Down
2 changes: 1 addition & 1 deletion telnyx_rtc/src/main/java/com/telnyx/webrtc/sdk/Config.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ internal object Config {
const val TELNYX_DEV_HOST_ADDRESS = "rtcdev.telnyx.com"
const val TELNYX_PORT = 443
const val DEFAULT_TURN = "turn:turn.telnyx.com:3478?transport=tcp"
const val DEFAULT_STUN = "stun:stun.telnyx.com:3843"
const val DEFAULT_STUN = "stun:stun.telnyx.com:3478"
var USERNAME = "testuser"
var PASSWORD = "testpassword"
}
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ class TelnyxClient(
* (Get this from push notification - fcm data payload)
* required fot push calls to work
*/
fun connect(
fun connect(
providedServerConfig: TxServerConfiguration = TxServerConfiguration(),
txPushMetaData: String?
) {
Expand Down Expand Up @@ -840,6 +840,8 @@ class TelnyxClient(

override fun onMediaReceived(jsonObject: JsonObject) {
call?.onMediaReceived(jsonObject)
/*Stop local Media and play ringback from telnyx cloud*/
stopMediaPlayer()
}

override fun onOfferReceived(jsonObject: JsonObject) {
Expand Down
19 changes: 13 additions & 6 deletions telnyx_rtc/src/main/java/com/telnyx/webrtc/sdk/peer/Peer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,6 @@ internal class Peer(

private val rootEglBase: EglBase = EglBase.create()

init {
initPeerConnectionFactory(context)
}

private val iceServer = getIceServers()

Expand All @@ -53,6 +50,7 @@ internal class Peer(
*/
private fun getIceServers(): List<PeerConnection.IceServer> {
val iceServers: MutableList<PeerConnection.IceServer> = ArrayList()
Timber.e("start get ice server")
iceServers.add(
PeerConnection.IceServer.builder(providedStun).setUsername(USERNAME).setPassword(
PASSWORD
Expand All @@ -63,11 +61,12 @@ internal class Peer(
PASSWORD
).createIceServer()
)
Timber.e("end get ice server")
return iceServers
}

private val peerConnectionFactory by lazy { buildPeerConnectionFactory() }
private val peerConnection by lazy { buildPeerConnection(observer) }
private var peerConnection: PeerConnection? = null

/**
* Initiates our peer connection factory with the specified options
Expand Down Expand Up @@ -287,10 +286,18 @@ internal class Peer(
fun disconnect() {
peerConnection?.close()
peerConnection?.dispose()
peerConnection = null
}

fun release() {
disconnect()
peerConnectionFactory.dispose()
if (peerConnection != null) {
disconnect()
peerConnectionFactory.dispose()
}
}

init {
initPeerConnectionFactory(context)
peerConnection = buildPeerConnection(observer)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,7 @@ class TxSocket(
HttpUrl.Builder()
.scheme("https")
.host(host_address)
.addQueryParameter("rtc_ip", pushmetaData.rtcIP ?: "")
.addQueryParameter("rtc_port", pushmetaData.rtcPort?.toString() ?: "")
.addQueryParameter("voice_sdk_id", pushmetaData.voiceSdkId ?: "")
.build()
} else {
HttpUrl.Builder()
Expand Down

0 comments on commit 65f4a7a

Please sign in to comment.