Skip to content

Commit 552db9b

Browse files
committed
feat: disable custom camera session when running on simulator
1 parent 68d2a81 commit 552db9b

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

SimpleWebRTC/CameraSession/CameraSession.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ class CameraSession: NSObject, AVCaptureVideoDataOutputSampleBufferDelegate {
2525

2626
func setupSession(){
2727
self.session = AVCaptureSession()
28+
session?.sessionPreset = AVCaptureSession.Preset.medium
2829
self.device = AVCaptureDevice.default(.builtInWideAngleCamera, for: .video, position: .front)
2930
guard let input = try? AVCaptureDeviceInput(device: device!) else {
3031
print("Caught exception!")

SimpleWebRTC/ViewController/ViewController.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class ViewController: UIViewController, WebSocketDelegate, WebRTCClientDelegate,
3434
var cameraSession: CameraSession?
3535

3636
// You can create video source from CMSampleBuffer :)
37-
var useCustomCapturer: Bool = false
37+
var useCustomCapturer: Bool = true
3838

3939
// Constants
4040
let ipAddress: String = "192.168.1.139"
@@ -52,6 +52,10 @@ class ViewController: UIViewController, WebSocketDelegate, WebRTCClientDelegate,
5252
//MARK: - ViewController Override Methods
5353
override func viewDidLoad() {
5454
super.viewDidLoad()
55+
#if targetEnvironment(simulator)
56+
// simulator does not have camera
57+
self.useCustomCapturer = false
58+
#endif
5559

5660
webRTCClient = WebRTCClient()
5761
webRTCClient.delegate = self

0 commit comments

Comments
 (0)