@@ -15,23 +15,23 @@ extension RemoteCamSession {
1515
1616 // MARK: - Camera Capabilities Retry Helper
1717 private func attemptToSendCapabilities( ctrl: CameraViewController , peer: MCPeerID , attempt: Int , maxAttempts: Int ) {
18- print ( " 🔍 DEBUG: Attempt \( attempt) / \( maxAttempts) to gather camera capabilities " )
18+ debugLog ( " 🔍 DEBUG: Attempt \( attempt) / \( maxAttempts) to gather camera capabilities " )
1919
2020 ctrl. gatherAllCameraCapabilities ( )
2121 if let capabilities = ctrl. gatherCurrentCameraCapabilities ( ) {
22- print ( " ✅ DEBUG: Successfully gathered capabilities on attempt \( attempt) " )
23- print ( " 🔍 DEBUG: Sending camera capabilities - Available lenses: \( capabilities. getCurrentCameraInfo ( ) ? . availableLenses ?? [ ] ) " )
22+ debugLog ( " ✅ DEBUG: Successfully gathered capabilities on attempt \( attempt) " )
23+ debugLog ( " 🔍 DEBUG: Sending camera capabilities - Available lenses: \( capabilities. getCurrentCameraInfo ( ) ? . availableLenses ?? [ ] ) " )
2424 self . mailbox. addOperation ( BlockOperation {
2525 self . sendCommandOrGoToScanning ( peer: [ peer] , msg: capabilities)
2626 } )
2727 } else if attempt < maxAttempts {
2828 let delay = Double ( attempt) * 0.2 // 0.2s, 0.4s, 0.6s, 0.8s delays
29- print ( " ⏳ DEBUG: Attempt \( attempt) failed, retrying in \( delay) s " )
29+ debugLog ( " ⏳ DEBUG: Attempt \( attempt) failed, retrying in \( delay) s " )
3030 DispatchQueue . main. asyncAfter ( deadline: . now( ) + delay) { [ weak self] in
3131 self ? . attemptToSendCapabilities ( ctrl: ctrl, peer: peer, attempt: attempt + 1 , maxAttempts: maxAttempts)
3232 }
3333 } else {
34- print ( " ❌ DEBUG: Failed to gather camera capabilities after \( maxAttempts) attempts " )
34+ debugLog ( " ❌ DEBUG: Failed to gather camera capabilities after \( maxAttempts) attempts " )
3535 }
3636 }
3737
@@ -135,17 +135,17 @@ extension RemoteCamSession {
135135
136136 switch msg {
137137 case is OnEnter :
138- print ( " 🔍 DEBUG: Camera starting up " )
138+ debugLog ( " 🔍 DEBUG: Camera starting up " )
139139 getFrameSender ( ) ? . tell ( msg: SetSession ( peer: peer, session: self ) )
140140
141141 case is RemoteCmd . PeerBecameMonitor :
142142 // When a new monitor joins, immediately send camera capabilities
143- print ( " 🔍 DEBUG: Camera received PeerBecameMonitor - attempting to send capabilities " )
143+ debugLog ( " 🔍 DEBUG: Camera received PeerBecameMonitor - attempting to send capabilities " )
144144 self . attemptToSendCapabilities ( ctrl: ctrl, peer: peer, attempt: 1 , maxAttempts: 5 )
145145
146146 case is RemoteCmd . RequestCameraCapabilities :
147147 // When monitor explicitly requests capabilities
148- print ( " 🔍 DEBUG: Camera received RequestCameraCapabilities - attempting to gather capabilities " )
148+ debugLog ( " 🔍 DEBUG: Camera received RequestCameraCapabilities - attempting to gather capabilities " )
149149 self . attemptToSendCapabilities ( ctrl: ctrl, peer: peer, attempt: 1 , maxAttempts: 5 )
150150
151151 case is RemoteCmd . RequestFrame :
@@ -185,16 +185,16 @@ extension RemoteCamSession {
185185 state: self . cameraTakingPic ( peer: peer, ctrl: ctrl, lobby: lobbyWrapper, sendMediaToPeer: cmd. sendMediaToPeer) )
186186
187187 case is RemoteCmd . ToggleCamera :
188- print ( " 🔍 DEBUG: Camera received ToggleCamera command " )
188+ debugLog ( " 🔍 DEBUG: Camera received ToggleCamera command " )
189189 let result = ctrl. toggleCamera ( )
190190 var resp : Message ?
191191 if let ( _, position) = result. toOptional ( ) {
192- print ( " ✅ DEBUG: Camera toggle success - new position: \( position) " )
192+ debugLog ( " ✅ DEBUG: Camera toggle success - new position: \( position) " )
193193 // Send camera capabilities as part of the response
194194 let capabilities = ctrl. gatherCurrentCameraCapabilities ( )
195195 resp = RemoteCmd . ToggleCameraResp ( cameraCapabilities: capabilities, error: nil )
196196 } else if let failure = result as? Failure {
197- print ( " ❌ DEBUG: Camera toggle failed: \( failure. tryError. localizedDescription) " )
197+ debugLog ( " ❌ DEBUG: Camera toggle failed: \( failure. tryError. localizedDescription) " )
198198 resp = RemoteCmd . ToggleCameraResp ( cameraCapabilities: nil , error: failure. tryError)
199199 }
200200 self . sendCommandOrGoToScanning ( peer: [ peer] , msg: resp!)
@@ -232,31 +232,31 @@ extension RemoteCamSession {
232232
233233 // MARK: - Zoom Command Handling
234234 case let zoomCmd as RemoteCmd . SetZoom :
235- print ( " 🔍 DEBUG: Camera received SetZoom: \( zoomCmd. zoomFactor) " )
235+ debugLog ( " 🔍 DEBUG: Camera received SetZoom: \( zoomCmd. zoomFactor) " )
236236 let result = ctrl. setZoom ( zoomFactor: zoomCmd. zoomFactor)
237237 var resp : Message ?
238238 if let ( zoomFactor, currentLens, zoomRange) = result. toOptional ( ) {
239239 resp = RemoteCmd . SetZoomResp ( zoomFactor: zoomFactor, currentLens: currentLens, zoomRange: zoomRange, error: nil )
240240 } else if let failure = result as? Failure {
241- print ( " ❌ DEBUG: Camera zoom failed: \( failure. tryError. localizedDescription) " )
241+ debugLog ( " ❌ DEBUG: Camera zoom failed: \( failure. tryError. localizedDescription) " )
242242 resp = RemoteCmd . SetZoomResp ( zoomFactor: nil , currentLens: nil , zoomRange: nil , error: failure. tryError)
243243 }
244244 self . sendCommandOrGoToScanning ( peer: [ peer] , msg: resp!)
245245
246246 // MARK: - Lens Switching Command Handling
247247 case let lensCmd as RemoteCmd . SwitchLens :
248- print ( " 🔍 DEBUG: Camera received SwitchLens command to \( lensCmd. lensType. displayName) " )
248+ debugLog ( " 🔍 DEBUG: Camera received SwitchLens command to \( lensCmd. lensType. displayName) " )
249249 let result = ctrl. switchLens ( to: lensCmd. lensType)
250250 var resp : Message ?
251251 if let ( lensType, availableLenses, currentZoom, zoomRange) = result. toOptional ( ) {
252- print ( " ✅ DEBUG: Camera lens switch success - new lens: \( lensType. displayName) " )
252+ debugLog ( " ✅ DEBUG: Camera lens switch success - new lens: \( lensType. displayName) " )
253253 resp = RemoteCmd . SwitchLensResp ( lensType: lensType, availableLenses: availableLenses, currentZoom: currentZoom, zoomRange: zoomRange, error: nil )
254254
255255 } else if let failure = result as? Failure {
256- print ( " ❌ DEBUG: Camera lens switch failed: \( failure. tryError. localizedDescription) " )
256+ debugLog ( " ❌ DEBUG: Camera lens switch failed: \( failure. tryError. localizedDescription) " )
257257 resp = RemoteCmd . SwitchLensResp ( lensType: nil , availableLenses: nil , currentZoom: nil , zoomRange: nil , error: failure. error)
258- print ( " 🔍 DEBUG: Created error response: " )
259- // print ("🔍 DEBUG: - error: \(failure.error.localizedDescription)")
258+ debugLog ( " 🔍 DEBUG: Created error response: " )
259+ // debugLog ("🔍 DEBUG: - error: \(failure.error.localizedDescription)")
260260 }
261261
262262
@@ -302,18 +302,24 @@ extension RemoteCamSession {
302302 self . sendCommandOrGoToScanning ( peer: [ peer] , msg: RemoteCmd . SetPhotoQualityResp ( format: nil , hdrMode: nil , error: error) )
303303 }
304304
305+ // MARK: - Aspect Ratio Command Handling
306+ case let cmd as RemoteCmd . SetAspectRatio :
307+ let result = ctrl. setAspectRatio ( cmd. aspectRatio)
308+ self . sendCommandOrGoToScanning ( peer: [ peer] ,
309+ msg: RemoteCmd . SetAspectRatioResp ( aspectRatio: result, error: nil ) )
310+
305311 case let c as DisconnectPeer :
306312 if c. peer? . displayName == peer. displayName && self . connectedPeers. count == 0 {
307- print ( " 🔍 DEBUG: Camera disconnecting peer - going to scanning " )
313+ debugLog ( " 🔍 DEBUG: Camera disconnecting peer - going to scanning " )
308314 self . popAndStartScanning ( )
309315 }
310316
311317 case is Disconnect :
312- print ( " 🔍 DEBUG: Camera disconnecting - going to scanning " )
318+ debugLog ( " 🔍 DEBUG: Camera disconnecting - going to scanning " )
313319 self . popAndStartScanning ( )
314320
315321 case is UICmd . UnbecomeCamera :
316- print ( " 🔍 DEBUG: Camera explicitly unbecoming - going to connected state " )
322+ debugLog ( " 🔍 DEBUG: Camera explicitly unbecoming - going to connected state " )
317323 self . popToState ( name: . connected)
318324
319325 default :
0 commit comments