Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Unwanted IPS from SDP #358

Merged
merged 4 commits into from
Nov 18, 2024
Merged

Remove Unwanted IPS from SDP #358

merged 4 commits into from
Nov 18, 2024

Conversation

isaacakakpo1
Copy link
Contributor

Copy link
Collaborator

@gbattistel gbattistel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple of small changes

callStateLiveData.postValue(CallState.ACTIVE)
callStateLiveData.value = CallState.ACTIVE
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this right?

In line 188 we are using postValue, which is thread-safe, and in the next line, we are using .value, which is not thread-safe, and they perform almost the same operation.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah they are the same, the issue is callStateLiveData.postValue(CallState.ACTIVE) doesent set the value somehow (it just updates the observers) and I have to observe the value from the TelnyxClient.kt class might I don't want to do. I could create a separate variablle for CallState.ACTIVE but then there's not single souce of truth.

For thread safety
@Override public void setValue(T value) { super.setValue(value); }

I believe it's just a setter. 
Now that you mkention though, I think there's a `getState()` method that might have the updated value. 

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I am actually using it :
if (call.getCallState().value != CallState.ACTIVE) but somehow it doesn't print the latest value. Let me see if I can make it work

Copy link
Contributor Author

@isaacakakpo1 isaacakakpo1 Nov 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMPORTANT NOTE: I just noticed that if you're in main thread and use postValue it will take a few more millis compared to setValue to dispatch the data. I had this happen when I fill a layout manually, with setValue it was instant but not with post.

-- Probably this is why it still has the previous value. I may have to observe then

https://stackoverflow.com/a/51299672/24361182

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated the mutable livedata with a flow and deprecated livedata. This was in Todo for sometime and I think I will want to deprecate all mutable livedata infavour of flow because it's threadsafe.

@@ -1274,6 +1279,7 @@ class TelnyxClient(
peerConnection?.onRemoteSessionReceived(sdp)

callStateLiveData.postValue(CallState.ACTIVE)
callStateLiveData.value = CallState.ACTIVE
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as before
In line 1281 we are using postValue, which is thread-safe, and in the next line, we are using .value, which is not thread-safe, and they perform almost the same operation.

peerConnection?.addIceCandidate(p0)
Timber.d("Event-IceCandidate Generated")
if (call.getCallState().value != CallState.ACTIVE){
peerConnection?.addIceCandidate(p0)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should check if peerConnection exist before printing the log that the ICE candidate was added


// Create new peer
peerConnection = Peer(
context, client, providedTurn, providedStun, callId.toString(),
object : PeerConnectionObserver() {
override fun onIceCandidate(p0: IceCandidate?) {
super.onIceCandidate(p0)
peerConnection?.addIceCandidate(p0)
Timber.d("Event-IceCandidate Generated")
if (call.getCallState().value != CallState.ACTIVE){
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A little change here. Please add a space between parentheses and braces ){

@@ -1309,6 +1315,7 @@ class TelnyxClient(
)
)
callStateLiveData.postValue(CallState.ACTIVE)
callStateLiveData.value = CallState.ACTIVE
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same comment as before

Timber.d("Event-IceCandidate Generated")
Timber.d("Event-IceCandidate ${calls[callId]?.getCallState()?.value}")
if (calls[callId]?.getCallState()?.value != CallState.ACTIVE){
peerConnection?.addIceCandidate(p0)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check if peerConnection exist before printing the log

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Peer connection should always exit on line 1425 peerConnection = Peer(

peerConnection?.addIceCandidate(p0)
Timber.d("On IceCandidate Added")
Timber.d("Event-IceCandidate Generated")
if (calls[callId]?.getCallState()?.value != CallState.ACTIVE){
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a space between parentheses and braces ){.

And check if peerConnection Exist before printing the log

@isaacakakpo1 isaacakakpo1 merged commit 9c07e5f into main Nov 18, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants