Skip to content

Commit

Permalink
Merge remote-tracking branch 'orig-upstream/M118' into m118
Browse files Browse the repository at this point in the history
# Conflicts:
#	android/build.gradle
#	ios/RCTWebRTC/SerializeUtils.h
#	ios/RCTWebRTC/SerializeUtils.m
#	ios/RCTWebRTC/WebRTCModule+Transceivers.m
#	package-lock.json
#	package.json
#	stream-react-native-webrtc.podspec
  • Loading branch information
santhoshvai committed Nov 21, 2023
2 parents c704fe1 + 95984a3 commit 07b709e
Show file tree
Hide file tree
Showing 7 changed files with 247 additions and 229 deletions.
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
Loading

0 comments on commit 07b709e

Please sign in to comment.