talk-android/app/src/main/java/com/nextcloud/talk/call/MutableCallParticipantModel.java
Daniel Calviño Sánchez d72648379e Add model for (remote) call participants
Clients that modify the model would define the variables using the
mutable subclass, while clients that only need to access the model are
expected to use the read-only base class.

The read-only class provides an observer; as it is expected that the
model will be modified from background threads but observed from the
main thread the observer can be registered along a handler to be
notified on its thread, independently of on which thread the values were
set.

Currently there does not seem to be a need to observe each value on its
own, so the observer is notified in a coarse way when any value changes.

Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
2023-01-16 09:05:50 +00:00

68 lines
2.2 KiB
Java

/*
* Nextcloud Talk application
*
* @author Daniel Calviño Sánchez
* Copyright (C) 2022 Daniel Calviño Sánchez <danxuliu@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.nextcloud.talk.call;
import org.webrtc.MediaStream;
import org.webrtc.PeerConnection;
/**
* Mutable data model for (remote) call participants.
*
* There is no synchronization when setting the values; if needed, it should be handled by the clients of the model.
*/
public class MutableCallParticipantModel extends CallParticipantModel {
public MutableCallParticipantModel(String sessionId) {
super(sessionId);
}
public void setUserId(String userId) {
this.userId.setValue(userId);
}
public void setNick(String nick) {
this.nick.setValue(nick);
}
public void setIceConnectionState(PeerConnection.IceConnectionState iceConnectionState) {
this.iceConnectionState.setValue(iceConnectionState);
}
public void setMediaStream(MediaStream mediaStream) {
this.mediaStream.setValue(mediaStream);
}
public void setAudioAvailable(Boolean audioAvailable) {
this.audioAvailable.setValue(audioAvailable);
}
public void setVideoAvailable(Boolean videoAvailable) {
this.videoAvailable.setValue(videoAvailable);
}
public void setScreenIceConnectionState(PeerConnection.IceConnectionState screenIceConnectionState) {
this.screenIceConnectionState.setValue(screenIceConnectionState);
}
public void setScreenMediaStream(MediaStream screenMediaStream) {
this.screenMediaStream.setValue(screenMediaStream);
}
}