Signed-off-by: Mario Danic <mario@lovelyhq.com>
This commit is contained in:
Mario Danic 2020-04-11 10:49:36 +02:00
parent b9ff070884
commit 668b42e27e
No known key found for this signature in database
GPG Key ID: CDE0BBD2738C4CC0
7 changed files with 82 additions and 23 deletions

View File

@ -654,11 +654,11 @@ class CallController(args: Bundle) : BaseController() {
microphoneControlButton?.setImageResource(R.drawable.ic_mic_off_white_24px)
}
toggleMedia(audioOn, false)
toggleMedia(audioOn, false, false)
} else {
microphoneControlButton?.setImageResource(R.drawable.ic_mic_white_24px)
pulseAnimation!!.start()
toggleMedia(true, false)
toggleMedia(true, false, false)
}
if (isVoiceOnlyCall && !isConnectionEstablished) {
@ -709,7 +709,7 @@ class CallController(args: Bundle) : BaseController() {
cameraSwitchButton!!.visibility = View.GONE
}
toggleMedia(videoOn, true)
toggleMedia(videoOn, true, false)
} else if (activity != null && EffortlessPermissions.somePermissionPermanentlyDenied(
activity!!,
*PERMISSIONS_CAMERA
@ -746,9 +746,11 @@ class CallController(args: Bundle) : BaseController() {
private fun toggleMedia(
enable: Boolean,
video: Boolean
video: Boolean,
silencedByModerator: Boolean = false
) {
var message: String
val alreadySilenced = microphoneControlButton?.alpha == 0.7f
if (video) {
message = "videoOff"
if (enable) {
@ -789,6 +791,11 @@ class CallController(args: Bundle) : BaseController() {
}
}
if (!alreadySilenced && !enable && !video && silencedByModerator) {
microphoneControlButton?.setImageResource(R.drawable.ic_mic_off_white_24px)
Toast.makeText(context, R.string.silenced_by_moderator, Toast.LENGTH_SHORT).show()
}
sendDataChannelMessage(message)
}
@ -976,21 +983,6 @@ class CallController(args: Bundle) : BaseController() {
hasExternalSignalingServer = false
}
if (conversationUser!!.userId != "?") {
/*try {
userUtils.createOrUpdateUser(
null, null, null, null, null, null, null,
conversationUser.id, null, null,
LoganSquare.serialize(externalSignalingServer!!)
)
.subscribeOn(Schedulers.io())
.subscribe()
} catch (exception: IOException) {
Log.e(TAG, "Failed to serialize external signaling server")
}*/
}
if (signalingSettingsOverall.ocs.signalingSettings.stunServers != null) {
for (i in 0 until signalingSettingsOverall.ocs.signalingSettings.stunServers!!.size) {
iceServer = signalingSettingsOverall.ocs.signalingSettings.stunServers!![i]
@ -1305,6 +1297,9 @@ class CallController(args: Bundle) : BaseController() {
it, "video"
)
}
"mutedByModerator" -> {
toggleMedia(enable = false, video = false, silencedByModerator = true)
}
}
}
@ -1399,6 +1394,16 @@ class CallController(args: Bundle) : BaseController() {
magicPeerConnectionWrapper.addCandidate(iceCandidate)
}
"endOfCandidates" -> magicPeerConnectionWrapper.drainIceCandidates()
"control" -> {
when (ncSignalingMessage.payload.action) {
"forceMute" -> {
if (ncSignalingMessage.payload.peerId == callSession) {
toggleMedia(false, video = false, silencedByModerator = true)
}
}
else -> {}
}
}
else -> {
}
}
@ -1799,7 +1804,7 @@ class CallController(args: Bundle) : BaseController() {
(currentCallStatus == CallStatus.CALLING || isConnectionEstablished) && videoOn
&& enableVideo != localVideoTrack!!.enabled()
) {
toggleMedia(enableVideo, true)
toggleMedia(enableVideo, true, false)
}
}
} else if (peerConnectionEvent.peerConnectionEventType == PeerConnectionEvent
@ -2426,7 +2431,7 @@ class CallController(args: Bundle) : BaseController() {
isPTTActive = false
microphoneControlButton?.setImageResource(R.drawable.ic_mic_off_white_24px)
pulseAnimation!!.stop()
toggleMedia(false, false)
toggleMedia(false, false, false)
animateCallControls(false, 5000)
}
return true

View File

@ -45,4 +45,11 @@ public class NCMessagePayload {
@JsonField(name = "name")
public String name;
@JsonField(name = "action")
public String action;
@JsonField(name = "peerId")
public String peerId;
}

View File

@ -0,0 +1,14 @@
package com.nextcloud.talk.models.json.websocket
import com.bluelinelabs.logansquare.annotation.JsonField
import com.bluelinelabs.logansquare.annotation.JsonObject
@JsonObject
class ControlDataWebSocketMessage {
@JsonField(name = ["action"])
var action: String? = null
@JsonField(name = ["peerId"])
var peerId: String? = null
}

View File

@ -0,0 +1,10 @@
package com.nextcloud.talk.models.json.websocket
import com.bluelinelabs.logansquare.annotation.JsonField
import com.bluelinelabs.logansquare.annotation.JsonObject
@JsonObject
class ControlOverallWebSocketMessage : BaseWebSocketMessage() {
@JsonField(name = ["control"])
var controlWebSocketMessage: ControlWebSocketMessage? = null
}

View File

@ -0,0 +1,14 @@
package com.nextcloud.talk.models.json.websocket
import com.bluelinelabs.logansquare.annotation.JsonField
import com.bluelinelabs.logansquare.annotation.JsonObject
@JsonObject
class ControlWebSocketMessage {
@JsonField(name = ["recipient"])
var recipient: ActorWebSocketMessage? = null
@JsonField(name = ["data"])
var data: ControlDataWebSocketMessage? = null
}

View File

@ -309,10 +309,18 @@ class MagicWebSocketInstance internal constructor(
if (!TextUtils.isEmpty(ncSignalingMessage.from)) {
val messageHashMap =
HashMap<String, String>()
messageHashMap["jobId"] = Integer.toString(magicMap.add(ncSignalingMessage))
messageHashMap["jobId"] = magicMap.add(ncSignalingMessage).toString()
eventBus.post(WebSocketCommunicationEvent("signalingMessage", messageHashMap))
}
}
"control" -> {
val controlOverallWebSocketMessage = LoganSquare.parse(text, ControlOverallWebSocketMessage::class.java)
if (controlOverallWebSocketMessage.controlWebSocketMessage?.data?.peerId == sessionId) {
if (controlOverallWebSocketMessage.controlWebSocketMessage?.data?.action?.equals("forceMute") == true) {
eventBus.post(WebSocketCommunicationEvent("mutedByModerator", hashMapOf()))
}
}
}
"bye" -> {
isConnected = false
resumeId = ""

View File

@ -344,5 +344,6 @@
<string name="nc_search_for_more">Search for more participants</string>
<string name="nc_new_group">New group</string>
<string name="nc_search_empty_contacts">Where did they all hide?</string>
<string name="nc_reject_call">Reject </string>
<string name="nc_reject_call">Reject</string>
<string name="silenced_by_moderator">You were silenced by a moderator</string>
</resources>