record-daemon: build the Linux capture path again
record-daemon / Build, check and test (push) Failing after 1m12s
record-daemon / Build, check and test (push) Failing after 1m12s
CI has been red since libobs-simple started handing back an either-or source for screen capture: on Linux the builder picks X11 or PipeWire, so build() gives ObsEitherSource rather than a source ref, and the closure's error was left as a RecordingError instead of the daemon's. The kept source is now a per-platform alias, one type on Windows and the either-or on Linux; the scene calls only ask for a source, so both go through. The encoder list is built per platform too: the Linux one never grew past x264 and the `mut` was flagged.
This commit is contained in:
1 parent
297118cfc1
commit
94cbdcf0b1
2 files changed
+25
-8
No files matched your search
@@ -17,11 +17,18 @@ pub enum EncoderCapability {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// All encoders available on this machine.
|
/// All encoders available on this machine.
|
||||||
|
///
|
||||||
|
/// Only the Windows branch has anything to add; elsewhere the list is x264 and nobody has to
|
||||||
|
/// grow it.
|
||||||
pub fn detect_hardware_encoders() -> Vec<EncoderCapability> {
|
pub fn detect_hardware_encoders() -> Vec<EncoderCapability> {
|
||||||
let mut capabilities = vec![EncoderCapability::Software];
|
#[cfg(not(target_os = "windows"))]
|
||||||
|
{
|
||||||
|
vec![EncoderCapability::Software]
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(target_os = "windows")]
|
#[cfg(target_os = "windows")]
|
||||||
{
|
{
|
||||||
|
let mut capabilities = vec![EncoderCapability::Software];
|
||||||
let vendors = detect_gpu_vendors();
|
let vendors = detect_gpu_vendors();
|
||||||
if vendors.contains(&GpuVendor::Nvidia) {
|
if vendors.contains(&GpuVendor::Nvidia) {
|
||||||
capabilities.push(EncoderCapability::Nvenc);
|
capabilities.push(EncoderCapability::Nvenc);
|
||||||
@@ -32,9 +39,8 @@ pub fn detect_hardware_encoders() -> Vec<EncoderCapability> {
|
|||||||
if vendors.contains(&GpuVendor::Intel) {
|
if vendors.contains(&GpuVendor::Intel) {
|
||||||
capabilities.push(EncoderCapability::QuickSync);
|
capabilities.push(EncoderCapability::QuickSync);
|
||||||
}
|
}
|
||||||
|
capabilities
|
||||||
}
|
}
|
||||||
|
|
||||||
capabilities
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The single best encoder for recording, hardware over software.
|
/// The single best encoder for recording, hardware over software.
|
||||||
|
|||||||
@@ -151,7 +151,7 @@ pub struct ObsContext {
|
|||||||
/// Process captures. They are scene items as well, but the watcher owns them.
|
/// Process captures. They are scene items as well, but the watcher owns them.
|
||||||
process_audio: Option<ProcessAudio>,
|
process_audio: Option<ProcessAudio>,
|
||||||
/// Video source of the recording that is running, added to the scene on start.
|
/// Video source of the recording that is running, added to the scene on start.
|
||||||
video: Option<ObsSourceRef>,
|
video: Option<VideoSource>,
|
||||||
output: Option<libobs_simple::wrapper::data::output::ObsOutputRef>,
|
output: Option<libobs_simple::wrapper::data::output::ObsOutputRef>,
|
||||||
recording: bool,
|
recording: bool,
|
||||||
/// Settings that arrived while a recording was running, applied once it stops.
|
/// Settings that arrived while a recording was running, applied once it stops.
|
||||||
@@ -538,12 +538,21 @@ fn add_device_sources(
|
|||||||
Ok(added)
|
Ok(added)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// The capture source a recording runs with, kept so stopping can take it back out.
|
||||||
|
///
|
||||||
|
/// Windows builds one game or monitor capture. Linux picks X11 or PipeWire from the display
|
||||||
|
/// server, which the builder settles at build time, so the source is one of two types there.
|
||||||
|
#[cfg(target_os = "windows")]
|
||||||
|
type VideoSource = ObsSourceRef;
|
||||||
|
#[cfg(target_os = "linux")]
|
||||||
|
type VideoSource = libobs_simple::sources::linux::LinuxGeneralScreenCaptureSourceRef;
|
||||||
|
|
||||||
/// Put a video capture source in the scene for the recording that is starting.
|
/// Put a video capture source in the scene for the recording that is starting.
|
||||||
#[cfg(target_os = "windows")]
|
#[cfg(target_os = "windows")]
|
||||||
fn add_video_source(
|
fn add_video_source(
|
||||||
context: &LibObsContext,
|
context: &LibObsContext,
|
||||||
scene: Option<&mut libobs_wrapper::scenes::ObsSceneRef>,
|
scene: Option<&mut libobs_wrapper::scenes::ObsSceneRef>,
|
||||||
slot: &mut Option<ObsSourceRef>,
|
slot: &mut Option<VideoSource>,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
use libobs_simple::sources::windows::{GameCaptureSourceBuilder, ObsGameCaptureMode};
|
use libobs_simple::sources::windows::{GameCaptureSourceBuilder, ObsGameCaptureMode};
|
||||||
|
|
||||||
@@ -594,7 +603,7 @@ fn add_video_source(
|
|||||||
fn add_video_source(
|
fn add_video_source(
|
||||||
context: &LibObsContext,
|
context: &LibObsContext,
|
||||||
scene: Option<&mut libobs_wrapper::scenes::ObsSceneRef>,
|
scene: Option<&mut libobs_wrapper::scenes::ObsSceneRef>,
|
||||||
slot: &mut Option<ObsSourceRef>,
|
slot: &mut Option<VideoSource>,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
use libobs_simple::sources::linux::LinuxGeneralScreenCaptureBuilder;
|
use libobs_simple::sources::linux::LinuxGeneralScreenCaptureBuilder;
|
||||||
|
|
||||||
@@ -604,7 +613,9 @@ fn add_video_source(
|
|||||||
LinuxGeneralScreenCaptureBuilder::new("screen_capture", context.runtime().clone())
|
LinuxGeneralScreenCaptureBuilder::new("screen_capture", context.runtime().clone())
|
||||||
.map_err(|e| RecordingError::StartError(format!("screen capture builder: {:?}", e)))?
|
.map_err(|e| RecordingError::StartError(format!("screen capture builder: {:?}", e)))?
|
||||||
.build()
|
.build()
|
||||||
.map_err(|e| RecordingError::StartError(format!("screen capture source: {:?}", e)))
|
.map_err(|e| {
|
||||||
|
RecordingError::StartError(format!("screen capture source: {:?}", e)).into()
|
||||||
|
})
|
||||||
})?;
|
})?;
|
||||||
scene
|
scene
|
||||||
.add_source(source.clone())
|
.add_source(source.clone())
|
||||||
@@ -616,7 +627,7 @@ fn add_video_source(
|
|||||||
/// Take the video source back out of the scene and drop it.
|
/// Take the video source back out of the scene and drop it.
|
||||||
fn remove_video_source(
|
fn remove_video_source(
|
||||||
scene: Option<&mut libobs_wrapper::scenes::ObsSceneRef>,
|
scene: Option<&mut libobs_wrapper::scenes::ObsSceneRef>,
|
||||||
source: Option<ObsSourceRef>,
|
source: Option<VideoSource>,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
let (Some(scene), Some(source)) = (scene, source) else {
|
let (Some(scene), Some(source)) = (scene, source) else {
|
||||||
return Ok(());
|
return Ok(());
|
||||||
|
|||||||
Reference in new issue
Block a user