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

feat: move to 118 webrtc version #5

Closed
wants to merge 23 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
76aa82b
feat: switch to livekit m104 webrtc
davidliu May 29, 2023
9dce711
android: remove setEnableVolumeLogger call
davidliu Jun 2, 2023
2cdc788
ios, android: setCodecPreferences implementations (#2)
davidliu Jun 8, 2023
63b8566
android: update webrtc to 104.5112.10 (#3)
davidliu Jun 8, 2023
77839a3
chore: change namespace for release
santhoshvai Aug 16, 2023
33b8ae0
chore: rename podspec file
santhoshvai Aug 16, 2023
cd41718
104.0.1
santhoshvai Aug 16, 2023
fa7b37e
build(deps-dev): bump @babel/traverse from 7.17.3 to 7.23.2
dependabot[bot] Oct 17, 2023
94add9b
ios,android: update WebRTC to M118
saghul Oct 17, 2023
914c636
ios,android: setCodecPreferences and getCapabilities
davidliu Jun 7, 2023
eb2b0c4
ios build fix: missing type
8BallBomBom Oct 20, 2023
93bfe02
ios: fix setCodecPreferences build error
davidliu Nov 1, 2023
95984a3
ios: more setCodecPreferences fixes
davidliu Nov 1, 2023
15390a8
Merge remote-tracking branch 'upstream/master'
santhoshvai Nov 16, 2023
9ca25c8
104.0.2
santhoshvai Nov 16, 2023
6cee3a6
chore: update lock file
santhoshvai Nov 16, 2023
6ea96ee
104.0.3-alpha.0
santhoshvai Nov 16, 2023
d06ab57
Revert "ios: add ability to customize RTCAudioDevice"
santhoshvai Nov 16, 2023
02f2270
104.0.3-alpha.1
santhoshvai Nov 16, 2023
b0136e4
104.0.3-alpha.2
santhoshvai Nov 16, 2023
d82e62c
fix: pod spec troubles
santhoshvai Nov 16, 2023
c704fe1
104.0.3
santhoshvai Nov 17, 2023
07b709e
Merge remote-tracking branch 'orig-upstream/M118' into m118
santhoshvai Nov 21, 2023
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 android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@ android {

dependencies {
implementation 'com.facebook.react:react-native:+'
api 'io.github.webrtc-sdk:android:104.5112.10'
api 'org.jitsi:webrtc:118.+'
}
2 changes: 1 addition & 1 deletion ios/RCTWebRTC/SerializeUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
+ (NSDictionary *_Nonnull)trackToJSONWithPeerConnectionId:(nonnull NSNumber *)id
track:(RTCMediaStreamTrack *_Nonnull)track;
+ (NSDictionary *_Nonnull)capabilitiesToJSON:(RTCRtpCapabilities *_Nonnull)capabilities;
+ (NSDictionary *_Nonnull)codecCapabilityToJSON:(RTCRtpCodecCapability *)codec;
+ (NSDictionary *_Nonnull)codecCapabilityToJSON:(RTCRtpCodecCapability *_Nonnull)codec;
+ (NSString *_Nonnull)serializeDirection:(RTCRtpTransceiverDirection)direction;
+ (RTCRtpTransceiverDirection)parseDirection:(NSString *_Nonnull)direction;
+ (RTCRtpTransceiverInit *_Nonnull)parseTransceiverOptions:(NSDictionary *_Nonnull)parameters;
Expand Down
16 changes: 5 additions & 11 deletions ios/RCTWebRTC/SerializeUtils.m
Original file line number Diff line number Diff line change
Expand Up @@ -171,20 +171,16 @@ + (NSDictionary *)trackToJSONWithPeerConnectionId:(NSNumber *)id track:(RTCMedia
}

+ (NSDictionary *)capabilitiesToJSON:(RTCRtpCapabilities *)capabilities {

NSMutableArray *codecs = [NSMutableArray new];

for (RTCRtpCodecCapability *codec in capabilities.codecs) {
[codecs addObject:[self codecCapabilityToJSON:codec]];
}

return @{
@"codecs" : codecs
};
return @{@"codecs" : codecs};
}

+ (NSDictionary *)codecCapabilityToJSON:(RTCRtpCodecCapability *)codec {

NSMutableDictionary *codecDictionary = [NSMutableDictionary new];

codecDictionary[@"payloadType"] = codec.preferredPayloadType;
Expand All @@ -203,16 +199,14 @@ + (NSDictionary *)codecCapabilityToJSON:(RTCRtpCodecCapability *)codec {
}

+ (NSString *)serializeSdpParameters:(NSDictionary *)parameters {

if(parameters == nil || parameters.count == 0) {
if (parameters == nil || parameters.count == 0) {
return nil;
}

NSMutableArray *parts = [NSMutableArray arrayWithCapacity:parameters.count];
[parameters
enumerateKeysAndObjectsUsingBlock:^(id _Nonnull key, id _Nonnull value, BOOL *_Nonnull stop) {
[parts addObject:[NSString stringWithFormat:@"%@=%@", key, value]];
}];
[parameters enumerateKeysAndObjectsUsingBlock:^(id _Nonnull key, id _Nonnull value, BOOL *_Nonnull stop) {
[parts addObject:[NSString stringWithFormat:@"%@=%@", key, value]];
}];

return [parts componentsJoinedByString:@";"];
}
Expand Down
45 changes: 26 additions & 19 deletions ios/RCTWebRTC/WebRTCModule+Transceivers.m
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
#import <React/RCTBridge.h>
#import <React/RCTBridgeModule.h>

#import <WebRTC/RTCRtpCodecCapability.h>
#import <WebRTC/RTCRtpReceiver.h>
#import <WebRTC/RTCRtpSender.h>
#import <WebRTC/RTCRtpCodecCapability.h>

#import "SerializeUtils.h"
#import "WebRTCModule.h"

@implementation WebRTCModule (Transceivers)

RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(senderGetCapabilities:(NSString *)kind) {
RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(senderGetCapabilities : (NSString *)kind) {
__block id params;

dispatch_sync(self.workerQueue, ^{
Expand All @@ -24,13 +24,13 @@ @implementation WebRTCModule (Transceivers)
}

RTCRtpCapabilities *capabilities = [self.peerConnectionFactory rtpSenderCapabilitiesFor:mediaType];
params = [SerializeUtils capabilitiesToJSON: capabilities];
params = [SerializeUtils capabilitiesToJSON:capabilities];
});

return params;
}

RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(receiverGetCapabilities:(NSString *)kind) {
RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(receiverGetCapabilities : (NSString *)kind) {
__block id params;

dispatch_sync(self.workerQueue, ^{
Expand All @@ -42,7 +42,7 @@ @implementation WebRTCModule (Transceivers)
}

RTCRtpCapabilities *capabilities = [self.peerConnectionFactory rtpSenderCapabilitiesFor:mediaType];
params = [SerializeUtils capabilitiesToJSON: capabilities];
params = [SerializeUtils capabilitiesToJSON:capabilities];
});

return params;
Expand Down Expand Up @@ -186,9 +186,9 @@ @implementation WebRTCModule (Transceivers)
}

RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(transceiverSetCodecPreferences
: (nonnull NSNumber *)objectID senderId
: (NSString *)senderId codecPreferences
: (NSArray *)codecPreferences) {
: (nonnull NSNumber *)objectID senderId
: (NSString *)senderId codecPreferences
: (NSArray *)codecPreferences) {
RTCPeerConnection *peerConnection = self.peerConnections[objectID];

if (peerConnection == nil) {
Expand All @@ -205,34 +205,36 @@ @implementation WebRTCModule (Transceivers)
}

if (transceiver == nil) {
RCTLogWarn(@"senderSetParameters() transceiver is null");
RCTLogWarn(@"transceiverSetCodecPreferences() transceiver is null");
return nil;
}

// Convert JSON codec capabilities to the actual objects.
// Get the available codecs
RTCRtpTransceiverDirection direction = transceiver.direction;
NSMutableArray *availableCodecs = [NSMutableArray new];
if (direction == RTCRtpTransceiverDirectionSendRecv || direction == RTCRtpTransceiverDirectionSendOnly) {
RTCRtpCapabilities *capabilities = [self.peerConnectionFactory rtpSenderCapabilitiesFor:transceiver.mediaType];
for(RTCRtpCodecCapability *codec in capabilities.codecs) {
for (RTCRtpCodecCapability *codec in capabilities.codecs) {
NSDictionary *codecDict = [SerializeUtils codecCapabilityToJSON:codec];
[availableCodecs addObject:@{
@"dict": codecDict,
@"codec": codec,
@"dict" : codecDict,
@"codec" : codec,
}];
}
}
if (direction == RTCRtpTransceiverDirectionSendRecv || direction == RTCRtpTransceiverDirectionRecvOnly) {
RTCRtpCapabilities *capabilities = [self.peerConnectionFactory rtpReceiverCapabilitiesFor:transceiver.mediaType];
for(RTCRtpCodecCapability *codec in capabilities.codecs) {
RTCRtpCapabilities *capabilities =
[self.peerConnectionFactory rtpReceiverCapabilitiesFor:transceiver.mediaType];
for (RTCRtpCodecCapability *codec in capabilities.codecs) {
NSDictionary *codecDict = [SerializeUtils codecCapabilityToJSON:codec];
[availableCodecs addObject:@{
@"dict": codecDict,
@"codec": codec,
@"dict" : codecDict,
@"codec" : codec,
}];
}
}


// Convert JSON codec capabilities to the actual objects.
// Codec preferences is order sensitive.
NSMutableArray *codecsToSet = [NSMutableArray new];

Expand All @@ -246,7 +248,12 @@ @implementation WebRTCModule (Transceivers)
}
}

transceiver.codecPreferences = codecsToSet;
NSError *error;
[transceiver setCodecPreferences:codecsToSet error:&error];

if (error) {
RTCLogError(@"transceiverSetCodecPreferences() Could not set preferences: %@", error);
}
return nil;
}

Expand Down
4 changes: 1 addition & 3 deletions ios/RCTWebRTC/WebRTCModule.m
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ - (instancetype)init {
self = [super init];
if (self) {
WebRTCModuleOptions *options = [WebRTCModuleOptions sharedInstance];
id<RTCAudioDevice> audioDevice = options.audioDevice;
id<RTCVideoDecoderFactory> decoderFactory = options.videoDecoderFactory;
id<RTCVideoEncoderFactory> encoderFactory = options.videoEncoderFactory;
NSDictionary *fieldTrials = options.fieldTrials;
Expand Down Expand Up @@ -70,8 +69,7 @@ - (instancetype)init {
RCTLogInfo(@"Using video decoder factory: %@", NSStringFromClass([decoderFactory class]));

_peerConnectionFactory = [[RTCPeerConnectionFactory alloc] initWithEncoderFactory:encoderFactory
decoderFactory:decoderFactory
audioDevice:audioDevice];
decoderFactory:decoderFactory];

_peerConnections = [NSMutableDictionary new];
_localStreams = [NSMutableDictionary new];
Expand Down
1 change: 0 additions & 1 deletion ios/RCTWebRTC/WebRTCModuleOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ NS_ASSUME_NONNULL_BEGIN

@property(nonatomic, strong, nullable) id<RTCVideoDecoderFactory> videoDecoderFactory;
@property(nonatomic, strong, nullable) id<RTCVideoEncoderFactory> videoEncoderFactory;
@property(nonatomic, strong, nullable) id<RTCAudioDevice> audioDevice;
@property(nonatomic, strong, nullable) NSDictionary *fieldTrials;
@property(nonatomic, assign) RTCLoggingSeverity loggingSeverity;

Expand Down
1 change: 0 additions & 1 deletion ios/RCTWebRTC/WebRTCModuleOptions.m
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ + (instancetype)sharedInstance {

- (instancetype)init {
if (self = [super init]) {
self.audioDevice = nil;
self.fieldTrials = nil;
self.videoEncoderFactory = nil;
self.videoDecoderFactory = nil;
Expand Down
Loading