Skip to content

Commit

Permalink
Merge branch 'task/CHT-1284-Assert-failed-at-setVideoCapturerInDevice…
Browse files Browse the repository at this point in the history
…-for-iOS-app-(simulator)' into 'develop'

CHT-1284: Assert failed at setVideoCapturerInDevice for iOS app (simulator)

Closes CHT-1284

See merge request megachat/MEGAchat!1952
  • Loading branch information
jnavarrom committed Jun 25, 2024
2 parents a90d92f + ed37ebc commit 1495258
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 14 deletions.
36 changes: 24 additions & 12 deletions bindings/Objective-C/MEGAChatSdk.mm
Original file line number Diff line number Diff line change
Expand Up @@ -1730,14 +1730,14 @@ - (MEGAStringList *)chatVideoInDevices {
}

- (void)setChatVideoInDevices:(NSString *)devices {
if (self.megaChatApi) {
return self.megaChatApi->setChatVideoInDevice(devices.UTF8String);
if (self.megaChatApi && self.cameraSupported) {
self.megaChatApi->setChatVideoInDevice(devices.UTF8String);
}
}

- (void)setChatVideoInDevices:(NSString *)devices delegate:(id<MEGAChatRequestDelegate>)delegate {
if (self.megaChatApi) {
return self.megaChatApi->setChatVideoInDevice(devices.UTF8String, [self createDelegateMEGAChatRequestListener:delegate singleListener:YES]);
if (self.megaChatApi && self.cameraSupported) {
self.megaChatApi->setChatVideoInDevice(devices.UTF8String, [self createDelegateMEGAChatRequestListener:delegate singleListener:YES]);
}
}

Expand All @@ -1750,15 +1750,22 @@ - (NSString *)videoDeviceSelected {
return selectedVideoDeviceString;
}

- (void)startCallInChat:(uint64_t)chatId enableVideo:(BOOL)enableVideo enableAudio:(BOOL)enableAudio notRinging:(BOOL)notRinging delegate:(id<MEGAChatRequestDelegate>)delegate {
- (void)startCallInChat:(uint64_t)chatId
enableVideo:(BOOL)enableVideo
enableAudio:(BOOL)enableAudio
notRinging:(BOOL)notRinging
delegate:(id<MEGAChatRequestDelegate>)delegate {
if (self.megaChatApi) {
self.megaChatApi->startCallInChat(chatId, enableVideo, enableAudio, notRinging,[self createDelegateMEGAChatRequestListener:delegate singleListener:YES]);
self.megaChatApi->startCallInChat(chatId, enableVideo && self.cameraSupported, enableAudio, notRinging,[self createDelegateMEGAChatRequestListener:delegate singleListener:YES]);
}
}

- (void)startCallInChat:(uint64_t)chatId enableVideo:(BOOL)enableVideo enableAudio:(BOOL)enableAudio notRinging:(BOOL)notRinging {
- (void)startCallInChat:(uint64_t)chatId
enableVideo:(BOOL)enableVideo
enableAudio:(BOOL)enableAudio
notRinging:(BOOL)notRinging {
if (self.megaChatApi) {
self.megaChatApi->startCallInChat(chatId, enableVideo, enableAudio, notRinging);
self.megaChatApi->startCallInChat(chatId, enableVideo && self.cameraSupported, enableAudio, notRinging);
}
}

Expand Down Expand Up @@ -1828,26 +1835,31 @@ - (void)disableAudioForChat:(uint64_t)chatId {
}
}

- (BOOL)cameraSupported {
// [CHT-1284] iOS simulators are not supporting camera devices
return [[self chatVideoInDevices] size] > 0;
}

- (void)enableVideoForChat:(uint64_t)chatId delegate:(id<MEGAChatRequestDelegate>)delegate {
if (self.megaChatApi) {
if (self.megaChatApi && self.cameraSupported) {
self.megaChatApi->enableVideo(chatId, [self createDelegateMEGAChatRequestListener:delegate singleListener:YES]);
}
}

- (void)enableVideoForChat:(uint64_t)chatId {
if (self.megaChatApi) {
if (self.megaChatApi && self.cameraSupported) {
self.megaChatApi->enableVideo(chatId);
}
}

- (void)disableVideoForChat:(uint64_t)chatId delegate:(id<MEGAChatRequestDelegate>)delegate {
if (self.megaChatApi) {
if (self.megaChatApi && self.cameraSupported) {
self.megaChatApi->disableVideo(chatId, [self createDelegateMEGAChatRequestListener:delegate singleListener:YES]);
}
}

- (void)disableVideoForChat:(uint64_t)chatId {
if (self.megaChatApi) {
if (self.megaChatApi && self.cameraSupported) {
self.megaChatApi->disableVideo(chatId);
}
}
Expand Down
2 changes: 0 additions & 2 deletions src/rtcModule/webrtc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4899,10 +4899,8 @@ void RtcModuleSfu::openCameraDevice()
{
RTCM_LOG_WARNING("%sopenCameraDevice: default camera in device is not set",
getLoggingName());
#ifndef TARGET_OS_SIMULATOR
// it's expected to not have a camera device in the simulator but we do not want to crash here so that automated tests do not stop
assert(false);
#endif
// Try to get default (it already set in the constructor but just in case)
mSelectedCameraDeviceId = getDefaultCameraDeviceId();
// If not present now, return
Expand Down

0 comments on commit 1495258

Please sign in to comment.