Skip to content

Commit 60ce58c

Browse files
committed
linux-pipewire: camera-portal: Hide frame rate selector if unavailable
If the given format + resolution combination has no consumable frame rates, then hide the dropdown selector. Additionally, unset the previous frame rate of the pipewire stream.
1 parent 4c385fd commit 60ce58c

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

plugins/linux-pipewire/camera-portal.c

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -640,8 +640,8 @@ static int compare_framerates(gconstpointer a, gconstpointer b)
640640
return da - db;
641641
}
642642

643-
static void framerate_list(struct camera_device *dev, uint32_t pixelformat, const struct spa_rectangle *resolution,
644-
obs_property_t *prop)
643+
static size_t framerate_list(struct camera_device *dev, uint32_t pixelformat, const struct spa_rectangle *resolution,
644+
obs_property_t *prop)
645645
{
646646
g_autoptr(GArray) framerates = NULL;
647647
struct param *p;
@@ -737,6 +737,8 @@ static void framerate_list(struct camera_device *dev, uint32_t pixelformat, cons
737737
dstr_free(&str);
738738
}
739739
obs_data_release(data);
740+
741+
return framerates->len;
740742
}
741743

742744
static bool parse_framerate(struct spa_fraction *dest, const char *json)
@@ -843,7 +845,14 @@ static bool format_selected(void *data, obs_properties_t *properties, obs_proper
843845
}
844846

845847
property = obs_properties_get(properties, "framerate");
846-
framerate_list(device, camera_source->format.spa_format, &camera_source->resolution.rect, property);
848+
849+
bool has_framerates =
850+
framerate_list(device, camera_source->format.spa_format, &camera_source->resolution.rect, property);
851+
852+
obs_property_set_visible(property, has_framerates);
853+
854+
if (!has_framerates)
855+
obs_pipewire_stream_set_framerate(camera_source->obs_pw_stream, NULL);
847856

848857
return true;
849858
}

0 commit comments

Comments
 (0)