mirror of
https://github.com/brl/mutter.git
synced 2024-11-22 08:00:42 -05:00
screen-cast/src: Allow for source with adaptive stream size
The area source, window source, and monitor source, currently set up the stream size up front, given the area, maximum allowed window size or monitor resolution, but for to be introduced sources, the size will be negotiated using PipeWire, instead of specified via the D-Bus API. This commit changes the internal source API to allow for this. There are currently no users of this new behaviour. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1698>
This commit is contained in:
parent
cf5836a6ec
commit
2fbde28720
@ -83,7 +83,7 @@ get_backend (MetaScreenCastAreaStreamSrc *area_src)
|
|||||||
return meta_screen_cast_get_backend (screen_cast);
|
return meta_screen_cast_get_backend (screen_cast);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static gboolean
|
||||||
meta_screen_cast_area_stream_src_get_specs (MetaScreenCastStreamSrc *src,
|
meta_screen_cast_area_stream_src_get_specs (MetaScreenCastStreamSrc *src,
|
||||||
int *width,
|
int *width,
|
||||||
int *height,
|
int *height,
|
||||||
@ -100,6 +100,8 @@ meta_screen_cast_area_stream_src_get_specs (MetaScreenCastStreamSrc *src,
|
|||||||
*width = (int) roundf (area->width * scale);
|
*width = (int) roundf (area->width * scale);
|
||||||
*height = (int) roundf (area->height * scale);
|
*height = (int) roundf (area->height * scale);
|
||||||
*frame_rate = 60.0;
|
*frame_rate = 60.0;
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
|
@ -87,7 +87,7 @@ get_monitor (MetaScreenCastMonitorStreamSrc *monitor_src)
|
|||||||
return meta_screen_cast_monitor_stream_get_monitor (monitor_stream);
|
return meta_screen_cast_monitor_stream_get_monitor (monitor_stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static gboolean
|
||||||
meta_screen_cast_monitor_stream_src_get_specs (MetaScreenCastStreamSrc *src,
|
meta_screen_cast_monitor_stream_src_get_specs (MetaScreenCastStreamSrc *src,
|
||||||
int *width,
|
int *width,
|
||||||
int *height,
|
int *height,
|
||||||
@ -112,6 +112,8 @@ meta_screen_cast_monitor_stream_src_get_specs (MetaScreenCastStreamSrc *src,
|
|||||||
*width = (int) roundf (logical_monitor->rect.width * scale);
|
*width = (int) roundf (logical_monitor->rect.width * scale);
|
||||||
*height = (int) roundf (logical_monitor->rect.height * scale);
|
*height = (int) roundf (logical_monitor->rect.height * scale);
|
||||||
*frame_rate = meta_monitor_mode_get_refresh_rate (mode);
|
*frame_rate = meta_monitor_mode_get_refresh_rate (mode);
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -47,6 +47,14 @@
|
|||||||
(sizeof (struct spa_meta_cursor) + \
|
(sizeof (struct spa_meta_cursor) + \
|
||||||
sizeof (struct spa_meta_bitmap) + width * height * 4)
|
sizeof (struct spa_meta_bitmap) + width * height * 4)
|
||||||
|
|
||||||
|
#define DEFAULT_SIZE SPA_RECTANGLE (1280, 720)
|
||||||
|
#define MIN_SIZE SPA_RECTANGLE (1, 1)
|
||||||
|
#define MAX_SIZE SPA_RECTANGLE (16384, 16386)
|
||||||
|
|
||||||
|
#define DEFAULT_FRAME_RATE SPA_FRACTION (60, 1)
|
||||||
|
#define MIN_FRAME_RATE SPA_FRACTION (1, 1)
|
||||||
|
#define MAX_FRAME_RATE SPA_FRACTION (1000, 1)
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
PROP_0,
|
PROP_0,
|
||||||
@ -107,7 +115,7 @@ G_DEFINE_TYPE_WITH_CODE (MetaScreenCastStreamSrc,
|
|||||||
meta_screen_cast_stream_src_init_initable_iface)
|
meta_screen_cast_stream_src_init_initable_iface)
|
||||||
G_ADD_PRIVATE (MetaScreenCastStreamSrc))
|
G_ADD_PRIVATE (MetaScreenCastStreamSrc))
|
||||||
|
|
||||||
static void
|
static gboolean
|
||||||
meta_screen_cast_stream_src_get_specs (MetaScreenCastStreamSrc *src,
|
meta_screen_cast_stream_src_get_specs (MetaScreenCastStreamSrc *src,
|
||||||
int *width,
|
int *width,
|
||||||
int *height,
|
int *height,
|
||||||
@ -116,7 +124,7 @@ meta_screen_cast_stream_src_get_specs (MetaScreenCastStreamSrc *src,
|
|||||||
MetaScreenCastStreamSrcClass *klass =
|
MetaScreenCastStreamSrcClass *klass =
|
||||||
META_SCREEN_CAST_STREAM_SRC_GET_CLASS (src);
|
META_SCREEN_CAST_STREAM_SRC_GET_CLASS (src);
|
||||||
|
|
||||||
klass->get_specs (src, width, height, frame_rate);
|
return klass->get_specs (src, width, height, frame_rate);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
@ -694,6 +702,8 @@ on_stream_param_changed (void *data,
|
|||||||
MetaScreenCastStreamSrc *src = data;
|
MetaScreenCastStreamSrc *src = data;
|
||||||
MetaScreenCastStreamSrcPrivate *priv =
|
MetaScreenCastStreamSrcPrivate *priv =
|
||||||
meta_screen_cast_stream_src_get_instance_private (src);
|
meta_screen_cast_stream_src_get_instance_private (src);
|
||||||
|
MetaScreenCastStreamSrcClass *klass =
|
||||||
|
META_SCREEN_CAST_STREAM_SRC_GET_CLASS (src);
|
||||||
uint8_t params_buffer[1024];
|
uint8_t params_buffer[1024];
|
||||||
int32_t width, height, stride, size;
|
int32_t width, height, stride, size;
|
||||||
struct spa_pod_builder pod_builder;
|
struct spa_pod_builder pod_builder;
|
||||||
@ -737,6 +747,9 @@ on_stream_param_changed (void *data,
|
|||||||
SPA_PARAM_META_size, SPA_POD_Int (CURSOR_META_SIZE (384, 384)));
|
SPA_PARAM_META_size, SPA_POD_Int (CURSOR_META_SIZE (384, 384)));
|
||||||
|
|
||||||
pw_stream_update_params (priv->pipewire_stream, params, G_N_ELEMENTS (params));
|
pw_stream_update_params (priv->pipewire_stream, params, G_N_ELEMENTS (params));
|
||||||
|
|
||||||
|
if (klass->notify_params_updated)
|
||||||
|
klass->notify_params_updated (src, &priv->video_format);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -884,9 +897,6 @@ create_pipewire_stream (MetaScreenCastStreamSrc *src,
|
|||||||
int width;
|
int width;
|
||||||
int height;
|
int height;
|
||||||
float frame_rate;
|
float frame_rate;
|
||||||
MetaFraction frame_rate_fraction;
|
|
||||||
struct spa_fraction max_framerate;
|
|
||||||
struct spa_fraction min_framerate;
|
|
||||||
const struct spa_pod *params[1];
|
const struct spa_pod *params[1];
|
||||||
int result;
|
int result;
|
||||||
|
|
||||||
@ -903,24 +913,49 @@ create_pipewire_stream (MetaScreenCastStreamSrc *src,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
meta_screen_cast_stream_src_get_specs (src, &width, &height, &frame_rate);
|
if (meta_screen_cast_stream_src_get_specs (src, &width, &height, &frame_rate))
|
||||||
frame_rate_fraction = meta_fraction_from_double (frame_rate);
|
{
|
||||||
|
MetaFraction frame_rate_fraction;
|
||||||
|
struct spa_fraction max_framerate;
|
||||||
|
struct spa_fraction min_framerate;
|
||||||
|
|
||||||
min_framerate = SPA_FRACTION (1, 1);
|
frame_rate_fraction = meta_fraction_from_double (frame_rate);
|
||||||
max_framerate = SPA_FRACTION (frame_rate_fraction.num,
|
|
||||||
frame_rate_fraction.denom);
|
|
||||||
|
|
||||||
params[0] = spa_pod_builder_add_object (
|
min_framerate = SPA_FRACTION (1, 1);
|
||||||
&pod_builder,
|
max_framerate = SPA_FRACTION (frame_rate_fraction.num,
|
||||||
SPA_TYPE_OBJECT_Format, SPA_PARAM_EnumFormat,
|
frame_rate_fraction.denom);
|
||||||
SPA_FORMAT_mediaType, SPA_POD_Id (SPA_MEDIA_TYPE_video),
|
|
||||||
SPA_FORMAT_mediaSubtype, SPA_POD_Id (SPA_MEDIA_SUBTYPE_raw),
|
params[0] = spa_pod_builder_add_object (
|
||||||
SPA_FORMAT_VIDEO_format, SPA_POD_Id (SPA_VIDEO_FORMAT_BGRx),
|
&pod_builder,
|
||||||
SPA_FORMAT_VIDEO_size, SPA_POD_Rectangle (&SPA_RECTANGLE (width, height)),
|
SPA_TYPE_OBJECT_Format, SPA_PARAM_EnumFormat,
|
||||||
SPA_FORMAT_VIDEO_framerate, SPA_POD_Fraction (&SPA_FRACTION (0, 1)),
|
SPA_FORMAT_mediaType, SPA_POD_Id (SPA_MEDIA_TYPE_video),
|
||||||
SPA_FORMAT_VIDEO_maxFramerate, SPA_POD_CHOICE_RANGE_Fraction (&max_framerate,
|
SPA_FORMAT_mediaSubtype, SPA_POD_Id (SPA_MEDIA_SUBTYPE_raw),
|
||||||
&min_framerate,
|
SPA_FORMAT_VIDEO_format, SPA_POD_Id (SPA_VIDEO_FORMAT_BGRx),
|
||||||
&max_framerate));
|
SPA_FORMAT_VIDEO_size, SPA_POD_Rectangle (&SPA_RECTANGLE (width,
|
||||||
|
height)),
|
||||||
|
SPA_FORMAT_VIDEO_framerate, SPA_POD_Fraction (&SPA_FRACTION (0, 1)),
|
||||||
|
SPA_FORMAT_VIDEO_maxFramerate,
|
||||||
|
SPA_POD_CHOICE_RANGE_Fraction (&max_framerate,
|
||||||
|
&min_framerate,
|
||||||
|
&max_framerate));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
params[0] = spa_pod_builder_add_object (
|
||||||
|
&pod_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),
|
||||||
|
SPA_FORMAT_VIDEO_format, SPA_POD_Id (SPA_VIDEO_FORMAT_BGRx),
|
||||||
|
SPA_FORMAT_VIDEO_size, SPA_POD_CHOICE_RANGE_Rectangle (&DEFAULT_SIZE,
|
||||||
|
&MIN_SIZE,
|
||||||
|
&MAX_SIZE),
|
||||||
|
SPA_FORMAT_VIDEO_framerate, SPA_POD_Fraction (&SPA_FRACTION (0, 1)),
|
||||||
|
SPA_FORMAT_VIDEO_maxFramerate,
|
||||||
|
SPA_POD_CHOICE_RANGE_Fraction (&DEFAULT_FRAME_RATE,
|
||||||
|
&MIN_FRAME_RATE,
|
||||||
|
&MAX_FRAME_RATE));
|
||||||
|
}
|
||||||
|
|
||||||
pw_stream_add_listener (pipewire_stream,
|
pw_stream_add_listener (pipewire_stream,
|
||||||
&priv->pipewire_stream_listener,
|
&priv->pipewire_stream_listener,
|
||||||
|
@ -53,10 +53,10 @@ struct _MetaScreenCastStreamSrcClass
|
|||||||
{
|
{
|
||||||
GObjectClass parent_class;
|
GObjectClass parent_class;
|
||||||
|
|
||||||
void (* get_specs) (MetaScreenCastStreamSrc *src,
|
gboolean (* get_specs) (MetaScreenCastStreamSrc *src,
|
||||||
int *width,
|
int *width,
|
||||||
int *height,
|
int *height,
|
||||||
float *frame_rate);
|
float *frame_rate);
|
||||||
void (* enable) (MetaScreenCastStreamSrc *src);
|
void (* enable) (MetaScreenCastStreamSrc *src);
|
||||||
void (* disable) (MetaScreenCastStreamSrc *src);
|
void (* disable) (MetaScreenCastStreamSrc *src);
|
||||||
gboolean (* record_to_buffer) (MetaScreenCastStreamSrc *src,
|
gboolean (* record_to_buffer) (MetaScreenCastStreamSrc *src,
|
||||||
@ -74,6 +74,9 @@ struct _MetaScreenCastStreamSrcClass
|
|||||||
MetaRectangle *crop_rect);
|
MetaRectangle *crop_rect);
|
||||||
void (* set_cursor_metadata) (MetaScreenCastStreamSrc *src,
|
void (* set_cursor_metadata) (MetaScreenCastStreamSrc *src,
|
||||||
struct spa_meta_cursor *spa_meta_cursor);
|
struct spa_meta_cursor *spa_meta_cursor);
|
||||||
|
|
||||||
|
void (* notify_params_updated) (MetaScreenCastStreamSrc *src,
|
||||||
|
struct spa_video_info_raw *video_format);
|
||||||
};
|
};
|
||||||
|
|
||||||
void meta_screen_cast_stream_src_close (MetaScreenCastStreamSrc *src);
|
void meta_screen_cast_stream_src_close (MetaScreenCastStreamSrc *src);
|
||||||
|
@ -275,7 +275,7 @@ capture_into (MetaScreenCastWindowStreamSrc *window_src,
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static gboolean
|
||||||
meta_screen_cast_window_stream_src_get_specs (MetaScreenCastStreamSrc *src,
|
meta_screen_cast_window_stream_src_get_specs (MetaScreenCastStreamSrc *src,
|
||||||
int *width,
|
int *width,
|
||||||
int *height,
|
int *height,
|
||||||
@ -287,6 +287,8 @@ meta_screen_cast_window_stream_src_get_specs (MetaScreenCastStreamSrc *src,
|
|||||||
*width = get_stream_width (window_src);
|
*width = get_stream_width (window_src);
|
||||||
*height = get_stream_height (window_src);
|
*height = get_stream_height (window_src);
|
||||||
*frame_rate = 60.0f;
|
*frame_rate = 60.0f;
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
|
Loading…
Reference in New Issue
Block a user