diff options
author | Jonas Ådahl <jadahl@gmail.com> | 2017-06-26 12:55:48 +0800 |
---|---|---|
committer | Jonas Ådahl <jadahl@gmail.com> | 2017-08-29 14:39:04 +0800 |
commit | 920541fa26f667b5cb8d859585067461b2b09e59 (patch) | |
tree | 648148bcc9556130da5032f880f1703608c1cd95 /src/backends/meta-screen-cast-monitor-stream-src.c | |
parent | 9d8922764cbf03f1d35a8acb7e9a0d58969fcb20 (diff) | |
download | mutter-920541fa26f667b5cb8d859585067461b2b09e59.tar.gz |
screen-cast-stream-src: Only try to record frames when streaming
Only when the PipeWire stream state is 'PW_STREAM_STATE STREAMING'
should the signal be connected causing the src to maybe record a frame.
https://bugzilla.gnome.org/show_bug.cgi?id=784199
Diffstat (limited to 'src/backends/meta-screen-cast-monitor-stream-src.c')
-rw-r--r-- | src/backends/meta-screen-cast-monitor-stream-src.c | 75 |
1 files changed, 35 insertions, 40 deletions
diff --git a/src/backends/meta-screen-cast-monitor-stream-src.c b/src/backends/meta-screen-cast-monitor-stream-src.c index dd9196e5e..e5a681b37 100644 --- a/src/backends/meta-screen-cast-monitor-stream-src.c +++ b/src/backends/meta-screen-cast-monitor-stream-src.c @@ -94,22 +94,6 @@ meta_screen_cast_monitor_stream_src_get_specs (MetaScreenCastStreamSrc *src, } static void -meta_screen_cast_monitor_stream_src_record_frame (MetaScreenCastStreamSrc *src, - uint8_t *data) -{ - MetaScreenCastMonitorStreamSrc *monitor_src = - META_SCREEN_CAST_MONITOR_STREAM_SRC (src); - ClutterStage *stage; - MetaMonitor *monitor; - MetaLogicalMonitor *logical_monitor; - - stage = get_stage (monitor_src); - monitor = get_monitor (monitor_src); - logical_monitor = meta_monitor_get_logical_monitor (monitor); - clutter_stage_capture_into (stage, FALSE, &logical_monitor->rect, data); -} - -static void stage_painted (ClutterActor *actor, MetaScreenCastMonitorStreamSrc *monitor_src) { @@ -118,24 +102,11 @@ stage_painted (ClutterActor *actor, meta_screen_cast_stream_src_maybe_record_frame (src); } -MetaScreenCastMonitorStreamSrc * -meta_screen_cast_monitor_stream_src_new (MetaScreenCastMonitorStream *monitor_stream, - const char *stream_id, - GError **error) -{ - return g_initable_new (META_TYPE_SCREEN_CAST_MONITOR_STREAM_SRC, - NULL, - error, - "stream-id", stream_id, - "stream", monitor_stream, - NULL); -} - static void -meta_screen_cast_monitor_stream_src_constructed (GObject *object) +meta_screen_cast_monitor_stream_src_enable (MetaScreenCastStreamSrc *src) { MetaScreenCastMonitorStreamSrc *monitor_src = - META_SCREEN_CAST_MONITOR_STREAM_SRC (object); + META_SCREEN_CAST_MONITOR_STREAM_SRC (src); ClutterStage *stage; stage = get_stage (monitor_src); @@ -147,18 +118,44 @@ meta_screen_cast_monitor_stream_src_constructed (GObject *object) } static void -meta_screen_cast_monitor_stream_src_finalize (GObject *object) +meta_screen_cast_monitor_stream_src_disable (MetaScreenCastStreamSrc *src) { MetaScreenCastMonitorStreamSrc *monitor_src = - META_SCREEN_CAST_MONITOR_STREAM_SRC (object); - GObjectClass *parent_class = - G_OBJECT_CLASS (meta_screen_cast_monitor_stream_src_parent_class); + META_SCREEN_CAST_MONITOR_STREAM_SRC (src); ClutterStage *stage; stage = get_stage (monitor_src); g_signal_handler_disconnect (stage, monitor_src->stage_painted_handler_id); + monitor_src->stage_painted_handler_id = 0; +} + +static void +meta_screen_cast_monitor_stream_src_record_frame (MetaScreenCastStreamSrc *src, + uint8_t *data) +{ + MetaScreenCastMonitorStreamSrc *monitor_src = + META_SCREEN_CAST_MONITOR_STREAM_SRC (src); + ClutterStage *stage; + MetaMonitor *monitor; + MetaLogicalMonitor *logical_monitor; + + stage = get_stage (monitor_src); + monitor = get_monitor (monitor_src); + logical_monitor = meta_monitor_get_logical_monitor (monitor); + clutter_stage_capture_into (stage, FALSE, &logical_monitor->rect, data); +} - parent_class->finalize (object); +MetaScreenCastMonitorStreamSrc * +meta_screen_cast_monitor_stream_src_new (MetaScreenCastMonitorStream *monitor_stream, + const char *stream_id, + GError **error) +{ + return g_initable_new (META_TYPE_SCREEN_CAST_MONITOR_STREAM_SRC, + NULL, + error, + "stream-id", stream_id, + "stream", monitor_stream, + NULL); } static void @@ -169,13 +166,11 @@ meta_screen_cast_monitor_stream_src_init (MetaScreenCastMonitorStreamSrc *monito static void meta_screen_cast_monitor_stream_src_class_init (MetaScreenCastMonitorStreamSrcClass *klass) { - GObjectClass *object_class = G_OBJECT_CLASS (klass); MetaScreenCastStreamSrcClass *src_class = META_SCREEN_CAST_STREAM_SRC_CLASS (klass); - object_class->constructed = meta_screen_cast_monitor_stream_src_constructed; - object_class->finalize = meta_screen_cast_monitor_stream_src_finalize; - src_class->get_specs = meta_screen_cast_monitor_stream_src_get_specs; + src_class->enable = meta_screen_cast_monitor_stream_src_enable; + src_class->disable = meta_screen_cast_monitor_stream_src_disable; src_class->record_frame = meta_screen_cast_monitor_stream_src_record_frame; } |