settings.js 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. /*
  2. Copyright (C) 2013 Borsato Ivano
  3. The JavaScript code in this page is free software: you can
  4. redistribute it and/or modify it under the terms of the GNU
  5. General Public License (GNU GPL) as published by the Free Software
  6. Foundation, either version 3 of the License, or (at your option)
  7. any later version. The code is distributed WITHOUT ANY WARRANTY;
  8. without even the implied warranty of MERCHANTABILITY or FITNESS
  9. FOR A PARTICULAR PURPOSE. See the GNU GPL for more details.
  10. */
  11. 'use strict';
  12. import GObject from 'gi://GObject';
  13. // setting keys
  14. export const INPUT_AUDIO_SOURCE_SETTING_KEY = 'input-audio-source';
  15. export const ACTIVE_POST_CMD_SETTING_KEY = 'execute-post-cmd';
  16. export const POST_CMD_SETTING_KEY = 'post-cmd';
  17. export const ACTIVE_PRE_CMD_SETTING_KEY = 'execute-pre-cmd';
  18. export const PRE_CMD_SETTING_KEY = 'pre-cmd';
  19. export const ACTIVE_CUSTOM_GSP_SETTING_KEY = 'active-custom-gsp';
  20. export const ACTIVE_SHORTCUT_SETTING_KEY = 'active-shortcut';
  21. export const SHORTCUT_KEY_SETTING_KEY = 'shortcut-key';
  22. export const TIME_DELAY_SETTING_KEY = 'delay-time';
  23. export const SHOW_NOTIFY_ALERT_SETTING_KEY = 'show-notify-alert';
  24. export const SHOW_AREA_REC_SETTING_KEY = 'show-area-rec';
  25. export const VERBOSE_DEBUG_SETTING_KEY = 'verbose-debug';
  26. export const PIPELINE_REC_SETTING_KEY = 'pipeline';
  27. export const FPS_SETTING_KEY = 'fps';
  28. export const STATUS_INDICATORS_SETTING_KEY = 'status-indicators';
  29. export const X_POS_SETTING_KEY = 'x-pos';
  30. export const Y_POS_SETTING_KEY = 'y-pos';
  31. export const WIDTH_SETTING_KEY = 'width-rec';
  32. export const HEIGHT_SETTING_KEY = 'height-rec';
  33. export const DRAW_CURSOR_SETTING_KEY = 'draw-cursor';
  34. export const AREA_SCREEN_SETTING_KEY = 'area-screen';
  35. export const FILE_NAME_SETTING_KEY = 'file-name';
  36. export const FILE_FOLDER_SETTING_KEY = 'file-folder';
  37. export const FILE_CONTAINER_SETTING_KEY = 'file-container';
  38. export const FILE_RESOLUTION_TYPE_SETTING_KEY = 'file-resolution-type';
  39. export const FILE_RESOLUTION_KAR_SETTING_KEY = 'file-resolution-kar';
  40. export const FILE_RESOLUTION_WIDTH_SETTING_KEY = 'file-resolution-width';
  41. export const FILE_RESOLUTION_HEIGHT_SETTING_KEY = 'file-resolution-height';
  42. export const QUALITY_SETTING_KEY = 'quality-index';
  43. export const DEVICE_INDEX_WEBCAM_SETTING_KEY = 'device-webcam-index';
  44. export const DEVICE_WEBCAM_SETTING_KEY = 'device-webcam';
  45. export const QUALITY_WEBCAM_SETTING_KEY = 'quality-webcam';
  46. export const WIDTH_WEBCAM_SETTING_KEY = 'width-webcam';
  47. export const HEIGHT_WEBCAM_SETTING_KEY = 'height-webcam';
  48. export const TYPE_UNIT_WEBCAM_SETTING_KEY = 'type-unit-webcam';
  49. export const MARGIN_X_WEBCAM_SETTING_KEY = 'margin-x-webcam';
  50. export const MARGIN_Y_WEBCAM_SETTING_KEY = 'margin-y-webcam';
  51. export const ALPHA_CHANNEL_WEBCAM_SETTING_KEY = 'alpha-channel-webcam';
  52. export const CORNER_POSITION_WEBCAM_SETTING_KEY = 'corner-position-webcam';
  53. // shortcut tree view columns
  54. export const SHORTCUT_COLUMN_KEY = 0;
  55. export const SHORTCUT_COLUMN_MODS = 1;
  56. export const Settings = GObject.registerClass(class EasyScreenCastSettings extends GObject.Object {
  57. constructor(settings) {
  58. super();
  59. this._settings = settings;
  60. }
  61. /**
  62. * getter option
  63. *
  64. * @param {string} type value type of the option. one of 'b', 'i', 's', 'd', 'as'
  65. * @param {string} key option key
  66. * @returns {string}
  67. */
  68. getOption(type, key) {
  69. switch (type) {
  70. case 'b':
  71. return this._settings.get_boolean(key);
  72. case 'i':
  73. return this._settings.get_int(key);
  74. case 's':
  75. return this._settings.get_string(key);
  76. case 'd':
  77. return this._settings.get_double(key);
  78. case 'as':
  79. return this._settings.get_strv(key);
  80. }
  81. return '';
  82. }
  83. /**
  84. * setter option
  85. *
  86. * @param {string} key option key
  87. * @param {boolean|number|string|double|object} option option value
  88. * @returns {string} empty string if successful, 'ERROR' otherwise
  89. */
  90. setOption(key, option) {
  91. switch (typeof option) {
  92. case 'boolean':
  93. this._settings.set_boolean(key, option);
  94. break;
  95. case 'number':
  96. this._settings.set_int(key, option);
  97. break;
  98. case 'string':
  99. this._settings.set_string(key, option);
  100. break;
  101. case 'double':
  102. this._settings.set_double(key, option);
  103. break;
  104. case 'object':
  105. this._settings.set_strv(key, option);
  106. break;
  107. default:
  108. return 'ERROR';
  109. }
  110. return '';
  111. }
  112. destroy() {
  113. if (this._settings)
  114. this._settings = null;
  115. }
  116. });
  117. /**
  118. * get a standard gsp pipeline
  119. *
  120. * @param {boolean} audio with or without audio
  121. * @returns {string}
  122. */
  123. export function getGSPstd(audio) {
  124. // TODO update gsp
  125. if (audio)
  126. return 'queue max-size-buffers=0 max-size-time=0 max-size-bytes=0 ! videorate ! vp8enc min_quantizer=0 max_quantizer=5 cpu-used=3 deadline=1000000 threads=%T ! queue max-size-buffers=0 max-size-time=0 max-size-bytes=0 ! mux. pulsesrc ! queue max-size-buffers=0 max-size-time=0 max-size-bytes=0 ! audioconvert ! vorbisenc ! queue max-size-buffers=0 max-size-time=0 max-size-bytes=0 ! mux. webmmux name=mux ';
  127. else
  128. return 'vp9enc min_quantizer=0 max_quantizer=5 cpu-used=3 deadline=1000000 threads=%T ! queue max-size-buffers=0 max-size-time=0 max-size-bytes=0 ! webmmux';
  129. }