Skip to content
Merged

m144 #68

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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Software encode/decode factories have been enabled by default.

## WebRTC Revision

* Currently used revision: [M125](https://github.com/webrtc-sdk/webrtc/tree/m125_release)
* Currently used revision: [M144](https://github.com/webrtc-sdk/webrtc/tree/m144_release)
* Supported architectures
* Android: armeabi-v7a, arm64-v8a, x86, x86_64
* iOS: arm64, x86_64
Expand Down
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ android {

dependencies {
implementation "com.facebook.react:react-android:+"
api 'io.github.webrtc-sdk:android:137.7151.05'
api 'io.github.webrtc-sdk:android:144.7559.01'
implementation "androidx.core:core:1.7.0"
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import org.webrtc.FrameCryptor;
import org.webrtc.FrameCryptorAlgorithm;
import org.webrtc.FrameCryptorFactory;
import org.webrtc.FrameCryptorKeyDerivationAlgorithm;
import org.webrtc.FrameCryptorKeyProvider;
import org.webrtc.RtpReceiver;
import org.webrtc.RtpSender;
Expand Down Expand Up @@ -92,6 +93,17 @@ private FrameCryptorAlgorithm frameCryptorAlgorithmFromInt(int algorithm) {
}
}

private FrameCryptorKeyDerivationAlgorithm keyDerivationAlgorithmFromInt(int algorithm) {
switch (algorithm) {
case 0:
return FrameCryptorKeyDerivationAlgorithm.PBKDF2;
case 1:
return FrameCryptorKeyDerivationAlgorithm.HKDF;
default:
return FrameCryptorKeyDerivationAlgorithm.PBKDF2;
}
}

public String frameCryptorFactoryCreateFrameCryptor(ReadableMap params) {
String keyProviderId = params.getString("keyProviderId");
FrameCryptorKeyProvider keyProvider = keyProviders.get(keyProviderId);
Expand Down Expand Up @@ -238,13 +250,17 @@ public String frameCryptorFactoryCreateKeyProvider(ReadableMap keyProviderOption
int keyRingSize = (int) keyProviderOptions.getInt("keyRingSize");
boolean discardFrameWhenCryptorNotReady =
(boolean) keyProviderOptions.getBoolean("discardFrameWhenCryptorNotReady");
int keyDerivationAlgorithm = keyProviderOptions.hasKey("keyDerivationAlgorithm")
? keyProviderOptions.getInt("keyDerivationAlgorithm")
: 0;
FrameCryptorKeyProvider keyProvider = FrameCryptorFactory.createFrameCryptorKeyProvider(sharedKey,
ratchetSalt,
ratchetWindowSize,
uncryptedMagicBytes,
failureTolerance,
keyRingSize,
discardFrameWhenCryptorNotReady);
discardFrameWhenCryptorNotReady,
keyDerivationAlgorithmFromInt(keyDerivationAlgorithm));
keyProviders.put(keyProviderId, keyProvider);
return keyProviderId;
}
Expand Down
15 changes: 14 additions & 1 deletion ios/RCTWebRTC/WebRTCModule+RTCFrameCryptor.m
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,17 @@ - (RTCCryptorAlgorithm)getAlgorithm:(NSNumber *)algorithm {
}
}

- (RTCKeyDerivationAlgorithm)getKeyDerivationAlgorithm:(NSNumber *)algorithm {
switch ([algorithm intValue]) {
case 0:
return RTCKeyDerivationAlgorithmPBKDF2;
case 1:
return RTCKeyDerivationAlgorithmHKDF;
default:
return RTCKeyDerivationAlgorithmPBKDF2;
}
}

- (NSData *)bytesFromMap:(NSDictionary *)map key:(NSString *)key isBase64Key:(nullable NSString *)isBase64Key {
BOOL isBase64 = YES;
if (isBase64Key) {
Expand Down Expand Up @@ -257,6 +268,7 @@ - (NSData *)bytesFromMap:(NSDictionary *)map key:(NSString *)key isBase64Key:(nu

NSNumber *keyRingSize = keyProviderOptions[@"keyRingSize"];
NSNumber *discardFrameWhenCryptorNotReady = keyProviderOptions[@"discardFrameWhenCryptorNotReady"];
NSNumber *keyDerivationAlgorithm = keyProviderOptions[@"keyDerivationAlgorithm"];

RTCFrameCryptorKeyProvider *keyProvider = [[RTCFrameCryptorKeyProvider alloc]
initWithRatchetSalt:ratchetSalt
Expand All @@ -267,7 +279,8 @@ - (NSData *)bytesFromMap:(NSDictionary *)map key:(NSString *)key isBase64Key:(nu
keyRingSize:keyRingSize != nil ? [keyRingSize intValue] : 0
discardFrameWhenCryptorNotReady:discardFrameWhenCryptorNotReady != nil
? [discardFrameWhenCryptorNotReady boolValue]
: NO];
: NO
keyDerivationAlgorithm:[self getKeyDerivationAlgorithm:keyDerivationAlgorithm]];
self.keyProviders[keyProviderId] = keyProvider;
return;
});
Expand Down
2 changes: 1 addition & 1 deletion livekit-react-native-webrtc.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Pod::Spec.new do |s|
s.libraries = 'c', 'sqlite3', 'stdc++'
s.framework = 'AudioToolbox','AVFoundation', 'CoreAudio', 'CoreGraphics', 'CoreVideo', 'GLKit', 'VideoToolbox'
s.dependency 'React-Core'
s.dependency 'WebRTC-SDK', '=137.7151.09'
s.dependency 'WebRTC-SDK', '=144.7559.01'

# Swift/Objective-C compatibility
s.pod_target_xcconfig = {
Expand Down
11 changes: 9 additions & 2 deletions src/RTCFrameCryptorFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,20 @@ export enum RTCFrameCryptorAlgorithm {
// kAesCbc = 1,
}

export enum RTCKeyDerivationAlgorithm {
PBKDF2 = 0,
HKDF = 1,
}

export type RTCKeyProviderOptions = {
sharedKey: boolean,
ratchetSalt: string | Uint8Array,
ratchetWindowSize: number,
uncryptedMagicBytes?: Uint8Array,
failureTolerance?: number,
keyRingSize?: number,
discardFrameWhenCryptorNotReady?: boolean
discardFrameWhenCryptorNotReady?: boolean,
keyDerivationAlgorithm?: RTCKeyDerivationAlgorithm,
}

export default class RTCFrameCryptorFactory {
Expand Down Expand Up @@ -74,7 +80,8 @@ export default class RTCFrameCryptorFactory {
'ratchetWindowSize': options.ratchetWindowSize,
'failureTolerance': options.failureTolerance ?? -1,
'keyRingSize': options.keyRingSize ?? 16,
'discardFrameWhenCryptorNotReady': options.discardFrameWhenCryptorNotReady ?? false
'discardFrameWhenCryptorNotReady': options.discardFrameWhenCryptorNotReady ?? false,
'keyDerivationAlgorithm': options.keyDerivationAlgorithm ?? 0
};

if (typeof options.ratchetSalt === 'string') {
Expand Down
1 change: 1 addition & 0 deletions src/RTCRtpSendParameters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ type DegradationPreferenceType = 'maintain-framerate'
| 'maintain-resolution'
| 'balanced'
| 'disabled'
| 'maintain-framerate-and-resolution'


/**
Expand Down
5 changes: 4 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ import RTCDataPacketCryptor, { RTCEncryptedPacket } from './RTCDataPacketCryptor
import RTCDataPacketCryptorFactory from './RTCDataPacketCryptorFactory';
import RTCErrorEvent from './RTCErrorEvent';
import RTCFrameCryptor, { RTCFrameCryptorState } from './RTCFrameCryptor';
import RTCFrameCryptorFactory, { RTCFrameCryptorAlgorithm, RTCKeyProviderOptions } from './RTCFrameCryptorFactory';
import RTCFrameCryptorFactory, {
RTCFrameCryptorAlgorithm, RTCKeyDerivationAlgorithm, RTCKeyProviderOptions,
} from './RTCFrameCryptorFactory';
import RTCIceCandidate from './RTCIceCandidate';
import RTCKeyProvider from './RTCKeyProvider';
import RTCPIPView, { startIOSPIP, stopIOSPIP } from './RTCPIPView';
Expand Down Expand Up @@ -64,6 +66,7 @@ export {
RTCFrameCryptor,
RTCFrameCryptorAlgorithm,
RTCFrameCryptorState,
RTCKeyDerivationAlgorithm,
RTCFrameCryptorFactory,
RTCKeyProvider,
RTCKeyProviderOptions,
Expand Down
Loading