Skip to content

Instantly share code, notes, and snippets.

@marler8997
Created March 3, 2023 16:09
Show Gist options
  • Save marler8997/f7c826a93c2b4614902368a351ae6d3a to your computer and use it in GitHub Desktop.
Save marler8997/f7c826a93c2b4614902368a351ae6d3a to your computer and use it in GitHub Desktop.
unsigned char param_buffer[1024];
spa_pod_builder builder = SPA_POD_BUILDER_INIT(param_buffer, sizeof(param_buffer));
const spa_pod *params[1];
params[0] = (spa_pod*)spa_pod_builder_add_object(&builder,
SPA_TYPE_OBJECT_Format, SPA_PARAM_EnumFormat,
SPA_FORMAT_mediaType, SPA_POD_Id(SPA_MEDIA_TYPE_video),
SPA_FORMAT_mediaSubtype, SPA_POD_Id(SPA_MEDIA_SUBTYPE_raw),
// TODO: test what happens if we don't support any formats
SPA_FORMAT_VIDEO_format, SPA_POD_CHOICE_ENUM_Id(3,
SPA_VIDEO_FORMAT_YUY2, // default
// TODO: find a device that has i420 and/or nv12 and test that
// this may not exist though, it's possible all desktop capturers use some form of RGB
//SPA_VIDEO_FORMAT_I420, // alternative
SPA_VIDEO_FORMAT_YUY2, // alternative
//SPA_VIDEO_FORMAT_RGB, // alternative
//SPA_VIDEO_FORMAT_RGBA,
//SPA_VIDEO_FORMAT_RGBx,
SPA_VIDEO_FORMAT_BGRx), // alternative
SPA_FORMAT_VIDEO_size, SPA_POD_CHOICE_RANGE_Rectangle(
&SPA_RECTANGLE((unsigned)size_.width(), (unsigned)size_.height()), // default
&SPA_RECTANGLE(1, 1), // min
&SPA_RECTANGLE(999999, 999999) // max
),
SPA_FORMAT_VIDEO_framerate, SPA_POD_CHOICE_RANGE_Fraction(
&SPA_FRACTION(25, 1),
&SPA_FRACTION(0, 1),
&SPA_FRACTION(1000, 1)));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment