|
@@ -133,7 +133,7 @@ RCT_EXPORT_METHOD(init:(NSDictionary *)options) {
|
133
|
133
|
}
|
134
|
134
|
}
|
135
|
135
|
|
136
|
|
- AgoraVideoEncoderConfiguration *video_encoder_config = [[AgoraVideoEncoderConfiguration init] initWithWidth:[options[@"videoEncoderConfig.width"] integerValue] height:[options[@"videoEncoderConfig.height"] integerValue] frameRate:(AgoraVideoFrameRate)[options[@"videoEncoderConfig.frameRate"] integerValue] bitrate:[options[@"videoEncoderConfig.bitrate"] integerValue] orientationMode: (AgoraVideoOutputOrientationMode)[options[@"videoEncoderCnofig.orientationMode"] integerValue]];
|
|
136
|
+ AgoraVideoEncoderConfiguration *video_encoder_config = [[AgoraVideoEncoderConfiguration new] initWithWidth:[options[@"videoEncoderConfig.width"] integerValue] height:[options[@"videoEncoderConfig.height"] integerValue] frameRate:(AgoraVideoFrameRate)[options[@"videoEncoderConfig.frameRate"] integerValue] bitrate:[options[@"videoEncoderConfig.bitrate"] integerValue] orientationMode: (AgoraVideoOutputOrientationMode)[options[@"videoEncoderCnofig.orientationMode"] integerValue]];
|
137
|
137
|
[self.rtcEngine setVideoEncoderConfiguration:video_encoder_config];
|
138
|
138
|
[self.rtcEngine setClientRole:(AgoraClientRole)[options[@"clientRole"] integerValue]];
|
139
|
139
|
[self.rtcEngine setAudioProfile:(AgoraAudioProfile)[options[@"audioProfile"] integerValue]
|
|
@@ -144,7 +144,8 @@ RCT_EXPORT_METHOD(init:(NSDictionary *)options) {
|
144
|
144
|
}
|
145
|
145
|
|
146
|
146
|
// renew token
|
147
|
|
-RCT_EXPORT_METHOD(renewToken:(NSString *)token
|
|
147
|
+RCT_EXPORT_METHOD(renewToken
|
|
148
|
+ :(NSString *)token
|
148
|
149
|
resolve:(RCTPromiseResolveBlock)resolve
|
149
|
150
|
reject:(RCTPromiseRejectBlock)reject) {
|
150
|
151
|
NSInteger res = [self.rtcEngine renewToken:token];
|
|
@@ -180,7 +181,9 @@ RCT_EXPORT_METHOD(enableWebSdkInteroperability: (BOOL)enabled
|
180
|
181
|
}
|
181
|
182
|
|
182
|
183
|
// get agora connection state
|
183
|
|
-RCT_EXPORT_METHOD(getConnectionState: (RCTPromiseResolveBlock)resolve) {
|
|
184
|
+RCT_EXPORT_METHOD(getConnectionState
|
|
185
|
+ :(RCTPromiseResolveBlock) resolve
|
|
186
|
+ reject:(RCTPromiseRejectBlock) reject) {
|
184
|
187
|
resolve(@{@"success": @(YES), @"state": @([self.rtcEngine getConnectionState])});
|
185
|
188
|
}
|
186
|
189
|
|
|
@@ -190,9 +193,9 @@ RCT_EXPORT_METHOD(setClientRole:(NSString *) role) {
|
190
|
193
|
}
|
191
|
194
|
|
192
|
195
|
// join channel
|
193
|
|
-RCT_EXPORT_METHOD(joinChannel:(NSDictionary *) options:success) {
|
|
196
|
+RCT_EXPORT_METHOD(joinChannel:(NSDictionary *) options) {
|
194
|
197
|
[AgoraConst share].localUid = [options[@"uid"] integerValue];
|
195
|
|
- [self.rtcEngine joinChannelByToken:options[@"token"] channelId:options[@"channelId"] info:options[@"info"] uid:[AgoraConst share].localUid joinSuccess:nil];
|
|
198
|
+ [self.rtcEngine joinChannelByToken:options[@"token"] channelId:options[@"channelName"] info:options[@"info"] uid:[AgoraConst share].localUid joinSuccess:nil];
|
196
|
199
|
}
|
197
|
200
|
|
198
|
201
|
// leave channel
|
|
@@ -200,7 +203,7 @@ RCT_EXPORT_METHOD(leaveChannel
|
200
|
203
|
:(RCTPromiseResolveBlock) resolve
|
201
|
204
|
reject:(RCTPromiseRejectBlock) reject) {
|
202
|
205
|
int res = [self.rtcEngine leaveChannel:^(AgoraChannelStats * _Nonnull stat) {
|
203
|
|
- [self sendEvent:@"leaveChannel" params:@{
|
|
206
|
+ [self sendEvent:DidLeaveChannel params:@{
|
204
|
207
|
@"message": @"leaveChannel",
|
205
|
208
|
@"duration": @(stat.duration),
|
206
|
209
|
@"txBytes": @(stat.txBytes),
|
|
@@ -215,7 +218,7 @@ RCT_EXPORT_METHOD(leaveChannel
|
215
|
218
|
@"cpuTotalUsage": @(stat.cpuTotalUsage)
|
216
|
219
|
}];
|
217
|
220
|
}];
|
218
|
|
- if (res < 0) {
|
|
221
|
+ if (res != 0) {
|
219
|
222
|
reject(@"131038", @"leaveChannel failed", [self makeNSError:@{
|
220
|
223
|
@"code": @(131038),
|
221
|
224
|
@"message":@{
|
|
@@ -369,7 +372,10 @@ RCT_EXPORT_METHOD(enableAudioVolumeIndication: (NSInteger) interval smooth:(NSIn
|
369
|
372
|
}
|
370
|
373
|
|
371
|
374
|
// create data stream
|
372
|
|
-RCT_EXPORT_METHOD(createDataStream:(NSDictionary *)options resolve:(RCTPromiseResolveBlock)resolve) {
|
|
375
|
+RCT_EXPORT_METHOD(createDataStream
|
|
376
|
+ :(NSDictionary *)options
|
|
377
|
+ resolve:(RCTPromiseResolveBlock)resolve
|
|
378
|
+ reject:(RCTPromiseRejectBlock)reject) {
|
373
|
379
|
NSInteger streamId = 0;
|
374
|
380
|
if (options[@"streamId"] != nil) {
|
375
|
381
|
streamId = [options[@"streamId"] integerValue];
|
|
@@ -498,10 +504,11 @@ RCT_EXPORT_METHOD(adjustAudioMixingPublishVolume:(NSInteger) volume) {
|
498
|
504
|
}
|
499
|
505
|
|
500
|
506
|
// get audio mixing duration
|
501
|
|
-RCT_EXPORT_METHOD(getAudioMixingDuration: (RCTPromiseResolveBlock)resolve
|
|
507
|
+RCT_EXPORT_METHOD(getAudioMixingDuration
|
|
508
|
+ : (RCTPromiseResolveBlock)resolve
|
502
|
509
|
reject:(RCTPromiseRejectBlock)reject) {
|
503
|
510
|
NSInteger res = [self.rtcEngine getAudioMixingDuration];
|
504
|
|
- if (res < 0) {
|
|
511
|
+ if (res != 0) {
|
505
|
512
|
reject(@"131004", @"getAudioMixingDuration failed", [self makeNSError:@{
|
506
|
513
|
@"code": @(131004),
|
507
|
514
|
@"message":@{
|
|
@@ -518,10 +525,11 @@ RCT_EXPORT_METHOD(getAudioMixingDuration: (RCTPromiseResolveBlock)resolve
|
518
|
525
|
}
|
519
|
526
|
|
520
|
527
|
// get audio mixing current position
|
521
|
|
-RCT_EXPORT_METHOD(getAudioMixingCurrentPosition: (RCTPromiseResolveBlock)resolve
|
|
528
|
+RCT_EXPORT_METHOD(getAudioMixingCurrentPosition
|
|
529
|
+ :(RCTPromiseResolveBlock)resolve
|
522
|
530
|
reject:(RCTPromiseRejectBlock)reject) {
|
523
|
531
|
NSInteger res = [self.rtcEngine getAudioMixingDuration];
|
524
|
|
- if (res < 0) {
|
|
532
|
+ if (res != 0) {
|
525
|
533
|
reject(@"131005", @"getAudioMixingCurrentPosition failed", [self makeNSError:@{
|
526
|
534
|
@"code": @(131005),
|
527
|
535
|
@"message":@{
|
|
@@ -538,11 +546,12 @@ RCT_EXPORT_METHOD(getAudioMixingCurrentPosition: (RCTPromiseResolveBlock)resolve
|
538
|
546
|
}
|
539
|
547
|
|
540
|
548
|
// set audio mixing position
|
541
|
|
-RCT_EXPORT_METHOD(setAudioMixingPosition: (NSInteger) pos
|
|
549
|
+RCT_EXPORT_METHOD(setAudioMixingPosition
|
|
550
|
+ :(NSInteger) pos
|
542
|
551
|
resolve:(RCTPromiseResolveBlock)resolve
|
543
|
552
|
reject:(RCTPromiseRejectBlock)reject) {
|
544
|
553
|
NSInteger res = [self.rtcEngine setAudioMixingPosition:pos];
|
545
|
|
- if (res < 0) {
|
|
554
|
+ if (res != 0) {
|
546
|
555
|
reject(@"131006", @"setAudioMixingPosition failed", [self makeNSError:@{
|
547
|
556
|
@"code": @(131006),
|
548
|
557
|
@"message":@{
|
|
@@ -562,7 +571,7 @@ RCT_EXPORT_METHOD(getEffectsVolume
|
562
|
571
|
:(RCTPromiseResolveBlock)resolve
|
563
|
572
|
reject:(RCTPromiseRejectBlock)reject) {
|
564
|
573
|
double res = [self.rtcEngine getEffectsVolume];
|
565
|
|
- if (res < 0) {
|
|
574
|
+ if (res != 0) {
|
566
|
575
|
reject(@"131007", @"getEffectsVolume failed", [self makeNSError:@{
|
567
|
576
|
@"code": @(131007),
|
568
|
577
|
@"message":@{
|
|
@@ -579,11 +588,12 @@ RCT_EXPORT_METHOD(getEffectsVolume
|
579
|
588
|
}
|
580
|
589
|
|
581
|
590
|
// set effects volume
|
582
|
|
-RCT_EXPORT_METHOD(setEffectsVolume:(double) volume
|
|
591
|
+RCT_EXPORT_METHOD(setEffectsVolume
|
|
592
|
+ :(double) volume
|
583
|
593
|
resolve:(RCTPromiseResolveBlock)resolve
|
584
|
594
|
reject:(RCTPromiseRejectBlock)reject) {
|
585
|
595
|
NSInteger res = [self.rtcEngine setEffectsVolume:volume];
|
586
|
|
- if (res < 0) {
|
|
596
|
+ if (res != 0) {
|
587
|
597
|
reject(@"131008", @"setEffectsVolume failed", [self makeNSError:@{
|
588
|
598
|
@"code": @(131008),
|
589
|
599
|
@"message":@{
|
|
@@ -600,12 +610,13 @@ RCT_EXPORT_METHOD(setEffectsVolume:(double) volume
|
600
|
610
|
}
|
601
|
611
|
|
602
|
612
|
// set volume of effect
|
603
|
|
-RCT_EXPORT_METHOD(setVolumeOfEffect:(NSInteger) soundId
|
|
613
|
+RCT_EXPORT_METHOD(setVolumeOfEffect
|
|
614
|
+ :(NSInteger) soundId
|
604
|
615
|
volume:(double)volume
|
605
|
616
|
resolve:(RCTPromiseResolveBlock)resolve
|
606
|
617
|
reject:(RCTPromiseRejectBlock)reject) {
|
607
|
618
|
NSInteger res = [self.rtcEngine setVolumeOfEffect:soundId withVolume:volume];
|
608
|
|
- if (res < 0) {
|
|
619
|
+ if (res != 0) {
|
609
|
620
|
reject(@"131009", @"setVolumeOfEffect failed", [self makeNSError:@{
|
610
|
621
|
@"code": @(131009),
|
611
|
622
|
@"message":@{
|
|
@@ -622,7 +633,8 @@ RCT_EXPORT_METHOD(setVolumeOfEffect:(NSInteger) soundId
|
622
|
633
|
}
|
623
|
634
|
|
624
|
635
|
// play effect
|
625
|
|
-RCT_EXPORT_METHOD(playEffect:(NSDictionary *)options
|
|
636
|
+RCT_EXPORT_METHOD(playEffect
|
|
637
|
+ :(NSDictionary *)options
|
626
|
638
|
resolve:(RCTPromiseResolveBlock)resolve
|
627
|
639
|
reject:(RCTPromiseRejectBlock)reject) {
|
628
|
640
|
NSInteger res = [self.rtcEngine playEffect:(int)[options[@"soundId"] integerValue]
|
|
@@ -632,7 +644,7 @@ RCT_EXPORT_METHOD(playEffect:(NSDictionary *)options
|
632
|
644
|
pan:[options[@"pan"] doubleValue]
|
633
|
645
|
gain:[options[@"gain"] boolValue]
|
634
|
646
|
publish:[options[@"publish"] boolValue]];
|
635
|
|
- if (res < 0) {
|
|
647
|
+ if (res != 0) {
|
636
|
648
|
reject(@"131010", @"playEffect failed", [self makeNSError:@{
|
637
|
649
|
@"code": @(131010),
|
638
|
650
|
@"message":@{
|
|
@@ -649,11 +661,12 @@ RCT_EXPORT_METHOD(playEffect:(NSDictionary *)options
|
649
|
661
|
}
|
650
|
662
|
|
651
|
663
|
// stop effect by soundId
|
652
|
|
-RCT_EXPORT_METHOD(stopEffect:(NSInteger) soundId
|
|
664
|
+RCT_EXPORT_METHOD(stopEffect
|
|
665
|
+ :(NSInteger) soundId
|
653
|
666
|
resolve:(RCTPromiseResolveBlock)resolve
|
654
|
667
|
reject:(RCTPromiseRejectBlock)reject) {
|
655
|
668
|
NSInteger res = [self.rtcEngine stopEffect:(int)soundId];
|
656
|
|
- if (res < 0) {
|
|
669
|
+ if (res != 0) {
|
657
|
670
|
reject(@"131011", @"stopEffect failed", [self makeNSError:@{
|
658
|
671
|
@"code": @(131011),
|
659
|
672
|
@"message":@{
|
|
@@ -670,11 +683,11 @@ RCT_EXPORT_METHOD(stopEffect:(NSInteger) soundId
|
670
|
683
|
}
|
671
|
684
|
|
672
|
685
|
// stopAllEffects
|
673
|
|
-RCT_EXPORT_METHOD(stopAllEffects:
|
674
|
|
- (RCTPromiseResolveBlock)resolve
|
|
686
|
+RCT_EXPORT_METHOD(stopAllEffects
|
|
687
|
+ :(RCTPromiseResolveBlock)resolve
|
675
|
688
|
reject:(RCTPromiseRejectBlock)reject) {
|
676
|
689
|
NSInteger res = [self.rtcEngine stopAllEffects];
|
677
|
|
- if (res < 0) {
|
|
690
|
+ if (res != 0) {
|
678
|
691
|
reject(@"131012", @"stopAllEffects failed", [self makeNSError:@{
|
679
|
692
|
@"code": @(131012),
|
680
|
693
|
@"message":@{
|
|
@@ -691,12 +704,13 @@ RCT_EXPORT_METHOD(stopAllEffects:
|
691
|
704
|
}
|
692
|
705
|
|
693
|
706
|
// preloadEffect
|
694
|
|
-RCT_EXPORT_METHOD(preloadEffect:(NSInteger) soundId
|
|
707
|
+RCT_EXPORT_METHOD(preloadEffect
|
|
708
|
+ :(NSInteger) soundId
|
695
|
709
|
filePath:(NSString *)filePath
|
696
|
710
|
resolve:(RCTPromiseResolveBlock)resolve
|
697
|
711
|
reject:(RCTPromiseRejectBlock)reject) {
|
698
|
712
|
NSInteger res = [self.rtcEngine preloadEffect:(int)soundId filePath:filePath];
|
699
|
|
- if (res < 0) {
|
|
713
|
+ if (res != 0) {
|
700
|
714
|
reject(@"131013", @"preloadEffect failed", [self makeNSError:@{
|
701
|
715
|
@"code": @(131013),
|
702
|
716
|
@"message":@{
|
|
@@ -713,11 +727,12 @@ RCT_EXPORT_METHOD(preloadEffect:(NSInteger) soundId
|
713
|
727
|
}
|
714
|
728
|
|
715
|
729
|
// unload effect
|
716
|
|
-RCT_EXPORT_METHOD(unloadEffect:(NSInteger) soundId
|
|
730
|
+RCT_EXPORT_METHOD(unloadEffect
|
|
731
|
+ :(NSInteger) soundId
|
717
|
732
|
resolve:(RCTPromiseResolveBlock)resolve
|
718
|
733
|
reject:(RCTPromiseRejectBlock)reject) {
|
719
|
734
|
NSInteger res = [self.rtcEngine unloadEffect:(int)soundId];
|
720
|
|
- if (res < 0) {
|
|
735
|
+ if (res != 0) {
|
721
|
736
|
reject(@"131014", @"unloadEffect failed", [self makeNSError:@{
|
722
|
737
|
@"code": @(131014),
|
723
|
738
|
@"message":@{
|
|
@@ -734,11 +749,12 @@ RCT_EXPORT_METHOD(unloadEffect:(NSInteger) soundId
|
734
|
749
|
}
|
735
|
750
|
|
736
|
751
|
// pause effect by id
|
737
|
|
-RCT_EXPORT_METHOD(pauseEffect:(NSInteger) soundId
|
|
752
|
+RCT_EXPORT_METHOD(pauseEffect
|
|
753
|
+ :(NSInteger) soundId
|
738
|
754
|
resolve:(RCTPromiseResolveBlock)resolve
|
739
|
755
|
reject:(RCTPromiseRejectBlock)reject) {
|
740
|
756
|
NSInteger res = [self.rtcEngine unloadEffect:(int)soundId];
|
741
|
|
- if (res < 0) {
|
|
757
|
+ if (res != 0) {
|
742
|
758
|
reject(@"131014", @"pauseEffect failed", [self makeNSError:@{
|
743
|
759
|
@"code": @(131014),
|
744
|
760
|
@"message":@{
|
|
@@ -759,7 +775,7 @@ RCT_EXPORT_METHOD(pauseAllEffects:(NSInteger) soundId
|
759
|
775
|
resolve:(RCTPromiseResolveBlock)resolve
|
760
|
776
|
reject:(RCTPromiseRejectBlock)reject) {
|
761
|
777
|
NSInteger res = [self.rtcEngine unloadEffect:(int)soundId];
|
762
|
|
- if (res < 0) {
|
|
778
|
+ if (res != 0) {
|
763
|
779
|
reject(@"131014", @"pauseAllEffects failed", [self makeNSError:@{
|
764
|
780
|
@"code": @(131014),
|
765
|
781
|
@"message":@{
|
|
@@ -780,7 +796,7 @@ RCT_EXPORT_METHOD(resumeEffect:(NSInteger) soundId
|
780
|
796
|
resolve:(RCTPromiseResolveBlock)resolve
|
781
|
797
|
reject:(RCTPromiseRejectBlock)reject) {
|
782
|
798
|
NSInteger res = [self.rtcEngine resumeEffect:(int)soundId];
|
783
|
|
- if (res < 0) {
|
|
799
|
+ if (res != 0) {
|
784
|
800
|
reject(@"131015", @"resumeEffect failed", [self makeNSError:@{
|
785
|
801
|
@"code": @(131015),
|
786
|
802
|
@"message":@{
|
|
@@ -801,7 +817,7 @@ RCT_EXPORT_METHOD(resumeAllEffects
|
801
|
817
|
:(RCTPromiseResolveBlock)resolve
|
802
|
818
|
reject:(RCTPromiseRejectBlock)reject) {
|
803
|
819
|
NSInteger res = [self.rtcEngine resumeAllEffects];
|
804
|
|
- if (res < 0) {
|
|
820
|
+ if (res != 0) {
|
805
|
821
|
reject(@"131016", @"resumeAllEffects failed", [self makeNSError:@{
|
806
|
822
|
@"code": @(131016),
|
807
|
823
|
@"message":@{
|
|
@@ -834,7 +850,7 @@ RCT_EXPORT_METHOD(startAudioRecording:(NSDictionary *)options
|
834
|
850
|
break;
|
835
|
851
|
}
|
836
|
852
|
NSInteger res = [self.rtcEngine startAudioRecording:[options[@"filePath"] stringValue] quality:qualityType];
|
837
|
|
- if (res < 0) {
|
|
853
|
+ if (res != 0) {
|
838
|
854
|
reject(@"131017", @"startAudioRecording failed", [self makeNSError:@{
|
839
|
855
|
@"code": @(131017),
|
840
|
856
|
@"message":@{
|
|
@@ -855,7 +871,7 @@ RCT_EXPORT_METHOD(stopAudioRecording
|
855
|
871
|
:(RCTPromiseResolveBlock)resolve
|
856
|
872
|
reject:(RCTPromiseRejectBlock)reject) {
|
857
|
873
|
NSInteger res = [self.rtcEngine stopAudioRecording];
|
858
|
|
- if (res < 0) {
|
|
874
|
+ if (res != 0) {
|
859
|
875
|
reject(@"131018", @"stopAudioRecording failed", [self makeNSError:@{
|
860
|
876
|
@"code": @(131018),
|
861
|
877
|
@"message":@{
|
|
@@ -907,7 +923,7 @@ RCT_EXPORT_METHOD(startEchoTest
|
907
|
923
|
@"elapsed": @(elapsed)
|
908
|
924
|
});
|
909
|
925
|
}];
|
910
|
|
- if (res < 0) {
|
|
926
|
+ if (res != 0) {
|
911
|
927
|
reject(@"131019", @"startEchoTest failed", [self makeNSError:@{
|
912
|
928
|
@"code": @(131019),
|
913
|
929
|
@"message":@{
|
|
@@ -928,7 +944,7 @@ RCT_EXPORT_METHOD(stopEchoTest
|
928
|
944
|
:(RCTPromiseResolveBlock)resolve
|
929
|
945
|
reject:(RCTPromiseRejectBlock)reject) {
|
930
|
946
|
NSInteger res = [self.rtcEngine stopEchoTest];
|
931
|
|
- if (res < 0) {
|
|
947
|
+ if (res != 0) {
|
932
|
948
|
reject(@"131020", @"stopEchoTest failed", [self makeNSError:@{
|
933
|
949
|
@"code": @(131020),
|
934
|
950
|
@"message":@{
|
|
@@ -949,7 +965,7 @@ RCT_EXPORT_METHOD(enableLastmileTest
|
949
|
965
|
:(RCTPromiseResolveBlock)resolve
|
950
|
966
|
reject:(RCTPromiseRejectBlock)reject) {
|
951
|
967
|
NSInteger res = [self.rtcEngine enableLastmileTest];
|
952
|
|
- if (res < 0) {
|
|
968
|
+ if (res != 0) {
|
953
|
969
|
reject(@"131021", @"enableLastmileTest failed", [self makeNSError:@{
|
954
|
970
|
@"code": @(131021),
|
955
|
971
|
@"message":@{
|
|
@@ -970,7 +986,7 @@ RCT_EXPORT_METHOD(disableLastmileTest
|
970
|
986
|
:(RCTPromiseResolveBlock)resolve
|
971
|
987
|
reject:(RCTPromiseRejectBlock)reject) {
|
972
|
988
|
NSInteger res = [self.rtcEngine disableLastmileTest];
|
973
|
|
- if (res < 0) {
|
|
989
|
+ if (res != 0) {
|
974
|
990
|
reject(@"131022", @"disableLastmileTest failed", [self makeNSError:@{
|
975
|
991
|
@"code": @(131022),
|
976
|
992
|
@"message":@{
|
|
@@ -995,7 +1011,7 @@ RCT_EXPORT_METHOD(setRecordingAudioFrameParametersWithSampleRate:(NSDictionary *
|
995
|
1011
|
mode:(AgoraAudioRawFrameOperationMode)[options[@"mode"] integerValue]
|
996
|
1012
|
samplesPerCall:[options[@"samplesPerCall"] integerValue]
|
997
|
1013
|
];
|
998
|
|
- if (res < 0) {
|
|
1014
|
+ if (res != 0) {
|
999
|
1015
|
reject(@"131023", @"setRecordingAudioFrameParametersWithSampleRate failed", [self makeNSError:@{
|
1000
|
1016
|
@"code": @(131023),
|
1001
|
1017
|
@"message":@{
|
|
@@ -1020,7 +1036,7 @@ RCT_EXPORT_METHOD(setPlaybackAudioFrameParametersWithSampleRate:(NSDictionary *)
|
1020
|
1036
|
mode:(AgoraAudioRawFrameOperationMode)[options[@"mode"] integerValue]
|
1021
|
1037
|
samplesPerCall:[options[@"samplesPerCall"] integerValue]
|
1022
|
1038
|
];
|
1023
|
|
- if (res < 0) {
|
|
1039
|
+ if (res != 0) {
|
1024
|
1040
|
reject(@"131024", @"setPlaybackAudioFrameParametersWithSampleRate failed", [self makeNSError:@{
|
1025
|
1041
|
@"code": @(131024),
|
1026
|
1042
|
@"message":@{
|
|
@@ -1042,7 +1058,7 @@ RCT_EXPORT_METHOD(setMixedAudioFrameParametersWithSampleRate
|
1042
|
1058
|
resolve:(RCTPromiseResolveBlock)resolve
|
1043
|
1059
|
reject:(RCTPromiseRejectBlock)reject) {
|
1044
|
1060
|
NSInteger res = [self.rtcEngine setMixedAudioFrameParametersWithSampleRate:[options[@"sampleRate"] integerValue] samplesPerCall:[options[@"samplesPerCall"] integerValue]];
|
1045
|
|
- if (res < 0) {
|
|
1061
|
+ if (res != 0) {
|
1046
|
1062
|
reject(@"131025", @"setMixedAudioFrameParametersWithSampleRate failed", [self makeNSError:@{
|
1047
|
1063
|
@"code": @(131025),
|
1048
|
1064
|
@"message":@{
|
|
@@ -1069,7 +1085,7 @@ RCT_EXPORT_METHOD(addVideoWatermark:(NSDictionary *)options
|
1069
|
1085
|
@"width": options[@"width"],
|
1070
|
1086
|
@"height": options[@"height"]
|
1071
|
1087
|
}]];
|
1072
|
|
- if (res < 0) {
|
|
1088
|
+ if (res != 0) {
|
1073
|
1089
|
reject(@"131026", @"addVideoWatermark failed", [self makeNSError:@{
|
1074
|
1090
|
@"code": @(131026),
|
1075
|
1091
|
@"message":@{
|
|
@@ -1090,7 +1106,7 @@ RCT_EXPORT_METHOD(clearVideoWatermarks
|
1090
|
1106
|
:(RCTPromiseResolveBlock)resolve
|
1091
|
1107
|
reject:(RCTPromiseRejectBlock)reject) {
|
1092
|
1108
|
NSInteger res = [self.rtcEngine clearVideoWatermarks];
|
1093
|
|
- if (res < 0) {
|
|
1109
|
+ if (res != 0) {
|
1094
|
1110
|
reject(@"131027", @"clearVideoWatermarks failed", [self makeNSError:@{
|
1095
|
1111
|
@"code": @(131027),
|
1096
|
1112
|
@"message":@{
|
|
@@ -1112,7 +1128,7 @@ RCT_EXPORT_METHOD(enableDualStreamMode
|
1112
|
1128
|
resolve:(RCTPromiseResolveBlock)resolve
|
1113
|
1129
|
reject:(RCTPromiseRejectBlock)reject) {
|
1114
|
1130
|
NSInteger res = [self.rtcEngine enableDualStreamMode:enabled];
|
1115
|
|
- if (res < 0) {
|
|
1131
|
+ if (res != 0) {
|
1116
|
1132
|
reject(@"131028", @"enableDualStreamMode failed", [self makeNSError:@{
|
1117
|
1133
|
@"code": @(131028),
|
1118
|
1134
|
@"message":@{
|
|
@@ -1135,7 +1151,7 @@ RCT_EXPORT_METHOD(setRemoteVideoStream
|
1135
|
1151
|
reject:(RCTPromiseRejectBlock)reject) {
|
1136
|
1152
|
NSInteger res = [self.rtcEngine setRemoteVideoStream:[options[@"uid"] integerValue]
|
1137
|
1153
|
type:(AgoraVideoStreamType)[options[@"streamType"] integerValue]];
|
1138
|
|
- if (res < 0) {
|
|
1154
|
+ if (res != 0) {
|
1139
|
1155
|
reject(@"131029", @"setRemoteVideoStream failed", [self makeNSError:@{
|
1140
|
1156
|
@"code": @(131029),
|
1141
|
1157
|
@"message":@{
|
|
@@ -1157,7 +1173,7 @@ RCT_EXPORT_METHOD(setRemoteDefaultVideoStreamType
|
1157
|
1173
|
resolve:(RCTPromiseResolveBlock)resolve
|
1158
|
1174
|
reject:(RCTPromiseRejectBlock)reject) {
|
1159
|
1175
|
NSInteger res = [self.rtcEngine setRemoteDefaultVideoStreamType:(AgoraVideoStreamType)[options[@"streamType"] integerValue]];
|
1160
|
|
- if (res < 0) {
|
|
1176
|
+ if (res != 0) {
|
1161
|
1177
|
reject(@"131030", @"setRemoteDefaultVideoStreamType failed", [self makeNSError:@{
|
1162
|
1178
|
@"code": @(131030),
|
1163
|
1179
|
@"message":@{
|
|
@@ -1179,17 +1195,17 @@ RCT_EXPORT_METHOD(addInjectStreamUrl
|
1179
|
1195
|
resolve:(RCTPromiseResolveBlock)resolve
|
1180
|
1196
|
reject:(RCTPromiseRejectBlock)reject) {
|
1181
|
1197
|
AgoraLiveInjectStreamConfig *config = [AgoraLiveInjectStreamConfig new];
|
1182
|
|
- config.size = CGSizeMake([options[@"config.size.width"] floatValue], [options[@"config.size.height"] floatValue]);
|
1183
|
|
- config.videoGop = [options[@"config.videoGop"] integerValue];
|
1184
|
|
- config.videoFramerate = [options[@"config.videoFramerate"] integerValue];
|
1185
|
|
- config.videoBitrate = [options[@"config.videoBitrate"] integerValue];
|
1186
|
|
- config.audioSampleRate = (AgoraAudioSampleRateType)[options[@"config.audioSampleRate"] integerValue];
|
1187
|
|
- config.audioBitrate = [options[@"config.audioBitrate"] integerValue];
|
1188
|
|
- config.audioChannels = [options[@"config.audioChannels"] integerValue];
|
|
1198
|
+ config.size = CGSizeMake([options[@"config"][@"size"][@"width"] floatValue], [options[@"config"][@"size"][@"height"] floatValue]);
|
|
1199
|
+ config.videoGop = [options[@"config"][@"videoGop"] integerValue];
|
|
1200
|
+ config.videoFramerate = [options[@"config"][@"videoFramerate"] integerValue];
|
|
1201
|
+ config.videoBitrate = [options[@"config"][@"videoBitrate"] integerValue];
|
|
1202
|
+ config.audioSampleRate = (AgoraAudioSampleRateType)[options[@"config"][@"audioSampleRate"] integerValue];
|
|
1203
|
+ config.audioBitrate = [options[@"config"][@"audioBitrate"] integerValue];
|
|
1204
|
+ config.audioChannels = [options[@"config"][@"audioChannels"] integerValue];
|
1189
|
1205
|
|
1190
|
1206
|
NSInteger res = [self.rtcEngine addInjectStreamUrl:[options[@"url"] stringValue]
|
1191
|
1207
|
config:config];
|
1192
|
|
- if (res < 0) {
|
|
1208
|
+ if (res != 0) {
|
1193
|
1209
|
reject(@"131031", @"addInjectStreamUrl failed", [self makeNSError:@{
|
1194
|
1210
|
@"code": @(131031),
|
1195
|
1211
|
@"message":@{
|
|
@@ -1212,7 +1228,7 @@ RCT_EXPORT_METHOD(removeInjectStreamUrl
|
1212
|
1228
|
reject:(RCTPromiseRejectBlock)reject) {
|
1213
|
1229
|
|
1214
|
1230
|
NSInteger res = [self.rtcEngine removeInjectStreamUrl:url];
|
1215
|
|
- if (res < 0) {
|
|
1231
|
+ if (res != 0) {
|
1216
|
1232
|
reject(@"131032", @"removeInjectStreamUrl failed", [self makeNSError:@{
|
1217
|
1233
|
@"code": @(131032),
|
1218
|
1234
|
@"message":@{
|
|
@@ -1373,7 +1389,8 @@ RCT_EXPORT_METHOD(setCameraExposurePosition
|
1373
|
1389
|
|
1374
|
1390
|
// enable camera torch
|
1375
|
1391
|
RCT_EXPORT_METHOD(setCameraTorchOn:(BOOL)isOn
|
1376
|
|
- resolve:(RCTPromiseResolveBlock)resolve) {
|
|
1392
|
+ resolve:(RCTPromiseResolveBlock)resolve
|
|
1393
|
+ reject:(RCTPromiseRejectBlock)reject) {
|
1377
|
1394
|
BOOL res = [self.rtcEngine setCameraTorchOn:isOn];
|
1378
|
1395
|
resolve(@{
|
1379
|
1396
|
@"success": @(YES),
|
|
@@ -1383,7 +1400,8 @@ RCT_EXPORT_METHOD(setCameraTorchOn:(BOOL)isOn
|
1383
|
1400
|
|
1384
|
1401
|
// enable auto focus face mode
|
1385
|
1402
|
RCT_EXPORT_METHOD(setCameraAutoFocusFaceModeEnabled:(BOOL)enable
|
1386
|
|
- resolve:(RCTPromiseResolveBlock)resolve) {
|
|
1403
|
+ resolve:(RCTPromiseResolveBlock)resolve
|
|
1404
|
+ reject:(RCTPromiseRejectBlock)reject) {
|
1387
|
1405
|
BOOL res = [self.rtcEngine setCameraAutoFocusFaceModeEnabled:enable];
|
1388
|
1406
|
resolve(@{
|
1389
|
1407
|
@"success": @(YES),
|
|
@@ -1406,7 +1424,7 @@ RCT_EXPORT_METHOD(setLog
|
1406
|
1424
|
resolve:(RCTPromiseResolveBlock)resolve
|
1407
|
1425
|
reject:(RCTPromiseRejectBlock)reject) {
|
1408
|
1426
|
int res = [self.rtcEngine setLogFilter:level];
|
1409
|
|
- if (res < 0) {
|
|
1427
|
+ if (res != 0) {
|
1410
|
1428
|
reject(@"131036", @"setLogFilter failed", [self makeNSError:@{
|
1411
|
1429
|
@"code": @(131036),
|
1412
|
1430
|
@"message":@{
|
|
@@ -1421,7 +1439,7 @@ RCT_EXPORT_METHOD(setLog
|
1421
|
1439
|
});
|
1422
|
1440
|
}
|
1423
|
1441
|
res = [self.rtcEngine setLogFile:filePath];
|
1424
|
|
- if (res < 0) {
|
|
1442
|
+ if (res != 0) {
|
1425
|
1443
|
reject(@"131037", @"setLogFile failed", [self makeNSError:@{
|
1426
|
1444
|
@"code": @(131037),
|
1427
|
1445
|
@"message":@{
|
|
@@ -1458,7 +1476,9 @@ RCT_EXPORT_METHOD(sendStreamMessage:(NSInteger)streamId data:(NSData*)data
|
1458
|
1476
|
}
|
1459
|
1477
|
|
1460
|
1478
|
// get sdk version
|
1461
|
|
-RCT_EXPORT_METHOD(getSdkVersion:(RCTPromiseResolveBlock) resolve) {
|
|
1479
|
+RCT_EXPORT_METHOD(getSdkVersion
|
|
1480
|
+ :(RCTPromiseResolveBlock) resolve
|
|
1481
|
+ reject:(RCTPromiseRejectBlock) reject) {
|
1462
|
1482
|
resolve(@[[AgoraRtcEngineKit getSdkVersion]]);
|
1463
|
1483
|
}
|
1464
|
1484
|
|
|
@@ -1494,7 +1514,7 @@ RCT_EXPORT_METHOD(addPublishStreamUrl:(NSDictionary *)options) {
|
1494
|
1514
|
RCT_EXPORT_METHOD(setLiveTranscoding:(NSDictionary *)options) {
|
1495
|
1515
|
AgoraLiveTranscoding *transcoding = AgoraLiveTranscoding.defaultTranscoding;
|
1496
|
1516
|
if (options[@"size"] != nil) {
|
1497
|
|
- transcoding.size = CGSizeMake([options[@"size.width"] doubleValue], [options[@"size.height"] doubleValue]);
|
|
1517
|
+ transcoding.size = CGSizeMake([options[@"size"][@"width"] doubleValue], [options[@"size"][@"height"] doubleValue]);
|
1498
|
1518
|
}
|
1499
|
1519
|
if (options[@"videoBitrate"] != nil) {
|
1500
|
1520
|
transcoding.videoBitrate = [options[@"videoBitrate"] integerValue];
|
|
@@ -1516,7 +1536,7 @@ RCT_EXPORT_METHOD(setLiveTranscoding:(NSDictionary *)options) {
|
1516
|
1536
|
for (NSDictionary *optionUser in options[@"users"]) {
|
1517
|
1537
|
AgoraLiveTranscodingUser *liveUser = [AgoraLiveTranscodingUser new];
|
1518
|
1538
|
liveUser.uid = (NSUInteger)[optionUser[@"uid"] integerValue];
|
1519
|
|
- liveUser.rect = CGRectMake((CGFloat)[options[@"backgroundColor.x"] floatValue], (CGFloat)[options[@"backgroundColor.y"] floatValue], (CGFloat)[options[@"backgroundColor.width"] floatValue], (CGFloat)[options[@"backgroundColor.height"] floatValue]);
|
|
1539
|
+ liveUser.rect = CGRectMake((CGFloat)[options[@"backgroundColor"][@"x"] floatValue], (CGFloat)[options[@"backgroundColor"][@"y"] floatValue], (CGFloat)[options[@"backgroundColor"][@"width"] floatValue], (CGFloat)[options[@"backgroundColor"][@"height"] floatValue]);
|
1520
|
1540
|
liveUser.zOrder = [optionUser[@"zOrder"] integerValue];
|
1521
|
1541
|
liveUser.alpha = [optionUser[@"alpha"] doubleValue];
|
1522
|
1542
|
liveUser.audioChannel = [optionUser[@"audioChannel"] integerValue];
|
|
@@ -1529,24 +1549,24 @@ RCT_EXPORT_METHOD(setLiveTranscoding:(NSDictionary *)options) {
|
1529
|
1549
|
}
|
1530
|
1550
|
if (options[@"watermark"] != nil) {
|
1531
|
1551
|
transcoding.watermark = [self makeAgoraImage:@{
|
1532
|
|
- @"url": options[@"watermark.url"],
|
1533
|
|
- @"x": options[@"watermark.x"],
|
1534
|
|
- @"y": options[@"watermark.y"],
|
1535
|
|
- @"width": options[@"watermark.width"],
|
1536
|
|
- @"height": options[@"watermark.height"]
|
|
1552
|
+ @"url": options[@"watermark"][@"url"],
|
|
1553
|
+ @"x": options[@"watermark"][@"x"],
|
|
1554
|
+ @"y": options[@"watermark"][@"y"],
|
|
1555
|
+ @"width": options[@"watermark"][@"width"],
|
|
1556
|
+ @"height": options[@"watermark"][@"height"]
|
1537
|
1557
|
}];
|
1538
|
1558
|
}
|
1539
|
1559
|
if (options[@"backgroundImage"] != nil) {
|
1540
|
1560
|
transcoding.backgroundImage = [self makeAgoraImage:@{
|
1541
|
|
- @"url": options[@"backgroundImage.url"],
|
1542
|
|
- @"x": options[@"backgroundImage.x"],
|
1543
|
|
- @"y": options[@"backgroundImage.y"],
|
1544
|
|
- @"width": options[@"backgroundImage.width"],
|
1545
|
|
- @"height": options[@"backgroundImage.height"]
|
|
1561
|
+ @"url": options[@"backgroundImage"][@"url"],
|
|
1562
|
+ @"x": options[@"backgroundImage"][@"x"],
|
|
1563
|
+ @"y": options[@"backgroundImage"][@"y"],
|
|
1564
|
+ @"width": options[@"backgroundImage"][@"width"],
|
|
1565
|
+ @"height": options[@"backgroundImage"][@"height"]
|
1546
|
1566
|
}];
|
1547
|
1567
|
}
|
1548
|
1568
|
if (options[@"backgroundColor"] != nil) {
|
1549
|
|
- transcoding.backgroundColor = [[UIColor new] initWithRed:(CGFloat)[options[@"backgroundColor.red"] floatValue] green:(CGFloat)[options[@"backgroundColor.green"] floatValue] blue:(CGFloat)[options[@"backgroundColor.blue"] floatValue] alpha:(CGFloat)[options[@"backgroundColor.alpha"] floatValue]];
|
|
1569
|
+ transcoding.backgroundColor = [[UIColor new] initWithRed:(CGFloat)[options[@"backgroundColor"][@"red"] floatValue] green:(CGFloat)[options[@"backgroundColor"][@"green"] floatValue] blue:(CGFloat)[options[@"backgroundColor"][@"blue"] floatValue] alpha:(CGFloat)[options[@"backgroundColor"][@"alpha"] floatValue]];
|
1550
|
1570
|
}
|
1551
|
1571
|
if (options[@"audioSampleRate"] != nil) {
|
1552
|
1572
|
transcoding.audioSampleRate = (AgoraAudioSampleRateType)[options[@"audioSampleRate"] integerValue];
|
|
@@ -1658,11 +1678,13 @@ RCT_EXPORT_METHOD(setLiveTranscoding:(NSDictionary *)options) {
|
1658
|
1678
|
}
|
1659
|
1679
|
|
1660
|
1680
|
- (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine didApiCallExecute:(NSInteger)error api:(NSString *_Nonnull)api result:(NSString *_Nonnull)result {
|
1661
|
|
- [self sendEvent:DidOccurError params:@{
|
1662
|
|
- @"api": api,
|
1663
|
|
- @"result": result,
|
1664
|
|
- @"error": @(error)
|
1665
|
|
- }];
|
|
1681
|
+ if (error != 0) {
|
|
1682
|
+ [self sendEvent:DidOccurError params:@{
|
|
1683
|
+ @"api": api,
|
|
1684
|
+ @"result": result,
|
|
1685
|
+ @"error": @(error)
|
|
1686
|
+ }];
|
|
1687
|
+ }
|
1666
|
1688
|
}
|
1667
|
1689
|
|
1668
|
1690
|
- (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine didJoinChannel:(NSString *_Nonnull)channel withUid:(NSUInteger)uid elapsed:(NSInteger)elapsed {
|
|
@@ -1953,7 +1975,7 @@ RCT_EXPORT_METHOD(setLiveTranscoding:(NSDictionary *)options) {
|
1953
|
1975
|
@"sentBitrate": @(stats.sentBitrate),
|
1954
|
1976
|
@"sentFrameRate": @(stats.sentFrameRate)
|
1955
|
1977
|
}
|
1956
|
|
- }];
|
|
1978
|
+ }];
|
1957
|
1979
|
}
|
1958
|
1980
|
|
1959
|
1981
|
- (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine remoteVideoStats:(AgoraRtcRemoteVideoStats *_Nonnull)stats {
|