mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-19 19:49:33 +01:00
Use Transceivers instead of constraints to discard received video tracks
After the migration from WebRTC from plan b to unified plan in commit86f20dc
the media constraints are ignored for creating an answer on a peer connection: > Offer to Receive Options/Constraints > > These constraints are passed to PeerConnection’s methods for creating SDP to > add placeholder media sections in case a sending track would not have already > created one. > > With Unified Plan semantics, these are still supported for creating offers > using a backwards compatibility shim (basically creating an RtpTransceiver if > one doesn’t exist). It is recommended to switch to the RtpTransceiver API > (example below). _They are no longer supported when creating answers._ > > [1] Because of that now all transceivers of type VIDEO will be stopped if it is only an audio call. After stopping the transceivers the status for the video tracks will be automatically set to ENDED. In the 'ParticipantsAdapter' it will be checked if the video tracks are ENDED. In that case the user avatar will be shown like before. Resolves: #1852 See: #1773, commit86f20dc
, [1] [1] https://docs.google.com/document/d/1PPHWV6108znP1tk_rkCnyagH9FK205hHeE9k5mhUzOg/edit#heading=h.9dcmkavg608r Signed-off-by: Tim Krüger <t@timkrueger.me>
This commit is contained in:
parent
9d8815a7a2
commit
346089cecf
@ -19,6 +19,7 @@ import com.nextcloud.talk.activities.CallActivity;
|
||||
import com.nextcloud.talk.utils.DisplayUtils;
|
||||
|
||||
import org.webrtc.MediaStream;
|
||||
import org.webrtc.MediaStreamTrack;
|
||||
import org.webrtc.RendererCommon;
|
||||
import org.webrtc.SurfaceViewRenderer;
|
||||
import org.webrtc.VideoTrack;
|
||||
@ -140,7 +141,21 @@ public class ParticipantsAdapter extends BaseAdapter {
|
||||
}
|
||||
|
||||
private boolean hasVideoStream(ParticipantDisplayItem participantDisplayItem, MediaStream mediaStream) {
|
||||
return mediaStream != null && mediaStream.videoTracks != null && mediaStream.videoTracks.size() > 0 && participantDisplayItem.isStreamEnabled();
|
||||
if (!participantDisplayItem.isStreamEnabled()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (mediaStream == null || mediaStream.videoTracks == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (VideoTrack t : mediaStream.videoTracks) {
|
||||
if (MediaStreamTrack.State.LIVE == t.state()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private int scaleGridViewItemHeight() {
|
||||
|
@ -44,9 +44,11 @@ import org.webrtc.DataChannel;
|
||||
import org.webrtc.IceCandidate;
|
||||
import org.webrtc.MediaConstraints;
|
||||
import org.webrtc.MediaStream;
|
||||
import org.webrtc.MediaStreamTrack;
|
||||
import org.webrtc.PeerConnection;
|
||||
import org.webrtc.PeerConnectionFactory;
|
||||
import org.webrtc.RtpReceiver;
|
||||
import org.webrtc.RtpTransceiver;
|
||||
import org.webrtc.SdpObserver;
|
||||
import org.webrtc.SessionDescription;
|
||||
import org.webrtc.VideoTrack;
|
||||
@ -256,6 +258,15 @@ public class PeerConnectionWrapper {
|
||||
return isMCUPublisher;
|
||||
}
|
||||
|
||||
private boolean isAudioCallOnly() {
|
||||
for (MediaConstraints.KeyValuePair keyValuePair : mediaConstraints.mandatory) {
|
||||
if ("OfferToReceiveVideo".equals(keyValuePair.getKey())) {
|
||||
return !Boolean.parseBoolean(keyValuePair.getValue());
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private class MagicDataChannelObserver implements DataChannel.Observer {
|
||||
|
||||
@Override
|
||||
@ -444,7 +455,22 @@ public class PeerConnectionWrapper {
|
||||
public void onSetSuccess() {
|
||||
if (peerConnection != null) {
|
||||
if (peerConnection.getLocalDescription() == null) {
|
||||
peerConnection.createAnswer(magicSdpObserver, mediaConstraints);
|
||||
|
||||
if (isAudioCallOnly()) {
|
||||
for (RtpTransceiver t : peerConnection.getTransceivers()) {
|
||||
if (t.getMediaType().equals(MediaStreamTrack.MediaType.MEDIA_TYPE_VIDEO)) {
|
||||
t.stop();
|
||||
}
|
||||
}
|
||||
Log.d(TAG, "Stop all Transceivers for MEDIA_TYPE_VIDEO.");
|
||||
}
|
||||
|
||||
/*
|
||||
Passed 'MediaConstraints' will be ignored by WebRTC when using UNIFIED PLAN.
|
||||
See for details: https://docs.google.com/document/d/1PPHWV6108znP1tk_rkCnyagH9FK205hHeE9k5mhUzOg/edit#heading=h.9dcmkavg608r
|
||||
*/
|
||||
peerConnection.createAnswer(magicSdpObserver, new MediaConstraints());
|
||||
|
||||
}
|
||||
|
||||
if (peerConnection.getRemoteDescription() != null) {
|
||||
|
Loading…
Reference in New Issue
Block a user