diff options
author | Wim Taymans <wtaymans@redhat.com> | 2015-10-15 09:41:01 +0200 |
---|---|---|
committer | Wim Taymans <wtaymans@redhat.com> | 2015-10-15 09:41:01 +0200 |
commit | 056674c3a425fec57004d0e48941c55f3e88788e (patch) | |
tree | d27a40389cdda442ad033f29cbf734a97b4c3a30 | |
parent | 6610a34ad0146862d44903390e55b6c13c53bbf9 (diff) |
attempt to use prime fdprime-fd
-rw-r--r-- | configure.ac | 2 | ||||
-rw-r--r-- | js/ui/sessionMode.js | 2 | ||||
-rw-r--r-- | js/ui/windowManager.js | 15 | ||||
-rw-r--r-- | src/shell-recorder.c | 20 |
4 files changed, 35 insertions, 4 deletions
diff --git a/configure.ac b/configure.ac index 3e265bea..b2ba219f 100644 --- a/configure.ac +++ b/configure.ac @@ -50,7 +50,7 @@ AC_MSG_CHECKING([for GStreamer (needed for recording functionality)]) if $PKG_CONFIG --exists gstreamer-1.0 '>=' $GSTREAMER_MIN_VERSION ; then AC_MSG_RESULT(yes) build_recorder=true - recorder_modules="gstreamer-1.0 gstreamer-base-1.0 x11 gtk+-3.0" + recorder_modules="gstreamer-1.0 gstreamer-base-1.0 gstreamer-allocators-1.0 x11 gtk+-3.0" PKG_CHECK_MODULES(TEST_SHELL_RECORDER, $recorder_modules clutter-1.0) else AC_MSG_RESULT(no) diff --git a/js/ui/sessionMode.js b/js/ui/sessionMode.js index ae08d085..ea412eb5 100644 --- a/js/ui/sessionMode.js +++ b/js/ui/sessionMode.js @@ -22,7 +22,7 @@ const _modes = { showCalendarEvents: false, allowSettings: false, allowExtensions: false, - allowScreencast: false, + allowScreencast: true, enabledExtensions: [], hasRunDialog: false, hasWorkspaces: false, diff --git a/js/ui/windowManager.js b/js/ui/windowManager.js index 7c96d065..4d325d31 100644 --- a/js/ui/windowManager.js +++ b/js/ui/windowManager.js @@ -709,6 +709,7 @@ const WindowManager = new Lang.Class({ this._workspaceSwitcherPopup = null; this._tilePreview = null; + this._recorder = null; this.allowKeybinding('switch-to-session-1', Shell.ActionMode.ALL); this.allowKeybinding('switch-to-session-2', Shell.ActionMode.ALL); @@ -770,7 +771,7 @@ const WindowManager = new Lang.Class({ this.setCustomKeybindingHandler('switch-to-workspace-3', Shell.ActionMode.NORMAL | Shell.ActionMode.OVERVIEW, - Lang.bind(this, this._showWorkspaceSwitcher)); + Lang.bind(this, this._toggleRecording)); this.setCustomKeybindingHandler('switch-to-workspace-4', Shell.ActionMode.NORMAL | Shell.ActionMode.OVERVIEW, @@ -1666,6 +1667,18 @@ const WindowManager = new Lang.Class({ OrigTweener.resumeAllTweens(); }, + _toggleRecording : function(display, screen, window, binding) { + if (this._recorder == null) { + this._recorder = new Shell.Recorder({ stage: global.stage, + screen: global.screen }); + this._recorder.set_file_template('recording from %d %t.webm'); + this._recorder.record(); + } else { + this._recorder.close(); + this._recorder = null; + } + }, + _showWorkspaceSwitcher : function(display, screen, window, binding) { if (!Main.sessionMode.hasWorkspaces) return; diff --git a/src/shell-recorder.c b/src/shell-recorder.c index b28e1e91..c6483f99 100644 --- a/src/shell-recorder.c +++ b/src/shell-recorder.c @@ -10,6 +10,8 @@ #define GST_USE_UNSTABLE_API #include <gst/gst.h> +#include <gst/allocators/gstfdmemory.h> + #include <gtk/gtk.h> #include <gdk/gdk.h> @@ -73,6 +75,7 @@ struct _ShellRecorder { char *pipeline_description; char *file_template; + GstAllocator *fd_allocator; /* We might have multiple pipelines that are finishing encoding * to go along with the current pipeline where we are recording. */ @@ -212,6 +215,8 @@ shell_recorder_init (ShellRecorder *recorder) shell_recorder_src_register (); + recorder->fd_allocator = gst_fd_allocator_new (); + recorder->gdk_screen = gdk_screen_get_default (); recorder->memory_target = get_memory_target(); @@ -240,6 +245,7 @@ shell_recorder_finalize (GObject *object) recorder_set_pipeline (recorder, NULL); recorder_set_file_template (recorder, NULL); + g_clear_object (&recorder->fd_allocator); g_clear_object (&recorder->a11y_settings); G_OBJECT_CLASS (shell_recorder_parent_class)->finalize (object); @@ -394,6 +400,9 @@ recorder_record_frame (ShellRecorder *recorder) guint size; GstClock *clock; GstClockTime now, base_time; + CoglFramebuffer *fbuf; + int fd; + GstMemory *fdmem = NULL; g_return_if_fail (recorder->current_pipeline != NULL); @@ -425,6 +434,9 @@ recorder_record_frame (ShellRecorder *recorder) size = recorder->area.width * recorder->area.height * 4; + buffer = gst_buffer_new(); + +#if 1 data = g_malloc (size); cogl_framebuffer_read_pixels (cogl_get_draw_framebuffer (), recorder->area.x, @@ -434,10 +446,16 @@ recorder_record_frame (ShellRecorder *recorder) CLUTTER_CAIRO_FORMAT_ARGB32, data); - buffer = gst_buffer_new(); gst_buffer_insert_memory (buffer, -1, gst_memory_new_wrapped (0, data, size, 0, size, data, g_free)); +#else + fbuf = cogl_get_draw_framebuffer (); + fd = cogl_framebuffer_get_prime_fd (fbuf); + fdmem = gst_fd_allocator_alloc (recorder->fd_allocator, fd, + size, GST_FD_MEMORY_FLAG_NONE); + gst_buffer_append_memory (buffer, fdmem); +#endif GST_BUFFER_PTS(buffer) = now; |