diff --git a/Shared/Controllers/AppContext.swift b/Shared/Controllers/AppContext.swift index 2a0af62..3475554 100644 --- a/Shared/Controllers/AppContext.swift +++ b/Shared/Controllers/AppContext.swift @@ -23,6 +23,10 @@ final class AppContext: ObservableObject { didSet { store.set(.videoViewMode, value: videoViewMode) } } + @Published var videoViewMirrored: Bool { + didSet { store.set(.videoViewMirrored, value: videoViewMirrored) } + } + @Published var connectionHistory: Set { didSet { store.set(.connectionHistory, value: connectionHistory) } } @@ -33,6 +37,7 @@ final class AppContext: ObservableObject { self.showInformationOverlay = store.get(.showInformationOverlay) ?? false self.preferMetal = store.get(.preferMetal) ?? true self.videoViewMode = store.get(.videoViewMode) ?? .fit + self.videoViewMirrored = store.get(.videoViewMirrored) ?? false self.connectionHistory = store.get(.connectionHistory) ?? [] } } diff --git a/Shared/ParticipantView.swift b/Shared/ParticipantView.swift index e9cfa35..3190240 100644 --- a/Shared/ParticipantView.swift +++ b/Shared/ParticipantView.swift @@ -38,29 +38,36 @@ struct ParticipantView: View { let track = publication.track as? VideoTrack, appCtx.videoViewVisible { ZStack(alignment: .topLeading) { + let mirrored = track is LocalVideoTrack ? !appCtx.videoViewMirrored : appCtx.videoViewMirrored SwiftUIVideoView(track, mode: videoViewMode, - mirrored: true, dimensions: $dimensions, + mirrored: mirrored, + dimensions: $dimensions, preferMetal: appCtx.preferMetal) .background(Color.black) + // .scaleEffect(CGSize(width: -1.0, height: 1.0))// flip local view horizontally // Show the actual video dimensions (if enabled) if appCtx.showInformationOverlay { VStack(alignment: .leading) { - if let dimensions = dimensions { - Text("DIM. \(dimensions.width)x\(dimensions.height)") + Text("Metal: \(String(describing: appCtx.preferMetal))") + .foregroundColor(Color.white) + .padding(3) + .background(Color.black) + .cornerRadius(8) + Text("Mirrored: \(String(describing: mirrored))") + .foregroundColor(Color.white) + .padding(3) + .background(Color.black) + .cornerRadius(8) + if let dimensions = dimensions { + Text("\(dimensions.width)x\(dimensions.height)") .foregroundColor(Color.white) .padding(3) .background(Color.lkBlue) .cornerRadius(8) } - Text("Metal: \(String(describing: appCtx.preferMetal))") - .foregroundColor(Color.white) - .padding(3) - .background(Color.green) - .cornerRadius(8) - } .padding() } @@ -77,13 +84,17 @@ struct ParticipantView: View { VStack(alignment: .trailing, spacing: 0) { // Show the sub-video view if let subVideoTrack = participant.subVideoTrack { - SwiftUIVideoView(subVideoTrack, mode: .fill, - preferMetal: appCtx.preferMetal) - .background(Color.black) - .aspectRatio(contentMode: .fit) - .frame(width: min(geometry.size.width, geometry.size.height) * 0.3) - .cornerRadius(8) - .padding() + let mirrored = subVideoTrack is LocalVideoTrack ? !appCtx.videoViewMirrored : appCtx.videoViewMirrored + SwiftUIVideoView(subVideoTrack, + mode: .fill, + mirrored: mirrored, + preferMetal: appCtx.preferMetal + ) + .background(Color.black) + .aspectRatio(contentMode: .fit) + .frame(width: min(geometry.size.width, geometry.size.height) * 0.3) + .cornerRadius(8) + .padding() } // Bottom user info bar diff --git a/Shared/RoomView.swift b/Shared/RoomView.swift index 5f6a9ca..7b6d80e 100644 --- a/Shared/RoomView.swift +++ b/Shared/RoomView.swift @@ -270,8 +270,14 @@ struct RoomView: View { Menu { Toggle("Show info overlay", isOn: $appCtx.showInformationOverlay) - Toggle("Video view visible", isOn: $appCtx.videoViewVisible) - Toggle("Prefer Metal", isOn: $appCtx.preferMetal) + + Divider() + + Toggle("VideoView visible", isOn: $appCtx.videoViewVisible) + Toggle("VideoView preferMetal", isOn: $appCtx.preferMetal) + Toggle("VideoView mirrored", isOn: $appCtx.videoViewMirrored) + + Divider() Menu { Button { diff --git a/Shared/Support/SecureStore.swift b/Shared/Support/SecureStore.swift index 4f1f14f..fcd8059 100644 --- a/Shared/Support/SecureStore.swift +++ b/Shared/Support/SecureStore.swift @@ -20,6 +20,7 @@ enum SecureStoreKeys: String { case showInformationOverlay = "showInformationOverlay" case preferMetal = "preferMetal" case videoViewMode = "videoViewMode" + case videoViewMirrored = "videoViewMirrored" case connectionHistory = "connectionHistory" }