Skip to content

Commit

Permalink
Offer video modifier
Browse files Browse the repository at this point in the history
  • Loading branch information
columbarius committed Sep 20, 2020
1 parent f062cca commit d4b0358
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 16 deletions.
1 change: 1 addition & 0 deletions include/screencast_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ struct xdpw_screencopy_frame {
void *data;

uint32_t fourcc;
uint64_t modifier;
struct gbm_bo *bo;
uint32_t offset;
int fd;
Expand Down
60 changes: 44 additions & 16 deletions src/screencast/pipewire_screencast.c
Original file line number Diff line number Diff line change
Expand Up @@ -220,22 +220,50 @@ void xdpw_pwr_stream_init(struct xdpw_screencast_instance *cast) {
n_formats++;
}

const struct spa_pod *param = spa_pod_builder_add_object(&b,
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),
SPA_FORMAT_VIDEO_format, SPA_POD_CHOICE_ENUM_Id(n_formats + 1,
format, format, format_without_alpha),
SPA_FORMAT_VIDEO_size, SPA_POD_CHOICE_RANGE_Rectangle(
&SPA_RECTANGLE(cast->xdpw_frames.simple_frame.width, cast->xdpw_frames.simple_frame.height),
&SPA_RECTANGLE(1, 1),
&SPA_RECTANGLE(4096, 4096)),
// variable framerate
SPA_FORMAT_VIDEO_framerate, SPA_POD_Fraction(&SPA_FRACTION(0, 1)),
SPA_FORMAT_VIDEO_maxFramerate, SPA_POD_CHOICE_RANGE_Fraction(
&SPA_FRACTION(cast->framerate, 1),
&SPA_FRACTION(1, 1),
&SPA_FRACTION(cast->framerate, 1)));
logprint(DEBUG, "pipewire: Supported format %d", format);

const struct spa_pod *param;
switch (cast->type) {
case XDPW_INSTANCE_SCP_SHM:
param = spa_pod_builder_add_object(&b,
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),
SPA_FORMAT_VIDEO_format, SPA_POD_CHOICE_ENUM_Id(n_formats + 1,
format, format, format_without_alpha),
SPA_FORMAT_VIDEO_size, SPA_POD_CHOICE_RANGE_Rectangle(
&SPA_RECTANGLE(cast->xdpw_frames.simple_frame.width, cast->xdpw_frames.simple_frame.height),
&SPA_RECTANGLE(1, 1),
&SPA_RECTANGLE(4096, 4096)),
// variable framerate
SPA_FORMAT_VIDEO_framerate, SPA_POD_Fraction(&SPA_FRACTION(0, 1)),
SPA_FORMAT_VIDEO_maxFramerate, SPA_POD_CHOICE_RANGE_Fraction(
&SPA_FRACTION(cast->framerate, 1),
&SPA_FRACTION(1, 1),
&SPA_FRACTION(cast->framerate, 1)));
break;
case XDPW_INSTANCE_SCP_DMABUF:
param = spa_pod_builder_add_object(&b,
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),
SPA_FORMAT_VIDEO_format, SPA_POD_CHOICE_ENUM_Id(n_formats + 1,
format, format, format_without_alpha),
SPA_FORMAT_VIDEO_modifier, SPA_POD_CHOICE_ENUM_Long(1,cast->xdpw_frames.screencopy_frame.modifier),
SPA_FORMAT_VIDEO_size, SPA_POD_CHOICE_RANGE_Rectangle(
&SPA_RECTANGLE(cast->xdpw_frames.simple_frame.width, cast->xdpw_frames.simple_frame.height),
&SPA_RECTANGLE(1, 1),
&SPA_RECTANGLE(4096, 4096)),
// variable framerate
SPA_FORMAT_VIDEO_framerate, SPA_POD_Fraction(&SPA_FRACTION(0, 1)),
SPA_FORMAT_VIDEO_maxFramerate, SPA_POD_CHOICE_RANGE_Fraction(
&SPA_FRACTION(cast->framerate, 1),
&SPA_FRACTION(1, 1),
&SPA_FRACTION(cast->framerate, 1)));
break;
default:
abort();
}

pw_stream_add_listener(cast->stream, &cast->stream_listener,
&pwr_stream_events, cast);
Expand Down
1 change: 1 addition & 0 deletions src/screencast/wlr_screencopy.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ static void wlr_frame_linux_dmabuf(void *data,
cast->xdpw_frames.screencopy_frame.size = cast->xdpw_frames.screencopy_frame.stride * height;
cast->xdpw_frames.screencopy_frame.offset = gbm_bo_get_offset(cast->xdpw_frames.screencopy_frame.bo, 0);
cast->xdpw_frames.screencopy_frame.fd = gbm_bo_get_fd(cast->xdpw_frames.screencopy_frame.bo);
cast->xdpw_frames.screencopy_frame.modifier = gbm_bo_get_modifier(cast->xdpw_frames.screencopy_frame.bo);
} else {
logprint(TRACE,"wlroots: dmabuf buffer exists");
}
Expand Down

0 comments on commit d4b0358

Please sign in to comment.