From 41ac6f70b463b20c182649f96132aa4163879bb7 Mon Sep 17 00:00:00 2001 From: Fabio de Albuquerque Dela Antonio Date: Fri, 30 Apr 2021 01:08:37 +0100 Subject: [PATCH] Adding option to record screen when connecting --- .../Model/MixedRealityConfiguration.swift | 2 + ...MixedRealityConnectionViewController.swift | 14 ++++- .../MixedRealityConnectionViewController.xib | 52 +++++++++++++++---- .../MixedRealityViewController.swift | 19 ++++++- 4 files changed, 74 insertions(+), 13 deletions(-) diff --git a/RealityMixer/Capture/Model/MixedRealityConfiguration.swift b/RealityMixer/Capture/Model/MixedRealityConfiguration.swift index da1b590..b35a86c 100644 --- a/RealityMixer/Capture/Model/MixedRealityConfiguration.swift +++ b/RealityMixer/Capture/Model/MixedRealityConfiguration.swift @@ -27,6 +27,7 @@ struct MixedRealityConfiguration: Codable, Equatable { let visibility: BackgroundVisibility } + let shouldRecord: Bool let enableAudio: Bool let enableAutoFocus: Bool let enablePersonSegmentation: Bool @@ -36,6 +37,7 @@ struct MixedRealityConfiguration: Codable, Equatable { let backgroundLayerOptions: BackgroundLayerOptions static let defaultConfiguration = MixedRealityConfiguration( + shouldRecord: true, enableAudio: true, enableAutoFocus: true, enablePersonSegmentation: true, diff --git a/RealityMixer/Capture/ViewControllers/MixedRealityConnectionViewController.swift b/RealityMixer/Capture/ViewControllers/MixedRealityConnectionViewController.swift index 0f6b263..da08cc5 100644 --- a/RealityMixer/Capture/ViewControllers/MixedRealityConnectionViewController.swift +++ b/RealityMixer/Capture/ViewControllers/MixedRealityConnectionViewController.swift @@ -7,6 +7,7 @@ import UIKit import ARKit +import ReplayKit import SwiftSocket final class MixedRealityConnectionViewController: UIViewController { @@ -31,7 +32,10 @@ final class MixedRealityConnectionViewController: UIViewController { @IBOutlet private weak var backgroundChromaKeySection: UIStackView! @IBOutlet private weak var backgroundChromaKeySegmentedControl: UISegmentedControl! - @IBOutlet private weak var showOptionsButton: UIButton! + // MARK: - Recording options + @IBOutlet private weak var recordingSwitch: UISwitch! + + @IBOutlet /*private*/ weak var showOptionsButton: UIButton! @IBOutlet private weak var resetOptionsButton: UIButton! @IBOutlet private weak var infoLabel: UILabel! @@ -122,6 +126,7 @@ final class MixedRealityConnectionViewController: UIViewController { } private func didUpdate(configuration: MixedRealityConfiguration) { + recordingSwitch.isOn = configuration.shouldRecord audioSwitch.isOn = configuration.enableAudio autoFocusSwitch.isOn = configuration.enableAutoFocus personSegmentationSwitch.isOn = configuration.enablePersonSegmentation @@ -169,6 +174,7 @@ final class MixedRealityConnectionViewController: UIViewController { private func updateConfiguration(enablePersonSegmentation: Bool) { configuration = MixedRealityConfiguration( + shouldRecord: recordingSwitch.isOn, enableAudio: audioSwitch.isOn, enableAutoFocus: autoFocusSwitch.isOn, enablePersonSegmentation: enablePersonSegmentation, @@ -239,6 +245,12 @@ final class MixedRealityConnectionViewController: UIViewController { let cameraPoseSender = CameraPoseSender(address: address) let configuration = self.configuration + let screenRecorder = RPScreenRecorder.shared() + if configuration.shouldRecord, screenRecorder.isAvailable, !screenRecorder.isRecording { + // TODO: Present alert to the user if this fails + screenRecorder.startRecording(handler: nil) + } + connectionAlert.dismiss(animated: false, completion: { [weak self] in let viewController = MixedRealityViewController( diff --git a/RealityMixer/Capture/ViewControllers/MixedRealityConnectionViewController.xib b/RealityMixer/Capture/ViewControllers/MixedRealityConnectionViewController.xib index e7c0ade..f505e82 100644 --- a/RealityMixer/Capture/ViewControllers/MixedRealityConnectionViewController.xib +++ b/RealityMixer/Capture/ViewControllers/MixedRealityConnectionViewController.xib @@ -23,6 +23,7 @@ + @@ -44,10 +45,10 @@ - + - + @@ -103,7 +104,7 @@ - + @@ -324,8 +325,37 @@ + + + + + + + + + + + + + + + + + + + + - +