-
Notifications
You must be signed in to change notification settings - Fork 4
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
Conversation
Outbound Inbound Attach
There was a problem hiding this 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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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){ |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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){ |
There was a problem hiding this comment.
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
WebRTC-2355 - Ticket Description.