use of org.webrtc.SessionDescription in project react-native-webrtc by react-native-webrtc.
the class PeerConnectionObserver method onRemoveStream.
@Override
public void onRemoveStream(MediaStream mediaStream) {
String streamReactTag = getReactTagForStream(mediaStream);
if (streamReactTag == null) {
Log.w(TAG, "onRemoveStream - no remote stream for id: " + mediaStream.getId());
return;
}
for (VideoTrack track : mediaStream.videoTracks) {
this.videoTrackAdapters.removeAdapter(track);
this.remoteTracks.remove(track.id());
}
for (AudioTrack track : mediaStream.audioTracks) {
this.remoteTracks.remove(track.id());
}
this.remoteStreams.remove(streamReactTag);
WritableMap params = Arguments.createMap();
params.putInt("id", id);
params.putString("streamId", streamReactTag);
SessionDescription newSdp = peerConnection.getRemoteDescription();
WritableMap newSdpMap = Arguments.createMap();
newSdpMap.putString("type", newSdp.type.canonicalForm());
newSdpMap.putString("sdp", newSdp.description);
params.putMap("sdp", newSdpMap);
webRTCModule.sendEvent("peerConnectionRemovedStream", params);
}
use of org.webrtc.SessionDescription in project react-native-webrtc by react-native-webrtc.
the class PeerConnectionObserver method onIceGatheringChange.
@Override
public void onIceGatheringChange(PeerConnection.IceGatheringState iceGatheringState) {
Log.d(TAG, "onIceGatheringChange" + iceGatheringState.name());
WritableMap params = Arguments.createMap();
params.putInt("id", id);
params.putString("iceGatheringState", iceGatheringStateString(iceGatheringState));
if (iceGatheringState == PeerConnection.IceGatheringState.COMPLETE) {
SessionDescription newSdp = peerConnection.getLocalDescription();
WritableMap newSdpMap = Arguments.createMap();
newSdpMap.putString("type", newSdp.type.canonicalForm());
newSdpMap.putString("sdp", newSdp.description);
params.putMap("sdp", newSdpMap);
}
webRTCModule.sendEvent("peerConnectionIceGatheringChanged", params);
}
use of org.webrtc.SessionDescription in project Signal-Android by WhisperSystems.
the class PeerConnectionWrapper method createOffer.
public SessionDescription createOffer(MediaConstraints mediaConstraints) throws PeerConnectionException {
final SettableFuture<SessionDescription> future = new SettableFuture<>();
peerConnection.createOffer(new SdpObserver() {
@Override
public void onCreateSuccess(SessionDescription sdp) {
future.set(sdp);
}
@Override
public void onCreateFailure(String error) {
future.setException(new PeerConnectionException(error));
}
@Override
public void onSetSuccess() {
throw new AssertionError();
}
@Override
public void onSetFailure(String error) {
throw new AssertionError();
}
}, mediaConstraints);
try {
return correctSessionDescription(future.get());
} catch (InterruptedException e) {
throw new AssertionError(e);
} catch (ExecutionException e) {
throw new PeerConnectionException(e);
}
}
use of org.webrtc.SessionDescription in project Signal-Android by WhisperSystems.
the class PeerConnectionWrapper method setRemoteDescription.
public void setRemoteDescription(SessionDescription sdp) throws PeerConnectionException {
final SettableFuture<Boolean> future = new SettableFuture<>();
peerConnection.setRemoteDescription(new SdpObserver() {
@Override
public void onCreateSuccess(SessionDescription sdp) {
}
@Override
public void onCreateFailure(String error) {
}
@Override
public void onSetSuccess() {
future.set(true);
}
@Override
public void onSetFailure(String error) {
future.setException(new PeerConnectionException(error));
}
}, sdp);
try {
future.get();
} catch (InterruptedException e) {
throw new AssertionError(e);
} catch (ExecutionException e) {
throw new PeerConnectionException(e);
}
}
use of org.webrtc.SessionDescription in project Signal-Android by WhisperSystems.
the class PeerConnectionWrapper method createAnswer.
public SessionDescription createAnswer(MediaConstraints mediaConstraints) throws PeerConnectionException {
final SettableFuture<SessionDescription> future = new SettableFuture<>();
peerConnection.createAnswer(new SdpObserver() {
@Override
public void onCreateSuccess(SessionDescription sdp) {
future.set(sdp);
}
@Override
public void onCreateFailure(String error) {
future.setException(new PeerConnectionException(error));
}
@Override
public void onSetSuccess() {
throw new AssertionError();
}
@Override
public void onSetFailure(String error) {
throw new AssertionError();
}
}, mediaConstraints);
try {
return correctSessionDescription(future.get());
} catch (InterruptedException e) {
throw new AssertionError(e);
} catch (ExecutionException e) {
throw new PeerConnectionException(e);
}
}
Aggregations