@@ -170,7 +170,7 @@ - (void)addParticipantView:(TVIVideoView *)view sid:(NSString *)sid trackSid:(NS
170
170
if (self.camera == nil ) {
171
171
return ;
172
172
}
173
- self.localVideoTrack = [TVILocalVideoTrack trackWithSource: self .camera enabled: YES name: @" camera" ];
173
+ self.localVideoTrack = [TVILocalVideoTrack trackWithSource: self .camera enabled: NO name: @" camera" ];
174
174
}
175
175
176
176
- (void )startCameraCapture {
@@ -233,19 +233,25 @@ - (void)startCameraCapture {
233
233
resolve (@(enabled));
234
234
}
235
235
236
- RCT_REMAP_METHOD (setLocalVideoEnabled, enabled:(BOOL )enabled setLocalVideoEnabledWithResolver:(RCTPromiseResolveBlock)resolve
237
- rejecter:(RCTPromiseRejectBlock)reject) {
236
+ - (bool )_setLocalVideoEnabled : (bool )enabled {
238
237
if (self.localVideoTrack != nil ) {
239
238
[self .localVideoTrack setEnabled: enabled];
240
- if (self.camera && self. camera . device ) {
239
+ if (self.camera ) {
241
240
if (enabled) {
242
241
[self startCameraCapture ];
243
242
} else {
244
243
[self clearCameraInstance ];
245
244
}
245
+ return enabled;
246
246
}
247
- resolve (@(enabled));
248
247
}
248
+ return false ;
249
+ }
250
+
251
+ RCT_REMAP_METHOD (setLocalVideoEnabled, enabled:(BOOL )enabled setLocalVideoEnabledWithResolver:(RCTPromiseResolveBlock)resolve
252
+ rejecter:(RCTPromiseRejectBlock)reject) {
253
+ bool result = [self _setLocalVideoEnabled: enabled];
254
+ resolve (@(result));
249
255
}
250
256
251
257
RCT_EXPORT_METHOD (flipCamera) {
@@ -378,9 +384,7 @@ -(NSMutableDictionary*)convertLocalVideoTrackStats:(TVILocalVideoTrackStats *)st
378
384
}
379
385
380
386
RCT_EXPORT_METHOD (connect:(NSString *)accessToken roomName:(NSString *)roomName enableVideo:(BOOL *)enableVideo encodingParameters:(NSDictionary *)encodingParameters enableNetworkQualityReporting:(BOOL *)enableNetworkQualityReporting) {
381
- if (enableVideo) {
382
- [self startCameraCapture ];
383
- }
387
+ [self _setLocalVideoEnabled: enableVideo];
384
388
385
389
TVIConnectOptions *connectOptions = [TVIConnectOptions optionsWithToken: accessToken block: ^(TVIConnectOptionsBuilder * _Nonnull builder) {
386
390
if (self.localVideoTrack ) {
@@ -391,7 +395,6 @@ -(NSMutableDictionary*)convertLocalVideoTrackStats:(TVILocalVideoTrackStats *)st
391
395
builder.audioTracks = @[self .localAudioTrack];
392
396
}
393
397
394
-
395
398
self.localDataTrack = [TVILocalDataTrack track ];
396
399
397
400
if (self.localDataTrack ) {
@@ -409,12 +412,12 @@ -(NSMutableDictionary*)convertLocalVideoTrackStats:(TVILocalVideoTrackStats *)st
409
412
NSInteger videoBitrate = [encodingParameters[@" videoBitrate" ] integerValue ];
410
413
builder.encodingParameters = [[TVIEncodingParameters alloc ] initWithAudioBitrate: (audioBitrate) ? audioBitrate : 40 videoBitrate: (videoBitrate) ? videoBitrate : 1500 ];
411
414
}
412
-
415
+
413
416
if (enableNetworkQualityReporting) {
414
417
builder.networkQualityEnabled = true ;
415
418
builder.networkQualityConfiguration = [ [TVINetworkQualityConfiguration alloc ] initWithLocalVerbosity: TVINetworkQualityVerbosityMinimal remoteVerbosity: TVINetworkQualityVerbosityMinimal];
416
419
}
417
-
420
+
418
421
}];
419
422
420
423
self.room = [TwilioVideoSDK connectWithOptions: connectOptions delegate: self ];
@@ -490,7 +493,7 @@ - (void)didConnectToRoom:(TVIRoom *)room {
490
493
}
491
494
self.localParticipant = room.localParticipant ;
492
495
self.localParticipant .delegate = self;
493
-
496
+
494
497
[participants addObject: [self .localParticipant toJSON ]];
495
498
[self sendEventCheckingListenerWithName: roomDidConnect body: @{ @" roomName" : room.name , @" roomSid" : room.sid , @" participants" : participants }];
496
499
0 commit comments