Skip to content

Commit

Permalink
Optionally force scene switch transitions for all video sources.
Browse files Browse the repository at this point in the history
  • Loading branch information
eerimoq committed Feb 5, 2025
1 parent ae7e0cb commit cbf714c
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 13 deletions.
6 changes: 6 additions & 0 deletions Common/Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -58276,6 +58276,9 @@
}
}
}
},
"Force scene switch transition" : {

},
"Foreground" : {
"localizations" : {
Expand Down Expand Up @@ -100417,6 +100420,9 @@
}
}
}
},
"RTMP, SRT(LA), screen capture and media player video sources can instantly be switched to, but if you want consistency you can force scene switch transitions to these as well." : {

},
"rtmp://a.rtmp.youtube.com/live2" : {
"localizations" : {
Expand Down
6 changes: 3 additions & 3 deletions Moblin/Various/Media.swift
Original file line number Diff line number Diff line change
Expand Up @@ -812,16 +812,16 @@ final class Media: NSObject {
func attachReplaceCamera(
device: AVCaptureDevice?,
cameraPreviewLayer: AVCaptureVideoPreviewLayer?,
showCameraPreview _: Bool,
cameraId: UUID
cameraId: UUID,
ignoreFramesAfterAttachSeconds: Double
) {
netStream?.attachCamera(
device,
cameraPreviewLayer,
false,
.off,
false,
0.0,
ignoreFramesAfterAttachSeconds,
replaceVideoCameraId: cameraId
)
}
Expand Down
12 changes: 10 additions & 2 deletions Moblin/Various/Model.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6433,6 +6433,14 @@ final class Model: NSObject, ObservableObject, @unchecked Sendable {
return Double(database.debug.cameraSwitchRemoveBlackish!)
}

private func getIgnoreFramesAfterAttachSecondsReplaceCamera() -> Double {
if database.forceSceneSwitchTransition! {
return Double(database.debug.cameraSwitchRemoveBlackish!)
} else {
return 0.0
}
}

private func attachReplaceCamera(cameraId: UUID) {
cameraDevice = nil
cameraPosition = nil
Expand All @@ -6441,8 +6449,8 @@ final class Model: NSObject, ObservableObject, @unchecked Sendable {
media.attachReplaceCamera(
device: getVideoSourceBuiltinCameraDevice(),
cameraPreviewLayer: cameraPreviewLayer,
showCameraPreview: updateShowCameraPreview(),
cameraId: cameraId
cameraId: cameraId,
ignoreFramesAfterAttachSeconds: getIgnoreFramesAfterAttachSecondsReplaceCamera()
)
media.usePendingAfterAttachEffects()
}
Expand Down
5 changes: 5 additions & 0 deletions Moblin/Various/Settings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2677,6 +2677,7 @@ class Database: Codable {
var pixellateStrength: Float? = 0.3
var moblink: SettingsMoblinkRelay? = .init()
var sceneSwitchTransition: SettingsSceneSwitchTransition? = .blur
var forceSceneSwitchTransition: Bool? = false

static func fromString(settings: String) throws -> Database {
let database = try JSONDecoder().decode(
Expand Down Expand Up @@ -4609,5 +4610,9 @@ final class Settings {
realDatabase.sceneSwitchTransition = realDatabase.debug.blurSceneSwitch! ? .blur : .freeze
store()
}
if realDatabase.forceSceneSwitchTransition == nil {
realDatabase.forceSceneSwitchTransition = false
store()
}
}
}
28 changes: 20 additions & 8 deletions Moblin/View/Settings/Scenes/ScenesSettingsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,27 @@ private struct ScenesSwitchTransition: View {
@State var sceneSwitchTransition: String

var body: some View {
Picker("Scene switch transition", selection: $sceneSwitchTransition) {
ForEach(sceneSwitchTransitions, id: \.self) { transition in
Text(transition)
Section {
Picker("Scene switch transition", selection: $sceneSwitchTransition) {
ForEach(sceneSwitchTransitions, id: \.self) { transition in
Text(transition)
}
}
}
.onChange(of: sceneSwitchTransition) { _ in
model.database.sceneSwitchTransition = SettingsSceneSwitchTransition
.fromString(value: sceneSwitchTransition)
model.setSceneSwitchTransition()
.onChange(of: sceneSwitchTransition) { _ in
model.database.sceneSwitchTransition = SettingsSceneSwitchTransition
.fromString(value: sceneSwitchTransition)
model.setSceneSwitchTransition()
}
Toggle("Force scene switch transition", isOn: Binding(get: {
model.database.forceSceneSwitchTransition!
}, set: { value in
model.database.forceSceneSwitchTransition = value
}))
} footer: {
Text("""
RTMP, SRT(LA), screen capture and media player video sources can instantly be switched \
to, but if you want consistency you can force scene switch transitions to these as well.
""")
}
}
}
Expand Down

0 comments on commit cbf714c

Please sign in to comment.