[gnome-sound-recorder] combine encoding profiles to record.js



commit d25fab5adb15c4e7a8ccc90dc37c38c85b519804
Author: Kavan Mevada <kavanmevada gmail com>
Date:   Fri May 29 23:06:25 2020 +0530

    combine encoding profiles to record.js

 src/encodingProfile.js                           | 73 ------------------------
 src/org.gnome.SoundRecorder.src.gresource.xml.in |  1 -
 src/preferences.js                               |  7 +--
 src/record.js                                    | 50 ++++++++++++++--
 4 files changed, 49 insertions(+), 82 deletions(-)
---
diff --git a/src/org.gnome.SoundRecorder.src.gresource.xml.in 
b/src/org.gnome.SoundRecorder.src.gresource.xml.in
index 2fcc1ff..4457702 100644
--- a/src/org.gnome.SoundRecorder.src.gresource.xml.in
+++ b/src/org.gnome.SoundRecorder.src.gresource.xml.in
@@ -2,7 +2,6 @@
 <gresources>
   <gresource prefix="/org/gnome/SoundRecorder@profile@/js">
     <file>application.js</file>
-    <file>encodingProfile.js</file>
     <file>utils.js</file>
     <file>recordingList.js</file>
     <file>recording.js</file>
diff --git a/src/preferences.js b/src/preferences.js
index bcf8196..e3de357 100644
--- a/src/preferences.js
+++ b/src/preferences.js
@@ -22,7 +22,7 @@ const Gio = imports.gi.Gio;
 const Gtk = imports.gi.Gtk;
 const GObject = imports.gi.GObject;
 
-var EncodingProfile = imports.encodingProfile.EncodingProfile;
+var Record = imports.record;
 
 
 let _settings = new Gio.Settings({ schema: pkg.name });
@@ -75,9 +75,8 @@ var SettingsDialog = GObject.registerClass({
 
 
 
-        Object.values(EncodingProfile.Profiles).forEach(profile => {
-            let index = profile.index.toString();
-            this._formateComboBox.append(index, profile.name);
+        Object.values(Record.EncodingProfiles).forEach((profile, index) => {
+            this._formateComboBox.append(`${index}`, profile.name);
         });
         this._formateComboBox.set_active(settings.encodingProfile);
         this._formateComboBox.connect('changed', () => {
diff --git a/src/record.js b/src/record.js
index e3df63d..56c325c 100644
--- a/src/record.js
+++ b/src/record.js
@@ -1,4 +1,4 @@
-/* exported Record */
+/* exported Record EncodingProfiles */
 /*
  * Copyright 2013 Meg Ford
  * This library is free software; you can redistribute it and/or
@@ -28,7 +28,6 @@ const Gtk = imports.gi.Gtk;
 const Application = imports.application;
 const Settings = imports.preferences;
 const MainWindow = imports.mainWindow;
-const EncodingProfile = imports.encodingProfile.EncodingProfile;
 
 var PipelineStates = {
     PLAYING: 0,
@@ -51,6 +50,34 @@ const _SEC_TIMEOUT = 100;
 
 let errorDialogState;
 
+// All supported encoding profiles.
+var EncodingProfiles = [
+    { name: 'VORBIS',
+        containerCaps: 'application/ogg;audio/ogg;video/ogg',
+        audioCaps: 'audio/x-vorbis',
+        mimeType: 'audio/x-vorbis' },
+
+    { name: 'OPUS',
+        containerCaps: 'application/ogg',
+        audioCaps: 'audio/x-opus',
+        mimeType: 'audio/x-opus' },
+
+    { name: 'FLAC',
+        containerCaps: 'audio/x-flac',
+        audioCaps: 'audio/x-flac',
+        mimeType: 'audio/x-flac' },
+
+    { name: 'MP3',
+        containerCaps: 'application/x-id3',
+        audioCaps: 'audio/mpeg,mpegversion=(int)1,layer=(int)3',
+        mimeType: 'audio/mpeg' },
+
+    { name: 'M4A',
+        containerCaps: 'video/quicktime,variant=(string)iso',
+        audioCaps: 'audio/mpeg,mpegversion=(int)4',
+        mimeType: 'audio/mpeg' },
+];
+
 var Record = class Record {
     _recordPipeline() {
         errorDialogState = ErrState.OFF;
@@ -117,8 +144,7 @@ var Record = class Record {
             }
         });
         this.pipeline.add(this.ebin);
-        let audioProfile = EncodingProfile.fromSettings(Settings.settings.encodingProfile);
-        this.ebin.set_property('profile', audioProfile);
+        this.ebin.set_property('profile', this._getProfile());
         this.filesink = Gst.ElementFactory.make('filesink', 'filesink');
         this.filesink.set_property('location', this.initialFileName);
         this.pipeline.add(this.filesink);
@@ -325,6 +351,22 @@ var Record = class Record {
             errorDialog.show();
         }
     }
+
+    _getProfile() {
+        let profileIndex = Settings.settings.encodingProfile;
+        const profile = EncodingProfiles[profileIndex];
+
+        let audioCaps = Gst.Caps.from_string(profile.audioCaps);
+        audioCaps.set_value('channels', this._getChannels());
+
+        let encodingProfile = GstPbutils.EncodingAudioProfile.new(audioCaps, null, null, 1);
+        let containerCaps = Gst.Caps.from_string(profile.containerCaps);
+        let containerProfile = GstPbutils.EncodingContainerProfile.new('record', null, containerCaps, null);
+        containerProfile.add_profile(encodingProfile);
+
+        return containerProfile;
+    }
+
 };
 
 const BuildFileName = class BuildFileName {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]