Seeds.cpp 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. /*\
  2. |*| Copyright 2015-2016 bill-auger <https://github.com/bill-auger/av-caster/issues>
  3. |*|
  4. |*| This file is part of the AvCaster program.
  5. |*|
  6. |*| AvCaster is free software: you can redistribute it and/or modify
  7. |*| it under the terms of the GNU General Public License version 3
  8. |*| as published by the Free Software Foundation.
  9. |*|
  10. |*| AvCaster is distributed in the hope that it will be useful,
  11. |*| but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. |*| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. |*| GNU General Public License for more details.
  14. |*|
  15. |*| You should have received a copy of the GNU General Public License
  16. |*| along with AvCaster. If not, see <http://www.gnu.org/licenses/>.
  17. \*/
  18. #include "Seeds.h"
  19. /* Seeds public class methods */
  20. ValueTree Seeds::DefaultStore()
  21. {
  22. ValueTree default_store = ValueTree(CONFIG::STORAGE_ID) ;
  23. default_store.setProperty(CONFIG::CONFIG_VERSION_ID , CONFIG::CONFIG_VERSION , nullptr) ;
  24. default_store.setProperty(CONFIG::PRESET_ID , CONFIG::DEFAULT_PRESET_IDX , nullptr) ;
  25. default_store.addChild (ValueTree(CONFIG::PRESETS_ID) , -1 , nullptr) ;
  26. return default_store ;
  27. }
  28. ValueTree Seeds::PresetSeeds()
  29. {
  30. FileSeed file_preset_seed ;
  31. RtmpSeed rtmp_preset_seed ;
  32. LctvSeed lctv_preset_seed ;
  33. ValueTree preset_seeds = ValueTree(CONFIG::PRESETS_ID) ;
  34. preset_seeds.addChild(file_preset_seed.presetStore , CONFIG::FILE_PRESET_IDX , nullptr) ;
  35. preset_seeds.addChild(rtmp_preset_seed.presetStore , CONFIG::RTMP_PRESET_IDX , nullptr) ;
  36. preset_seeds.addChild(lctv_preset_seed.presetStore , CONFIG::LCTV_PRESET_IDX , nullptr) ;
  37. return preset_seeds ;
  38. }
  39. /* Seeds protected constructor */
  40. Seeds::Seeds()
  41. {
  42. this->isScreencapActive = CONFIG::DEFAULT_IS_SCREEN_ACTIVE ;
  43. this->isCameraActive = CONFIG::DEFAULT_IS_CAMERA_ACTIVE ;
  44. this->isTextActive = CONFIG::DEFAULT_IS_TEXT_ACTIVE ;
  45. this->isImageActive = CONFIG::DEFAULT_IS_IMAGE_ACTIVE ;
  46. this->isPreviewActive = CONFIG::DEFAULT_IS_PREVIEW_ACTIVE ;
  47. this->isAudioActive = CONFIG::DEFAULT_IS_AUDIO_ACTIVE ;
  48. this->configPane = CONFIG::DEFAULT_CONFIG_PANE ;
  49. this->displayN = CONFIG::DEFAULT_DISPLAY_N ;
  50. this->screenN = CONFIG::DEFAULT_SCREEN_N ;
  51. this->screencapW = CONFIG::DEFAULT_SCREENCAP_W ;
  52. this->screencapH = CONFIG::DEFAULT_SCREENCAP_H ;
  53. this->offsetX = CONFIG::DEFAULT_OFFSET_X ;
  54. this->offsetY = CONFIG::DEFAULT_OFFSET_Y ;
  55. this->cameraDeviceIdx = CONFIG::DEFAULT_CAMERA_DEVICE_IDX ;
  56. this->cameraResolutionIdx = CONFIG::DEFAULT_CAMERA_RES_IDX ;
  57. this->audioApiIdx = CONFIG::DEFAULT_AUDIO_API_IDX ;
  58. this->audioDeviceIdx = CONFIG::DEFAULT_AUDIO_DEVICE_IDX ;
  59. this->audioCodecIdx = CONFIG::DEFAULT_AUDIO_CODEC_IDX ;
  60. this->nChannels = CONFIG::DEFAULT_N_CHANNELS ;
  61. this->samplerate = CONFIG::DEFAULT_SAMPLERATE_IDX ;
  62. this->audioBitrate = CONFIG::DEFAULT_AUDIO_BITRATE_IDX ;
  63. this->motdText = CONFIG::DEFAULT_MOTD_TEXT ;
  64. this->textStyleIdx = CONFIG::DEFAULT_TEXT_STYLE_IDX ;
  65. this->textPosIdx = CONFIG::DEFAULT_TEXT_POSITION_IDX ;
  66. this->imageLocation = CONFIG::DEFAULT_IMAGE_LOCATION ;
  67. this->muxerIdx = CONFIG::DEFAULT_OUTPUT_MUXER_IDX ;
  68. this->outputW = CONFIG::DEFAULT_OUTPUT_W ;
  69. this->outputH = CONFIG::DEFAULT_OUTPUT_H ;
  70. this->framerate = CONFIG::DEFAULT_FRAMERATE_IDX ;
  71. this->videoBitrate = CONFIG::DEFAULT_VIDEO_BITRATE_IDX ;
  72. this->networkStore = ValueTree(CONFIG::NETWORK_ID) ;
  73. this->network = CONFIG::DEFAULT_NETWORK ;
  74. this->port = CONFIG::DEFAULT_PORT ;
  75. this->nick = CONFIG::DEFAULT_NICK ;
  76. this->pass = CONFIG::DEFAULT_PASS ;
  77. this->channel = CONFIG::DEFAULT_CHANNEL ;
  78. this->showTimestamps = CONFIG::DEFAULT_SHOW_TIMESTAMPS ;
  79. this->showJoinParts = CONFIG::DEFAULT_SHOW_JOINPARTS ;
  80. this->greeting = CONFIG::DEFAULT_GREETING ;
  81. // subclass responsibility
  82. this->presetStore = ValueTree::invalid ;
  83. this->presetId = Identifier::null ;
  84. this->presetName = String::empty ;
  85. this->outputSinkIdx = -1 ;
  86. this->outputDest = String::empty ;
  87. }
  88. void Seeds::createPreset()
  89. {
  90. this->presetStore = ValueTree(presetId) ;
  91. setValue(this->presetStore , CONFIG::SCREEN_ID , var(this->isScreencapActive )) ;
  92. setValue(this->presetStore , CONFIG::CAMERA_ID , var(this->isCameraActive )) ;
  93. setValue(this->presetStore , CONFIG::TEXT_ID , var(this->isTextActive )) ;
  94. setValue(this->presetStore , CONFIG::IMAGE_ID , var(this->isImageActive )) ;
  95. setValue(this->presetStore , CONFIG::PREVIEW_ID , var(this->isPreviewActive )) ;
  96. setValue(this->presetStore , CONFIG::AUDIO_ID , var(this->isAudioActive )) ;
  97. setValue(this->presetStore , CONFIG::PRESET_NAME_ID , var(this->presetName )) ;
  98. setValue(this->presetStore , CONFIG::CONFIG_PANE_ID , var(this->configPane )) ;
  99. setValue(this->presetStore , CONFIG::DISPLAY_N_ID , var(this->displayN )) ;
  100. setValue(this->presetStore , CONFIG::SCREEN_N_ID , var(this->screenN )) ;
  101. setValue(this->presetStore , CONFIG::SCREENCAP_W_ID , var(this->screencapW )) ;
  102. setValue(this->presetStore , CONFIG::SCREENCAP_H_ID , var(this->screencapH )) ;
  103. setValue(this->presetStore , CONFIG::OFFSET_X_ID , var(this->offsetX )) ;
  104. setValue(this->presetStore , CONFIG::OFFSET_Y_ID , var(this->offsetY )) ;
  105. setValue(this->presetStore , CONFIG::CAMERA_DEVICE_ID , var(this->cameraDeviceIdx )) ;
  106. setValue(this->presetStore , CONFIG::CAMERA_RES_ID , var(this->cameraResolutionIdx)) ;
  107. setValue(this->presetStore , CONFIG::AUDIO_API_ID , var(this->audioApiIdx )) ;
  108. setValue(this->presetStore , CONFIG::AUDIO_DEVICE_ID , var(this->audioDeviceIdx )) ;
  109. setValue(this->presetStore , CONFIG::AUDIO_CODEC_ID , var(this->audioCodecIdx )) ;
  110. setValue(this->presetStore , CONFIG::N_CHANNELS_ID , var(this->nChannels )) ;
  111. setValue(this->presetStore , CONFIG::SAMPLERATE_ID , var(this->samplerate )) ;
  112. setValue(this->presetStore , CONFIG::AUDIO_BITRATE_ID , var(this->audioBitrate )) ;
  113. setValue(this->presetStore , CONFIG::MOTD_TEXT_ID , var(this->motdText )) ;
  114. setValue(this->presetStore , CONFIG::TEXT_STYLE_ID , var(this->textStyleIdx )) ;
  115. setValue(this->presetStore , CONFIG::TEXT_POSITION_ID , var(this->textPosIdx )) ;
  116. setValue(this->presetStore , CONFIG::IMAGE_LOC_ID , var(this->imageLocation )) ;
  117. setValue(this->presetStore , CONFIG::OUTPUT_SINK_ID , var(this->outputSinkIdx )) ;
  118. setValue(this->presetStore , CONFIG::OUTPUT_MUXER_ID , var(this->muxerIdx )) ;
  119. setValue(this->presetStore , CONFIG::OUTPUT_W_ID , var(this->outputW )) ;
  120. setValue(this->presetStore , CONFIG::OUTPUT_H_ID , var(this->outputH )) ;
  121. setValue(this->presetStore , CONFIG::FRAMERATE_ID , var(this->framerate )) ;
  122. setValue(this->presetStore , CONFIG::VIDEO_BITRATE_ID , var(this->videoBitrate )) ;
  123. setValue(this->presetStore , CONFIG::OUTPUT_DEST_ID , var(this->outputDest )) ;
  124. this->presetStore.addChild(this->networkStore , -1 , nullptr) ;
  125. setValue(this->networkStore , CONFIG::NETWORK_ID , var(this->network )) ;
  126. setValue(this->networkStore , CONFIG::PORT_ID , var(this->port )) ;
  127. setValue(this->networkStore , CONFIG::NICK_ID , var(this->nick )) ;
  128. setValue(this->networkStore , CONFIG::PASS_ID , var(this->pass )) ;
  129. setValue(this->networkStore , CONFIG::CHANNEL_ID , var(this->channel )) ;
  130. setValue(this->networkStore , CONFIG::TIMESTAMPS_ID , var(this->showTimestamps)) ;
  131. setValue(this->networkStore , CONFIG::JOINPARTS_ID , var(this->showJoinParts )) ;
  132. setValue(this->networkStore , CONFIG::GREETING_ID , var(this->greeting )) ;
  133. }
  134. /* Seeds private methods */
  135. void Seeds::setValue(ValueTree a_node , Identifier a_key , var a_value)
  136. {
  137. a_node.setProperty(a_key , a_value , nullptr) ;
  138. }
  139. /* Seeds subclass public constructors */
  140. FileSeed::FileSeed()
  141. {
  142. presetId = CONFIG::FILE_PRESET_ID ;
  143. presetName = CONFIG::FILE_PRESET_NAME ;
  144. outputSinkIdx = CONFIG::FILE_OUTPUT_IDX ;
  145. outputDest = CONFIG::DEFAULT_OUTPUT_DEST ;
  146. createPreset() ;
  147. }
  148. RtmpSeed::RtmpSeed()
  149. {
  150. presetId = CONFIG::RTMP_PRESET_ID ;
  151. presetName = CONFIG::RTMP_PRESET_NAME ;
  152. outputSinkIdx = CONFIG::RTMP_OUTPUT_IDX ;
  153. outputDest = String::empty ;
  154. createPreset() ;
  155. }
  156. LctvSeed::LctvSeed()
  157. {
  158. presetId = CONFIG::LCTV_PRESET_ID ;
  159. presetName = CONFIG::LCTV_PRESET_NAME ;
  160. outputSinkIdx = CONFIG::RTMP_OUTPUT_IDX ;
  161. outputDest = String::empty ;
  162. createPreset() ;
  163. }