@@ -541,17 +541,40 @@ - (RTCIceServer *)RTCIceServer:(id)json
541
541
542
542
- (nonnull RTCConfiguration *)RTCConfiguration : (id )json
543
543
{
544
- RTCConfiguration *config = [[RTCConfiguration alloc ] init ];
545
-
546
- if (!json) {
547
- return config;
548
- }
549
-
550
- if (![json isKindOfClass: [NSDictionary class ]]) {
551
- NSLog (@" must be an object" );
552
- return config;
544
+ RTCConfiguration *config = [[RTCConfiguration alloc ] init ];
545
+
546
+ if (!json) {
547
+ return config;
548
+ }
549
+
550
+ if (![json isKindOfClass: [NSDictionary class ]]) {
551
+ NSLog (@" must be an object" );
552
+ return config;
553
+ }
554
+
555
+ if (json[@" audioJitterBufferMaxPackets" ] != nil && [json[@" audioJitterBufferMaxPackets" ] isKindOfClass: [NSNumber class ]]) {
556
+ config.audioJitterBufferMaxPackets = [json[@" audioJitterBufferMaxPackets" ] intValue ];
557
+ }
558
+
559
+ if (json[@" bundlePolicy" ] != nil && [json[@" bundlePolicy" ] isKindOfClass: [NSString class ]]) {
560
+ NSString *bundlePolicy = json[@" bundlePolicy" ];
561
+ if ([bundlePolicy isEqualToString: @" balanced" ]) {
562
+ config.bundlePolicy = RTCBundlePolicyBalanced;
563
+ } else if ([bundlePolicy isEqualToString: @" max-compat" ]) {
564
+ config.bundlePolicy = RTCBundlePolicyMaxCompat;
565
+ } else if ([bundlePolicy isEqualToString: @" max-bundle" ]) {
566
+ config.bundlePolicy = RTCBundlePolicyMaxBundle;
553
567
}
554
-
568
+ }
569
+
570
+ if (json[@" iceBackupCandidatePairPingInterval" ] != nil && [json[@" iceBackupCandidatePairPingInterval" ] isKindOfClass: [NSNumber class ]]) {
571
+ config.iceBackupCandidatePairPingInterval = [json[@" iceBackupCandidatePairPingInterval" ] intValue ];
572
+ }
573
+
574
+ if (json[@" iceConnectionReceivingTimeout" ] != nil && [json[@" iceConnectionReceivingTimeout" ] isKindOfClass: [NSNumber class ]]) {
575
+ config.iceConnectionReceivingTimeout = [json[@" iceConnectionReceivingTimeout" ] intValue ];
576
+ }
577
+
555
578
if (json[@" iceServers" ] != nil && [json[@" iceServers" ] isKindOfClass: [NSArray class ]]) {
556
579
NSMutableArray <RTCIceServer *> *iceServers = [NSMutableArray new ];
557
580
for (id server in json[@" iceServers" ]) {
@@ -562,8 +585,48 @@ - (nonnull RTCConfiguration *)RTCConfiguration:(id)json
562
585
}
563
586
config.iceServers = iceServers;
564
587
}
565
- // TODO: Implement the rest of the RTCConfigure options ...
566
- return config;
588
+
589
+ if (json[@" iceTransportPolicy" ] != nil && [json[@" iceTransportPolicy" ] isKindOfClass: [NSString class ]]) {
590
+ NSString *iceTransportPolicy = json[@" iceTransportPolicy" ];
591
+ if ([iceTransportPolicy isEqualToString: @" all" ]) {
592
+ config.iceTransportPolicy = RTCIceTransportPolicyAll;
593
+ } else if ([iceTransportPolicy isEqualToString: @" none" ]) {
594
+ config.iceTransportPolicy = RTCIceTransportPolicyNone;
595
+ } else if ([iceTransportPolicy isEqualToString: @" nohost" ]) {
596
+ config.iceTransportPolicy = RTCIceTransportPolicyNoHost;
597
+ } else if ([iceTransportPolicy isEqualToString: @" relay" ]) {
598
+ config.iceTransportPolicy = RTCIceTransportPolicyRelay;
599
+ }
600
+ }
601
+
602
+ if (json[@" rtcpMuxPolicy" ] != nil && [json[@" rtcpMuxPolicy" ] isKindOfClass: [NSString class ]]) {
603
+ NSString *rtcpMuxPolicy = json[@" rtcpMuxPolicy" ];
604
+ if ([rtcpMuxPolicy isEqualToString: @" negotiate" ]) {
605
+ config.rtcpMuxPolicy = RTCRtcpMuxPolicyNegotiate;
606
+ } else if ([rtcpMuxPolicy isEqualToString: @" require" ]) {
607
+ config.rtcpMuxPolicy = RTCRtcpMuxPolicyRequire;
608
+ }
609
+ }
610
+
611
+ if (json[@" tcpCandidatePolicy" ] != nil && [json[@" tcpCandidatePolicy" ] isKindOfClass: [NSString class ]]) {
612
+ NSString *tcpCandidatePolicy = json[@" tcpCandidatePolicy" ];
613
+ if ([tcpCandidatePolicy isEqualToString: @" enabled" ]) {
614
+ config.tcpCandidatePolicy = RTCTcpCandidatePolicyEnabled;
615
+ } else if ([tcpCandidatePolicy isEqualToString: @" disabled" ]) {
616
+ config.tcpCandidatePolicy = RTCTcpCandidatePolicyDisabled;
617
+ }
618
+ }
619
+
620
+ if (json[@" sdpSemantics" ] != nil && [json[@" sdpSemantics" ] isKindOfClass: [NSString class ]]) {
621
+ NSString *sdpSemantics = json[@" sdpSemantics" ];
622
+ if ([sdpSemantics isEqualToString: @" plan-b" ]) {
623
+ config.sdpSemantics = RTCSdpSemanticsPlanB;
624
+ } else if ([sdpSemantics isEqualToString: @" unified-plan" ]) {
625
+ config.sdpSemantics = RTCSdpSemanticsUnifiedPlan;
626
+ }
627
+ }
628
+
629
+ return config;
567
630
}
568
631
569
632
- (RTCDataChannelConfiguration *)RTCDataChannelConfiguration : (id )json
@@ -573,7 +636,7 @@ - (RTCDataChannelConfiguration *)RTCDataChannelConfiguration:(id)json
573
636
}
574
637
if ([json isKindOfClass: [NSDictionary class ]]) {
575
638
RTCDataChannelConfiguration *init = [RTCDataChannelConfiguration new ];
576
-
639
+
577
640
if (json[@" id" ]) {
578
641
[init setChannelId: (int )[json[@" id" ] integerValue ]];
579
642
}
0 commit comments