Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions native/capture/linux/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1098,6 +1098,13 @@ static int run_pipeline(CaptureRun *run, const char *starting_status) {
return 0;
}

static char *pipewire_target(const PiikPortalCapture *portal) {
// target-object accepts a name or object serial; path accepts a node ID.
return portal->target_object != NULL
? g_strdup_printf("target-object=%s", portal->target_object)
: g_strdup_printf("path=%u", portal->node_id);
}

static int capture_video(int count, char **values) {
CaptureRun run = {.last_input_timestamp = GST_CLOCK_TIME_NONE};
gboolean encoded = count > 1 && strcmp(values[1], "--encoded-video") == 0;
Expand Down Expand Up @@ -1130,10 +1137,14 @@ static int capture_video(int count, char **values) {
"max-buffers=1 max-bytes=1048576 max-time=0 "
"caps=video/x-h264,stream-format=byte-stream,alignment=au ! "
"h264parse ! decodebin ! video/x-raw ! tee name=frames ");
} else g_string_append_printf(pipeline_text,
"pipewiresrc name=source fd=%d target-object=%s do-timestamp=true ! "
"videorate drop-only=true ! video/x-raw,framerate=%u/1 ! tee name=frames ",
portal.pipewire_fd, portal.target_object, run.profile.frame_rate);
} else {
char *target = pipewire_target(&portal);
g_string_append_printf(pipeline_text,
"pipewiresrc name=source fd=%d %s do-timestamp=true ! "
"videorate drop-only=true ! video/x-raw,framerate=%u/1 ! tee name=frames ",
portal.pipewire_fd, target, run.profile.frame_rate);
g_free(target);
}
for (guint index = 0; index < run.output_count; ++index) {
const VideoProfile *profile = &run.outputs[index].profile;
g_string_append_printf(pipeline_text,
Expand Down
13 changes: 13 additions & 0 deletions native/capture/linux/main.test.c
Original file line number Diff line number Diff line change
Expand Up @@ -430,8 +430,21 @@ static void check_output_failure_isolation(gboolean post_error) {
g_mutex_clear(&run->lock);
}

static void check_pipewire_target_identity(void) {
PiikPortalCapture portal = {.node_id = 42};
char *target = pipewire_target(&portal);
g_assert_cmpstr(target, ==, "path=42");
g_free(target);

portal.target_object = "9001";
target = pipewire_target(&portal);
g_assert_cmpstr(target, ==, "target-object=9001");
g_free(target);
}

int main(int argc, char **argv) {
gst_init(&argc, &argv);
check_pipewire_target_identity();
check_encoder_admission_and_control();
check_bus_error_retains_primary_cause();
check_slot_profiles();
Expand Down
3 changes: 0 additions & 3 deletions native/capture/linux/portal.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,6 @@ gboolean piik_portal_capture_open(const char *restore_token,
piik_portal_capture_close(capture);
return FALSE;
}
if (capture->target_object == NULL) {
capture->target_object = g_strdup_printf("%u", capture->node_id);
}
capture->restore_token = xdp_session_get_restore_token(capture->session);
return TRUE;
}
Expand Down