-
Notifications
You must be signed in to change notification settings - Fork 731
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
Feature/fga/log tags voip #3723
Changes from 4 commits
115f00f
79c8ef7
e356e71
e3464f5
45a51d1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* Copyright (c) 2021 The Matrix.org Foundation C.I.C. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.matrix.android.sdk.api.logger | ||
|
||
/** | ||
* Parent class for custom logger tags. Can be used with Timber : | ||
* | ||
* val loggerTag = LoggerTag("MyTag", LoggerTag.VOIP) | ||
* Timber.tag(loggerTag.value).v("My log message") | ||
*/ | ||
open class LoggerTag(private val _value: String, private val parentTag: LoggerTag? = null) { | ||
|
||
object VOIP : LoggerTag("VOIP", null) | ||
|
||
val value: String | ||
get() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Affect instead of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yup, you're right |
||
return if (parentTag == null) { | ||
_value | ||
} else { | ||
"${parentTag.value}/$_value" | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,7 @@ | |
|
||
package org.matrix.android.sdk.internal.session.call | ||
|
||
import org.matrix.android.sdk.api.logger.LoggerTag | ||
import org.matrix.android.sdk.api.session.call.CallListener | ||
import org.matrix.android.sdk.api.session.call.CallState | ||
import org.matrix.android.sdk.api.session.call.MxCall | ||
|
@@ -36,6 +37,8 @@ import org.matrix.android.sdk.internal.session.SessionScope | |
import timber.log.Timber | ||
import javax.inject.Inject | ||
|
||
private val loggerTag = LoggerTag("CallSignalingHandler", LoggerTag.VOIP) | ||
|
||
@SessionScope | ||
internal class CallSignalingHandler @Inject constructor(private val activeCallHandler: ActiveCallHandler, | ||
private val mxCallFactory: MxCallFactory, | ||
|
@@ -111,12 +114,12 @@ internal class CallSignalingHandler @Inject constructor(private val activeCallHa | |
return | ||
} | ||
if (call.isOutgoing) { | ||
Timber.v("Got selectAnswer for an outbound call: ignoring") | ||
Timber.tag(loggerTag.value).v("Got selectAnswer for an outbound call: ignoring") | ||
return | ||
} | ||
val selectedPartyId = content.selectedPartyId | ||
if (selectedPartyId == null) { | ||
Timber.w("Got nonsensical select_answer with null selected_party_id: ignoring") | ||
Timber.tag(loggerTag.value).w("Got nonsensical select_answer with null selected_party_id: ignoring") | ||
return | ||
} | ||
callListenersDispatcher.onCallSelectAnswerReceived(content) | ||
|
@@ -130,7 +133,7 @@ internal class CallSignalingHandler @Inject constructor(private val activeCallHa | |
return | ||
} | ||
if (call.opponentPartyId != null && !call.partyIdsMatches(content)) { | ||
Timber.v("Ignoring candidates from party ID ${content.partyId} we have chosen party ID ${call.opponentPartyId}") | ||
Timber.tag(loggerTag.value).v("Ignoring candidates from party ID ${content.partyId} we have chosen party ID ${call.opponentPartyId}") | ||
return | ||
} | ||
callListenersDispatcher.onCallIceCandidateReceived(call, content) | ||
|
@@ -163,7 +166,7 @@ internal class CallSignalingHandler @Inject constructor(private val activeCallHa | |
// party ID must match (our chosen partner hanging up the call) or be undefined (we haven't chosen | ||
// a partner yet but we're treating the hangup as a reject as per VoIP v0) | ||
if (call.opponentPartyId != null && !call.partyIdsMatches(content)) { | ||
Timber.v("Ignoring hangup from party ID ${content.partyId} we have chosen party ID ${call.opponentPartyId}") | ||
Timber.tag(loggerTag.value).v("Ignoring hangup from party ID ${content.partyId} we have chosen party ID ${call.opponentPartyId}") | ||
return | ||
} | ||
if (call.state !is CallState.Ended) { | ||
|
@@ -180,12 +183,18 @@ internal class CallSignalingHandler @Inject constructor(private val activeCallHa | |
if (event.roomId == null || event.senderId == null) { | ||
return | ||
} | ||
val now = System.currentTimeMillis() | ||
val age = now - (event.ageLocalTs ?: now) | ||
if (age > 40_000 && event.getClearType() == EventType.CALL_INVITE) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok |
||
Timber.tag(loggerTag.value).w("Call invite is too old to ring.") | ||
return | ||
} | ||
val content = event.getClearContent().toModel<CallInviteContent>() ?: return | ||
|
||
content.callId ?: return | ||
if (invitedCallIds.contains(content.callId)) { | ||
// Call is already known, maybe due to fast lane. Ignore | ||
Timber.d("Ignoring already known call invite") | ||
Timber.tag(loggerTag.value).d("Ignoring already known call invite") | ||
return | ||
} | ||
val incomingCall = mxCallFactory.createIncomingCall( | ||
|
@@ -214,7 +223,8 @@ internal class CallSignalingHandler @Inject constructor(private val activeCallHa | |
callListenersDispatcher.onCallManagedByOtherSession(content.callId) | ||
} else { | ||
if (call.opponentPartyId != null) { | ||
Timber.v("Ignoring answer from party ID ${content.partyId} we already have an answer from ${call.opponentPartyId}") | ||
Timber.tag(loggerTag.value) | ||
.v("Ignoring answer from party ID ${content.partyId} we already have an answer from ${call.opponentPartyId}") | ||
return | ||
} | ||
mxCallFactory.updateOutgoingCallWithOpponentData(call, event.senderId, content, content.capabilities) | ||
|
@@ -231,7 +241,7 @@ internal class CallSignalingHandler @Inject constructor(private val activeCallHa | |
activeCallHandler.getCallWithId(it) | ||
} | ||
if (currentCall == null) { | ||
Timber.v("Call with id $callId is null") | ||
Timber.tag(loggerTag.value).v("Call with id $callId is null") | ||
} | ||
return currentCall | ||
} | ||
|
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.
, null
could be ommited but I can live with that :)