mirror of
https://github.com/nextcloud/talk-android
synced 2025-07-09 13:59:48 +01:00
Merge pull request #1886 from nextcloud/bugfix/1852/black-screen-or-single-videoframe-for-audiocalls
Use Transceivers instead of constraints to discard received video tracks
This commit is contained in:
commit
3e941edc24
@ -19,6 +19,7 @@ import com.nextcloud.talk.activities.CallActivity;
|
|||||||
import com.nextcloud.talk.utils.DisplayUtils;
|
import com.nextcloud.talk.utils.DisplayUtils;
|
||||||
|
|
||||||
import org.webrtc.MediaStream;
|
import org.webrtc.MediaStream;
|
||||||
|
import org.webrtc.MediaStreamTrack;
|
||||||
import org.webrtc.RendererCommon;
|
import org.webrtc.RendererCommon;
|
||||||
import org.webrtc.SurfaceViewRenderer;
|
import org.webrtc.SurfaceViewRenderer;
|
||||||
import org.webrtc.VideoTrack;
|
import org.webrtc.VideoTrack;
|
||||||
@ -140,7 +141,21 @@ public class ParticipantsAdapter extends BaseAdapter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean hasVideoStream(ParticipantDisplayItem participantDisplayItem, MediaStream mediaStream) {
|
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() {
|
private int scaleGridViewItemHeight() {
|
||||||
|
@ -44,9 +44,11 @@ import org.webrtc.DataChannel;
|
|||||||
import org.webrtc.IceCandidate;
|
import org.webrtc.IceCandidate;
|
||||||
import org.webrtc.MediaConstraints;
|
import org.webrtc.MediaConstraints;
|
||||||
import org.webrtc.MediaStream;
|
import org.webrtc.MediaStream;
|
||||||
|
import org.webrtc.MediaStreamTrack;
|
||||||
import org.webrtc.PeerConnection;
|
import org.webrtc.PeerConnection;
|
||||||
import org.webrtc.PeerConnectionFactory;
|
import org.webrtc.PeerConnectionFactory;
|
||||||
import org.webrtc.RtpReceiver;
|
import org.webrtc.RtpReceiver;
|
||||||
|
import org.webrtc.RtpTransceiver;
|
||||||
import org.webrtc.SdpObserver;
|
import org.webrtc.SdpObserver;
|
||||||
import org.webrtc.SessionDescription;
|
import org.webrtc.SessionDescription;
|
||||||
import org.webrtc.VideoTrack;
|
import org.webrtc.VideoTrack;
|
||||||
@ -256,6 +258,15 @@ public class PeerConnectionWrapper {
|
|||||||
return isMCUPublisher;
|
return isMCUPublisher;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean shouldReceiveVideo() {
|
||||||
|
for (MediaConstraints.KeyValuePair keyValuePair : mediaConstraints.mandatory) {
|
||||||
|
if ("OfferToReceiveVideo".equals(keyValuePair.getKey())) {
|
||||||
|
return !Boolean.parseBoolean(keyValuePair.getValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
private class MagicDataChannelObserver implements DataChannel.Observer {
|
private class MagicDataChannelObserver implements DataChannel.Observer {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -444,7 +455,22 @@ public class PeerConnectionWrapper {
|
|||||||
public void onSetSuccess() {
|
public void onSetSuccess() {
|
||||||
if (peerConnection != null) {
|
if (peerConnection != null) {
|
||||||
if (peerConnection.getLocalDescription() == null) {
|
if (peerConnection.getLocalDescription() == null) {
|
||||||
peerConnection.createAnswer(magicSdpObserver, mediaConstraints);
|
|
||||||
|
if (shouldReceiveVideo()) {
|
||||||
|
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) {
|
if (peerConnection.getRemoteDescription() != null) {
|
||||||
|
Loading…
Reference in New Issue
Block a user