@@ -21,6 +21,8 @@ struct PictureInPictureVideoParticipantView: View {
21
21
var participant : CallParticipant
22
22
var track : RTCVideoTrack ?
23
23
24
+ @State private var isUsingFrontCameraForLocalUser : Bool = false
25
+
24
26
/// Creates a new participant view.
25
27
///
26
28
/// - Parameters:
@@ -41,11 +43,13 @@ struct PictureInPictureVideoParticipantView: View {
41
43
}
42
44
43
45
var body : some View {
44
- PictureInPictureVideoRendererView (
45
- store: store,
46
- participant: participant,
47
- track: track
48
- )
46
+ withCallSettingsObservation {
47
+ PictureInPictureVideoRendererView (
48
+ store: store,
49
+ participant: participant,
50
+ track: track
51
+ )
52
+ }
49
53
. opacity ( showVideo ? 1 : 0 )
50
54
. streamAccessibility ( value: showVideo ? " 1 " : " 0 " )
51
55
. overlay ( overlayView)
@@ -62,4 +66,26 @@ struct PictureInPictureVideoParticipantView: View {
62
66
. makeParticipantImageView ( participant: participant)
63
67
. opacity ( showVideo ? 0 : 1 )
64
68
}
69
+
70
+ @MainActor
71
+ @ViewBuilder
72
+ private func withCallSettingsObservation(
73
+ @ViewBuilder _ content: ( ) -> some View
74
+ ) -> some View {
75
+ if participant. sessionId == streamVideo. state. activeCall? . state. localParticipant? . sessionId {
76
+ Group {
77
+ if isUsingFrontCameraForLocalUser {
78
+ content ( )
79
+ . rotation3DEffect ( . degrees( 180 ) , axis: ( x: 0 , y: 1 , z: 0 ) )
80
+ } else {
81
+ content ( )
82
+ }
83
+ }
84
+ . onReceive ( store. state. call? . state. $callSettings) {
85
+ self . isUsingFrontCameraForLocalUser = $0. cameraPosition == . front
86
+ }
87
+ } else {
88
+ content ( )
89
+ }
90
+ }
65
91
}
0 commit comments