Fixing crash in Mac client when no cameras are available.
Bug: webrtc:8348
Change-Id: Ibf84ca76812d8c002fae9bd7bcf616abc53c78b1
Reviewed-on: https://webrtc-review.googlesource.com/7340
Reviewed-by: Kári Helgason <kthelgason@webrtc.org>
Reviewed-by: Daniela Jovanoska Petrenko <denicija@webrtc.org>
Commit-Queue: Peter Hanspers <peterhanspers@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#20392}
diff --git a/examples/objc/AppRTCMobile/ARDSettingsModel.m b/examples/objc/AppRTCMobile/ARDSettingsModel.m
index cdaead7..ac265c8 100644
--- a/examples/objc/AppRTCMobile/ARDSettingsModel.m
+++ b/examples/objc/AppRTCMobile/ARDSettingsModel.m
@@ -151,11 +151,11 @@
#pragma mark -
- (NSString *)defaultVideoResolutionSetting {
- return [self availableVideoResolutions][0];
+ return [self availableVideoResolutions].firstObject;
}
- (RTCVideoCodecInfo *)defaultVideoCodecSetting {
- return [self availableVideoCodecs][0];
+ return [self availableVideoCodecs].firstObject;
}
- (int)videoResolutionComponentAtIndex:(int)index inString:(NSString *)resolution {
@@ -170,11 +170,21 @@
}
- (void)registerStoreDefaults {
+ NSString *defaultVideoResolutionSetting = [self defaultVideoResolutionSetting];
+ BOOL audioOnly = (defaultVideoResolutionSetting.length == 0);
+
+// The iOS simulator doesn't provide any sort of camera capture
+// support or emulation (http://goo.gl/rHAnC1) so don't bother
+// trying to open a local stream.
+#if TARGET_IPHONE_SIMULATOR
+ audioOnly = YES;
+#endif
+
NSData *codecData = [NSKeyedArchiver archivedDataWithRootObject:[self defaultVideoCodecSetting]];
[ARDSettingsStore setDefaultsForVideoResolution:[self defaultVideoResolutionSetting]
videoCodec:codecData
bitrate:nil
- audioOnly:NO
+ audioOnly:audioOnly
createAecDump:NO
useLevelController:NO
useManualAudioConfig:YES];