Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ios,android: E2EE implementation #23

Merged
merged 1 commit into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,21 @@ RtpTransceiver addTransceiver(MediaStreamTrack track, RtpTransceiver.RtpTranscei
return peerConnection.addTransceiver(track, init);
}


RtpReceiver getReceiver(String id) {
if (this.peerConnection == null) {
return null;
}

for (RtpReceiver receiver : this.peerConnection.getReceivers()) {
if (receiver.id().equals(id)) {
return receiver;
}
}

return null;
}

RtpSender getSender(String id) {
if (this.peerConnection == null) {
return null;
Expand Down
384 changes: 384 additions & 0 deletions android/src/main/java/com/oney/WebRTCModule/RTCFrameCryptor.java

Large diffs are not rendered by default.

107 changes: 106 additions & 1 deletion android/src/main/java/com/oney/WebRTCModule/WebRTCModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,30 @@
import com.oney.WebRTCModule.webrtcutils.H264AndSoftwareVideoDecoderFactory;
import com.oney.WebRTCModule.webrtcutils.H264AndSoftwareVideoEncoderFactory;

import org.webrtc.*;
import org.webrtc.AddIceObserver;
import org.webrtc.AudioTrack;
import org.webrtc.CryptoOptions;
import org.webrtc.EglBase;
import org.webrtc.IceCandidate;
import org.webrtc.Loggable;
import org.webrtc.Logging;
import org.webrtc.MediaConstraints;
import org.webrtc.MediaStream;
import org.webrtc.MediaStreamTrack;
import org.webrtc.PeerConnection;
import org.webrtc.PeerConnectionFactory;
import org.webrtc.RTCStatsReport;
import org.webrtc.RtpCapabilities;
import org.webrtc.RtpParameters;
import org.webrtc.RtpSender;
import org.webrtc.RtpTransceiver;
import org.webrtc.SdpObserver;
import org.webrtc.SessionDescription;
import org.webrtc.SoftwareVideoDecoderFactory;
import org.webrtc.SoftwareVideoEncoderFactory;
import org.webrtc.VideoDecoderFactory;
import org.webrtc.VideoEncoderFactory;
import org.webrtc.VideoTrack;
import org.webrtc.audio.AudioDeviceModule;
import org.webrtc.audio.JavaAudioDeviceModule;

Expand Down Expand Up @@ -119,6 +142,9 @@ public String getName() {
return "WebRTCModule";
}

public PeerConnectionObserver getPeerConnectionObserver(int id) {
return mPeerConnectionObservers.get(id);
}
private PeerConnection getPeerConnection(int id) {
PeerConnectionObserver pco = mPeerConnectionObservers.get(id);
return (pco == null) ? null : pco.getPeerConnection();
Expand Down Expand Up @@ -1412,6 +1438,85 @@ public void dataChannelSend(int peerConnectionId, String reactTag, String data,
});
}

// Frame Cryptor methods
////////////////////////////////
RTCFrameCryptor frameCryptor = new RTCFrameCryptor(this);

@ReactMethod(isBlockingSynchronousMethod = true)
public String frameCryptorFactoryCreateFrameCryptor(ReadableMap config) {
return frameCryptor.frameCryptorFactoryCreateFrameCryptor(config);
}

@ReactMethod
public void frameCryptorSetKeyIndex(ReadableMap config, Promise promise) {
frameCryptor.frameCryptorSetKeyIndex(config, promise);
}

@ReactMethod
public void frameCryptorGetKeyIndex(ReadableMap config, Promise promise) {
frameCryptor.frameCryptorGetKeyIndex(config, promise);
}

@ReactMethod
public void frameCryptorSetEnabled(ReadableMap config, Promise promise) {
frameCryptor.frameCryptorSetEnabled(config, promise);
}

@ReactMethod
public void frameCryptorGetEnabled(ReadableMap config, Promise promise) {
frameCryptor.frameCryptorGetEnabled(config, promise);
}

@ReactMethod
public void frameCryptorDispose(ReadableMap config, Promise promise) {
frameCryptor.frameCryptorDispose(config, promise);
}

@ReactMethod(isBlockingSynchronousMethod = true)
public String frameCryptorFactoryCreateKeyProvider(ReadableMap config) {
return frameCryptor.frameCryptorFactoryCreateKeyProvider(config);
}

@ReactMethod
public void keyProviderSetSharedKey(ReadableMap config, Promise promise) {
frameCryptor.keyProviderSetSharedKey(config, promise);
}

@ReactMethod
public void keyProviderRatchetSharedKey(ReadableMap config, Promise promise) {
frameCryptor.keyProviderRatchetSharedKey(config, promise);
}

@ReactMethod
public void keyProviderExportSharedKey(ReadableMap config, Promise promise) {
frameCryptor.keyProviderExportSharedKey(config, promise);
}

@ReactMethod
public void keyProviderSetKey(ReadableMap config, Promise promise) {
frameCryptor.keyProviderSetKey(config, promise);
}

@ReactMethod
public void keyProviderRatchetKey(ReadableMap config, Promise promise) {
frameCryptor.keyProviderRatchetKey(config, promise);
}

@ReactMethod
public void keyProviderExportKey(ReadableMap config, Promise promise) {
frameCryptor.keyProviderExportKey(config, promise);
}

@ReactMethod
public void keyProviderSetSifTrailer(ReadableMap config, Promise promise) {
frameCryptor.keyProviderSetSifTrailer(config, promise);
}

@ReactMethod
public void keyProviderDispose(ReadableMap config, Promise promise) {
frameCryptor.keyProviderDispose(config, promise);
}

@ReactMethod
public void addListener(String eventName) {
// Keep: Required for RN built in Event Emitter Calls.
Expand Down
Loading
Loading