Skip to content

Commit

Permalink
[ios] - remove renderer for local video stream only if it exists
Browse files Browse the repository at this point in the history
  • Loading branch information
YuliaGrigorieva committed Aug 21, 2023
1 parent 0a2f8b8 commit e8e575e
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions ios/Classes/VICallModule.m
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ - (instancetype)initWithRegistrar:(NSObject<FlutterPluginRegistrar> *)registrar
callManager:(VoximplantCallManager *)callManager
call:(VICall *)call {
self = [super init];

if (self) {
self.registrar = registrar;
self.callManager = callManager;
Expand All @@ -40,7 +40,7 @@ - (instancetype)initWithRegistrar:(NSObject<FlutterPluginRegistrar> *)registrar
[self.eventChannel setStreamHandler:self];
[self.eventChannelQualityIssues setStreamHandler:self];
}

return self;
}

Expand Down Expand Up @@ -280,9 +280,11 @@ - (void)removeVideoRenderer:(NSDictionary *)arguments result:(FlutterResult)resu
}
if ([self.localVideoStream.streamId isEqualToString:streamId]) {
VoximplantRenderer *renderer = [self.renderers objectForKey:streamId];
[self.localVideoStream removeRenderer:renderer];
[renderer cleanup];
[self.renderers removeObjectForKey:streamId];
if (renderer) {
[self.localVideoStream removeRenderer:renderer];
[renderer cleanup];
[self.renderers removeObjectForKey:streamId];
}
self.localVideoStream = nil;
result(nil);
return;
Expand All @@ -304,7 +306,7 @@ - (void)removeVideoRenderer:(NSDictionary *)arguments result:(FlutterResult)resu
- (void)getCallDuration:(NSDictionary *)arguments result:(FlutterResult)result {
result([NSNumber fromTimeInterval:[self.call duration]]);
}

- (BOOL)hasVideoStreamId:(NSString *)streamId {
return [self.localVideoStream.streamId isEqualToString:streamId] || [self.remoteVideoStreams objectForKey:streamId] != nil;
}
Expand All @@ -327,7 +329,7 @@ - (void)cleanupResources {
}];
[self.renderers removeAllObjects];
[self.remoteVideoStreams removeAllObjects];

for (VIEndpoint *endpoint in self.call.endpoints) {
endpoint.delegate = nil;
}
Expand Down Expand Up @@ -412,7 +414,7 @@ - (void)call:(VICall *)call didAddEndpoint:(VIEndpoint *)endpoint {
}

- (void)call:(VICall *)call didReceiveStatistics:(VICallStats *)stat {

}

- (void)callDidStartReconnecting:(VICall *)call {
Expand Down Expand Up @@ -674,7 +676,7 @@ - (FlutterError * _Nullable)onListenWithArguments:(id _Nullable)arguments eventS
if ([type isEqual:channelName]) {
self.eventSink = events;
[self.call addDelegate:self];

for (VIEndpoint *endpoint in self.call.endpoints) {
endpoint.delegate = self;
}
Expand Down

0 comments on commit e8e575e

Please sign in to comment.