Skip to content

Commit

Permalink
Added a ScreenRecorder interface.
Browse files Browse the repository at this point in the history
  • Loading branch information
phw committed Jan 5, 2016
1 parent b78106b commit 6f3308c
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 34 deletions.
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ vala_precompile(VALA_C
src/peek-about-dialog.vala
src/peek-preferences-dialog.vala
src/desktop-integration.vala
src/screen-recorder.vala
src/screen-recorder/screen-recorder.vala
src/screen-recorder/ffmpeg-screen-recorder.vala
src/screen-recorder/recording-area.vala
PACKAGES
gtk+-3.0
OPTIONS
Expand Down
1 change: 0 additions & 1 deletion src/peek-application-window.vala
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ This software is licensed under the GNU General Public License
(version 3 or later). See the LICENSE file in this distribution.
*/

using GLib;
using Gtk;
using Cairo;

Expand Down
4 changes: 2 additions & 2 deletions src/peek-application.vala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Peek Copyright (c) 2015 by Philipp Wolfer <[email protected]>
Peek Copyright (c) 2015-2016 by Philipp Wolfer <[email protected]>
This file is part of Peek.
Expand Down Expand Up @@ -36,7 +36,7 @@ public class PeekApplication : Gtk.Application {
}

public override void activate () {
var recorder = new ScreenRecorder ();
var recorder = new FfmpegScreenRecorder ();
main_window = new PeekApplicationWindow (this, recorder);
main_window.present ();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,47 +1,21 @@
/*
Peek Copyright (c) 2015 by Philipp Wolfer <[email protected]>
Peek Copyright (c) 2015-2016 by Philipp Wolfer <[email protected]>
This file is part of Peek.
This software is licensed under the GNU General Public License
(version 3 or later). See the LICENSE file in this distribution.
*/

using GLib;

public struct RecordingArea {
public int left;
public int top;
public int width;
public int height;

public bool equals (RecordingArea? other) {
if (other == null) {
return false;
}

return this.left == other.left
&& this.top == other.top
&& this.width == other.width
&& this.height == other.height;
}
}

public class ScreenRecorder : Object {
public class FfmpegScreenRecorder : Object, ScreenRecorder {
private IOChannel input;
private string temp_file;

public bool is_recording { get; private set; default = false; }
public bool is_recording { get; protected set; default = false; }

public int framerate { get; set; default = 15; }

public signal void recording_started ();

public signal void recording_finished (File file);

public signal void recording_aborted (int status);

~ScreenRecorder () {
~FfmpegScreenRecorder () {
cancel ();
}

Expand Down
26 changes: 26 additions & 0 deletions src/screen-recorder/recording-area.vala
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
Peek Copyright (c) 2016 by Philipp Wolfer <[email protected]>
This file is part of Peek.
This software is licensed under the GNU General Public License
(version 3 or later). See the LICENSE file in this distribution.
*/

public struct RecordingArea {
public int left;
public int top;
public int width;
public int height;

public bool equals (RecordingArea? other) {
if (other == null) {
return false;
}

return this.left == other.left
&& this.top == other.top
&& this.width == other.width
&& this.height == other.height;
}
}
24 changes: 24 additions & 0 deletions src/screen-recorder/screen-recorder.vala
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
Peek Copyright (c) 2016 by Philipp Wolfer <[email protected]>
This file is part of Peek.
This software is licensed under the GNU General Public License
(version 3 or later). See the LICENSE file in this distribution.
*/

public interface ScreenRecorder : Object {
public abstract bool is_recording { get; protected set; }

public signal void recording_started ();

public signal void recording_finished (File file);

public signal void recording_aborted (int status);

public abstract bool record (RecordingArea area);

public abstract File? stop ();

public abstract void cancel ();
}

0 comments on commit 6f3308c

Please sign in to comment.