Skip to content
This repository has been archived by the owner on May 26, 2022. It is now read-only.

Commit

Permalink
Merge pull request #45 from dr-Styki/Flatpak
Browse files Browse the repository at this point in the history
Flatpak support !
  • Loading branch information
dr-Styki authored Oct 30, 2021
2 parents 430868a + 3bb9c81 commit 5c948df
Show file tree
Hide file tree
Showing 14 changed files with 1,796 additions and 32 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
*~
build/
.vscode/
.flatpak-builder/
42 changes: 42 additions & 0 deletions com.github.dr_styki.screenrec.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
app-id: com.github.dr_styki.screenrec
runtime: io.elementary.Platform
runtime-version: '6'
sdk: io.elementary.Sdk
command: com.github.dr_styki.screenrec
finish-args:
- '--share=ipc'
- '--socket=x11'
- '--device=dri'
- '--socket=pulseaudio'

- '--system-talk-name=org.freedesktop.Accounts'

- '--filesystem=home'
- '--filesystem=/tmp'
- '--env=GST_PLUGIN_PATH_1_0=/app/lib/gstreamer-1.0'

modules:
- name: x264
config-opts:
- --enable-shared
- --system-libx264
- --enable-pic
sources:
- type: archive
url: https://download.videolan.org/pub/x264/snapshots/x264-snapshot-20191217-2245-stable.tar.bz2
sha256: b2495c8f2930167d470994b1ce02b0f4bfb24b3317ba36ba7f112e9809264160

- name: gstreamer1-plugins-ugly
buildsystem: meson
config-opts:
- -D=x264=enabled
sources:
- type: archive
url: https://gstreamer.freedesktop.org/src/gst-plugins-ugly/gst-plugins-ugly-1.16.3.tar.xz
sha256: 403c21688065f41e53008874402b5c07832567cc1309a60df597eab7ff5843f0

- name: ScreenRec
buildsystem: meson
sources:
- type: dir
path: .
15 changes: 11 additions & 4 deletions data/com.github.dr_styki.screenrec.appdata.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,17 @@
<ul>
<li>Recording sound from computer</li>
<li>Recording sound from microphone</li>
<li>Available format: MP4, MKV and WEBM</li>
<li>Available format: MP4 and WEBM</li>
</ul>
</description>
<releases>
<release version="3.0.0" date="2021-10-30">
<description>
<ul>
<li>Add Flatpak support !</li>
</ul>
</description>
</release>
<release version="2.3.1" date="2021-01-13">
<description>
<ul>
Expand Down Expand Up @@ -81,7 +88,6 @@
</description>
</release>
</releases>

<screenshots>
<screenshot type="default">
<image>https://raw.githubusercontent.com/dr_styki/ScreenRec/master/data/screenshots/screenshot_1.png</image>
Expand All @@ -96,7 +102,6 @@
<image>https://raw.githubusercontent.com/dr_styki/ScreenRec/master/data/screenshots/screenshot_4.png</image>
</screenshot>
</screenshots>

<content_rating type="oars-1.1">
<content_attribute id="violence-cartoon">none</content_attribute>
<content_attribute id="violence-fantasy">none</content_attribute>
Expand Down Expand Up @@ -126,9 +131,11 @@
<content_attribute id="money-purchasing">none</content_attribute>
<content_attribute id="money-gambling">none</content_attribute>
</content_rating>

<developer_name>Stevy THOMAS (dr_Styki)</developer_name>
<url type="homepage">https://github.com/dr_styki/ScreenRec</url>
<url type="bugtracker">https://github.com/dr_styki/ScreenRec/issues</url>
<url type="help">https://github.com/dr_styki/ScreenRec/issues</url>
<custom>
<value key="x-appcenter-stripe">pk_live_5JaBVsaIMEY5rWllE5CkZ3Rl00OWs9lyrL</value>
</custom>
</component>
6 changes: 6 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
com.github.dr_styki.screenrec (3.0.0) focal; urgency=medium

* Add Flatpak support !

-- dr_Styki <[email protected]> Sat, 30 Oct 2021 16:55:00 +0200

com.github.dr_styki.screenrec (2.3.1) bionic; urgency=medium

* Fix Cancel button color.
Expand Down
2 changes: 1 addition & 1 deletion debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ Standards-Version: 3.9.3

Package: com.github.dr_styki.screenrec
Architecture: any
Depends: ffmpeg, gstreamer1.0-plugins-ugly, gstreamer1.0-libav, gstreamer1.0-plugins-good, ${misc:Depends}, ${shlibs:Depends}
Depends: ffmpeg, gstreamer1.0-plugins-ugly, gstreamer1.0-libav, gstreamer1.0-plugins-good, libpulse0, libpulse-mainloop-glib0, ${misc:Depends}, ${shlibs:Depends}
Description: Record videos of the screen
A simple screen recording tool which was make to work like the elementary OS Screenshot tool.
11 changes: 9 additions & 2 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
project (
'com.github.dr_styki.screenrec',
'vala', 'c',
version: '2.3.0',
version: '3.0.0',
license: 'GPL-3.0'
)

Expand All @@ -18,6 +18,11 @@ add_project_arguments (
language: 'c'
)

add_project_arguments(
['--vapidir', meson.current_source_dir() / 'vapi'],
language: 'vala'
)

# Compiling resources
asresources = gnome.compile_resources (
'as-resources',
Expand All @@ -37,7 +42,9 @@ dependencies = [
dependency ('gdk-x11-3.0'),
dependency ('gstreamer-1.0'),
dependency ('clutter-gst-3.0'),
dependency ('clutter-gtk-1.0')
dependency ('clutter-gtk-1.0'),
dependency ('libpulse'),
dependency ('libpulse-mainloop-glib')
]

subdir ('src')
Expand Down
110 changes: 110 additions & 0 deletions src/Tools/PulseAudioManager.vala
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
/*
* SPDX-License-Identifier: GPL-3.0-or-later
* SPDX-FileCopyrightText: 2018-2021 Ryo Nakano <[email protected]>
*
* Code brought from elementary/switchboard-plug-sound, src/PulseAudioManager.vala, authored by Corentin Noël
*/

public class PulseAudioManager : GLib.Object {
public string default_source_name { get; private set; }
public string default_sink_name { get; private set; }

private PulseAudio.Context context;
private PulseAudio.GLibMainLoop loop;
private bool is_ready = false;
private uint reconnect_timer_id = 0U;

private static PulseAudioManager pam;
public static unowned PulseAudioManager get_default () {
if (pam == null) {
pam = new PulseAudioManager ();
}

return pam;
}

private PulseAudioManager () {
loop = new PulseAudio.GLibMainLoop ();
}

public void start () {
reconnect_to_pulse.begin ();
}

private bool reconnect_timeout () {
reconnect_timer_id = 0U;
reconnect_to_pulse.begin ();
return false;
}

private async void reconnect_to_pulse () {
if (is_ready) {
context.disconnect ();
context = null;
is_ready = false;
}

var props = new PulseAudio.Proplist ();
props.sets (PulseAudio.Proplist.PROP_APPLICATION_ID, "com.github.ryonakano.reco");
context = new PulseAudio.Context (loop.get_api (), null, props);
context.set_state_callback (context_state_callback);

if (context.connect (null, PulseAudio.Context.Flags.NOFAIL, null) < 0) {
warning ("pa_context_connect () failed: %s", PulseAudio.strerror (context.errno ()));
}
}

private void context_state_callback (PulseAudio.Context c) {
switch (c.get_state ()) {
case PulseAudio.Context.State.READY:
c.set_subscribe_callback (subscribe_callback);
c.subscribe (PulseAudio.Context.SubscriptionMask.SERVER);
context.get_server_info (server_info_callback);
is_ready = true;
break;
case PulseAudio.Context.State.FAILED:
case PulseAudio.Context.State.TERMINATED:
if (reconnect_timer_id == 0U) {
reconnect_timer_id = Timeout.add_seconds (2, reconnect_timeout);
}

break;
default:
is_ready = false;
break;
}
}

private void subscribe_callback (PulseAudio.Context c, PulseAudio.Context.SubscriptionEventType t, uint32 index) {
var source_type = t & PulseAudio.Context.SubscriptionEventType.FACILITY_MASK;
if (source_type == PulseAudio.Context.SubscriptionEventType.SERVER) {
context.get_server_info (server_info_callback);
}
}

private void server_info_callback (PulseAudio.Context context, PulseAudio.ServerInfo? server) {
if (server == null) {
return;
}

if (default_sink_name == null) {
default_sink_name = server.default_sink_name;
debug ("Detected default sink: %s", default_sink_name);
}

if (default_sink_name != server.default_sink_name) {
debug ("Detected default sink changed: %s > %s", default_sink_name, server.default_sink_name);
default_sink_name = server.default_sink_name;
}

if (default_source_name == null) {
default_source_name = server.default_source_name;
debug ("Detected default source: %s", default_source_name);
}

if (default_source_name != server.default_source_name) {
debug ("Detected default source changed: %s > %s", default_source_name, server.default_source_name);
default_source_name = server.default_source_name;
}
}
}
28 changes: 6 additions & 22 deletions src/Tools/Recorder.vala
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,11 @@ namespace ScreenRec {
private bool crop_vid = false;
private int cpu_cores;

private PulseAudioManager pam;

public Recorder (){
pam = PulseAudioManager.get_default ();
pam.start ();
}

public void config (ScreenrecorderWindow.CaptureType capture_mode,
Expand Down Expand Up @@ -550,20 +553,10 @@ namespace ScreenRec {
string default_output = "";

try {
string sound_devices = "";
Process.spawn_command_line_sync ("pacmd list-sinks", out sound_devices);
var regex = new Regex ("(?<=\\*\\sindex:\\s\\d\\s\\sname:\\s<)[\\w\\.\\-]*");
MatchInfo match_info;

if (regex.match (sound_devices, 0, out match_info)) {
default_output = match_info.fetch (0);
}

default_output += ".monitor";
default_output = pam.default_sink_name + ".monitor";
debug ("Detected system sound device: %s", default_output);

} catch (Error e) {

warning (e.message);
}

Expand All @@ -575,20 +568,11 @@ namespace ScreenRec {

string default_input = "";

try {
string sound_devices = "";
Process.spawn_command_line_sync ("pacmd list-sources", out sound_devices);
var regex = new Regex ("(?<=\\*\\sindex:\\s\\d\\s\\sname:\\s<)[\\w\\.\\-]*");
MatchInfo match_info;

if (regex.match (sound_devices, 0, out match_info)) {
default_input = match_info.fetch (0);
}

try {
default_input = pam.default_source_name;
debug ("Detected microphone: %s", default_input);

} catch (Error e) {

warning (e.message);
}

Expand Down
10 changes: 7 additions & 3 deletions src/Views/SettingsView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,13 @@ namespace ScreenRec {
CODEC_USER,
CODEC_EXT
}
public const string[] codec_user = {"mp4", "mkv", "webm"};
public const string[] codec_gsk = {"x264enc-mp4", "x264enc-mkv", "vp8enc"};
public const string[] codec_ext = {".mp4", ".mkv", ".webm"};
//public const string[] codec_user = {"mp4", "mkv", "webm"};
//public const string[] codec_gsk = {"x264enc-mp4", "x264enc-mkv", "vp8enc"};
//public const string[] codec_ext = {".mp4", ".mkv", ".webm"};

public const string[] codec_user = {"mp4", "webm"};
public const string[] codec_gsk = {"x264enc-mp4", "vp8enc"};
public const string[] codec_ext = {".mp4", ".webm"};

private Gtk.ComboBox format_cmb;
public string format;
Expand Down
1 change: 1 addition & 0 deletions src/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ sources = files (
'Dialogs/SaveDialog.vala',

'Tools/KeybindingManager.vala',
'Tools/PulseAudioManager.vala',
'Tools/Recorder.vala',
'Tools/SendNotification.vala',

Expand Down
1 change: 1 addition & 0 deletions vapi/libpulse-mainloop-glib.deps
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
libpulse
13 changes: 13 additions & 0 deletions vapi/libpulse-mainloop-glib.vapi
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using GLib;

namespace PulseAudio {
[Compact]
[CCode (cheader_filename="pulse/glib-mainloop.h", cname="pa_glib_mainloop", cprefix="pa_glib_mainloop_", free_function="pa_glib_mainloop_free")]
public class GLibMainLoop {

[CCode (cname="pa_glib_mainloop_new")]
public GLibMainLoop(MainContext? c = null);

public unowned MainLoopApi get_api();
}
}
1 change: 1 addition & 0 deletions vapi/libpulse.deps
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
posix
Loading

0 comments on commit 5c948df

Please sign in to comment.