29ec2d2e20
The DMA buffer paths vs MemFd paths differ slightly in when content is recorded. This was in some places done by trying to record but bail if the dequeued buffer had the wrong type. This is problematic for two reasons: we'd update the timestamp even if we refused to record, making the follow-up attempt fail, and we'd dequeue and queue buffers that didn't get any content, meaning the receiving end would see empty buffers potentially with only cursor updates. Fix this by keeping track if a stream is DMA buffer able or not, and don't attempt to record at all in the places we would previously require DMA buffers. This avoids both issues: we don't dequeue/queue pw_buffers that we refuse to record to, and we won't update the recorded timestamp when we didn't intend to record to begin with. Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2783 Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2987>
137 lines
6.8 KiB
C
137 lines
6.8 KiB
C
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
|
|
|
|
/*
|
|
* Copyright (C) 2015-2017 Red Hat Inc.
|
|
*
|
|
* This program is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU General Public License as
|
|
* published by the Free Software Foundation; either version 2 of the
|
|
* License, or (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful, but
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
* General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program; if not, write to the Free Software
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
|
* 02111-1307, USA.
|
|
*
|
|
*/
|
|
|
|
#ifndef META_SCREEN_CAST_STREAM_SRC_H
|
|
#define META_SCREEN_CAST_STREAM_SRC_H
|
|
|
|
#include <glib-object.h>
|
|
#include <spa/param/video/format-utils.h>
|
|
#include <spa/buffer/meta.h>
|
|
|
|
#include "backends/meta-backend-private.h"
|
|
#include "backends/meta-cursor-renderer.h"
|
|
#include "backends/meta-cursor.h"
|
|
#include "backends/meta-renderer.h"
|
|
#include "clutter/clutter.h"
|
|
#include "cogl/cogl.h"
|
|
#include "meta/boxes.h"
|
|
|
|
typedef struct _MetaScreenCastStream MetaScreenCastStream;
|
|
|
|
typedef enum _MetaScreenCastRecordFlag
|
|
{
|
|
META_SCREEN_CAST_RECORD_FLAG_NONE = 0,
|
|
META_SCREEN_CAST_RECORD_FLAG_CURSOR_ONLY = 1 << 0,
|
|
} MetaScreenCastRecordFlag;
|
|
|
|
typedef enum _MetaScreenCastRecordResult
|
|
{
|
|
META_SCREEN_CAST_RECORD_RESULT_RECORDED_NOTHING = 0,
|
|
META_SCREEN_CAST_RECORD_RESULT_RECORDED_FRAME = 1 << 0,
|
|
META_SCREEN_CAST_RECORD_RESULT_RECORDED_CURSOR = 1 << 1,
|
|
} MetaScreenCastRecordResult;
|
|
|
|
#define META_TYPE_SCREEN_CAST_STREAM_SRC (meta_screen_cast_stream_src_get_type ())
|
|
G_DECLARE_DERIVABLE_TYPE (MetaScreenCastStreamSrc,
|
|
meta_screen_cast_stream_src,
|
|
META, SCREEN_CAST_STREAM_SRC,
|
|
GObject)
|
|
|
|
struct _MetaScreenCastStreamSrcClass
|
|
{
|
|
GObjectClass parent_class;
|
|
|
|
gboolean (* get_specs) (MetaScreenCastStreamSrc *src,
|
|
int *width,
|
|
int *height,
|
|
float *frame_rate);
|
|
void (* enable) (MetaScreenCastStreamSrc *src);
|
|
void (* disable) (MetaScreenCastStreamSrc *src);
|
|
gboolean (* record_to_buffer) (MetaScreenCastStreamSrc *src,
|
|
int width,
|
|
int height,
|
|
int stride,
|
|
uint8_t *data,
|
|
GError **error);
|
|
gboolean (* record_to_framebuffer) (MetaScreenCastStreamSrc *src,
|
|
CoglFramebuffer *framebuffer,
|
|
GError **error);
|
|
void (* record_follow_up) (MetaScreenCastStreamSrc *src);
|
|
|
|
gboolean (* get_videocrop) (MetaScreenCastStreamSrc *src,
|
|
MetaRectangle *crop_rect);
|
|
void (* set_cursor_metadata) (MetaScreenCastStreamSrc *src,
|
|
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);
|
|
|
|
gboolean meta_screen_cast_stream_src_is_enabled (MetaScreenCastStreamSrc *src);
|
|
|
|
MetaScreenCastRecordResult meta_screen_cast_stream_src_maybe_record_frame (MetaScreenCastStreamSrc *src,
|
|
MetaScreenCastRecordFlag flags,
|
|
const cairo_region_t *redraw_clip);
|
|
|
|
MetaScreenCastRecordResult meta_screen_cast_stream_src_maybe_record_frame_with_timestamp (MetaScreenCastStreamSrc *src,
|
|
MetaScreenCastRecordFlag flags,
|
|
const cairo_region_t *redraw_clip,
|
|
int64_t frame_timestamp_us);
|
|
|
|
gboolean meta_screen_cast_stream_src_pending_follow_up_frame (MetaScreenCastStreamSrc *src);
|
|
|
|
MetaScreenCastStream * meta_screen_cast_stream_src_get_stream (MetaScreenCastStreamSrc *src);
|
|
|
|
gboolean meta_screen_cast_stream_src_draw_cursor_into (MetaScreenCastStreamSrc *src,
|
|
CoglTexture *cursor_texture,
|
|
float scale,
|
|
MetaMonitorTransform transform,
|
|
uint8_t *data,
|
|
GError **error);
|
|
|
|
void meta_screen_cast_stream_src_unset_cursor_metadata (MetaScreenCastStreamSrc *src,
|
|
struct spa_meta_cursor *spa_meta_cursor);
|
|
|
|
void meta_screen_cast_stream_src_set_cursor_position_metadata (MetaScreenCastStreamSrc *src,
|
|
struct spa_meta_cursor *spa_meta_cursor,
|
|
int x,
|
|
int y);
|
|
|
|
void meta_screen_cast_stream_src_set_empty_cursor_sprite_metadata (MetaScreenCastStreamSrc *src,
|
|
struct spa_meta_cursor *spa_meta_cursor,
|
|
int x,
|
|
int y);
|
|
|
|
void meta_screen_cast_stream_src_set_cursor_sprite_metadata (MetaScreenCastStreamSrc *src,
|
|
struct spa_meta_cursor *spa_meta_cursor,
|
|
MetaCursorSprite *cursor_sprite,
|
|
int x,
|
|
int y,
|
|
float scale,
|
|
MetaMonitorTransform transform);
|
|
|
|
gboolean meta_screen_cast_stream_src_uses_dma_bufs (MetaScreenCastStreamSrc *src);
|
|
|
|
#endif /* META_SCREEN_CAST_STREAM_SRC_H */
|