EnvironmentConfigs.cs 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293
  1. using WingServerCommon.Config.Parameters;
  2. namespace WingServerCommon.Config
  3. {
  4. /// <summary>
  5. /// 环境配置帮助类
  6. /// </summary>
  7. public class EnvironmentConfigs
  8. {
  9. public static General General { get; } = new General();
  10. public static Rtmp Rtmp { get; } = new Rtmp();
  11. public static Rtc Rtc { get; } = new Rtc();
  12. public static Storage Storage { get; } = new Storage();
  13. }
  14. public class BaseEnvironment
  15. {
  16. protected readonly string _name;
  17. public BaseEnvironment()
  18. {
  19. _name = GetType().Name;
  20. }
  21. }
  22. /// <summary>
  23. /// General
  24. /// </summary>
  25. public class General : BaseEnvironment
  26. {
  27. public General() : base()
  28. {
  29. }
  30. public string LiveProtocol
  31. {
  32. get
  33. {
  34. return EnvironmentConfigManager.GetParammeter<StringParameter>(_name, "LiveProtocol").Value;
  35. }
  36. }
  37. /// <summary>
  38. /// General read live config
  39. /// </summary>
  40. public T LiveProtocolDetail<T>()
  41. {
  42. var t = default(T);
  43. if (LiveProtocol.ToLower() == "rtmp")
  44. {
  45. t = (T)Enum.Parse(typeof(T), EnvironmentConfigs.Rtmp.RTMPType);
  46. }
  47. else
  48. {
  49. t = (T)Enum.Parse(typeof(T), EnvironmentConfigs.Rtc.RTCType);
  50. }
  51. return t;
  52. }
  53. }
  54. /// <summary>
  55. /// RTMP
  56. /// </summary>
  57. public class Rtmp : BaseEnvironment
  58. {
  59. public Rtmp() : base()
  60. {
  61. }
  62. public string RTMPType
  63. {
  64. get
  65. {
  66. return EnvironmentConfigManager.GetParammeter<StringParameter>(_name, "RTMPType").Value;
  67. }
  68. }
  69. public string RTMPAppId
  70. {
  71. get
  72. {
  73. return EnvironmentConfigManager.GetParammeter<StringParameter>(_name, "RTMPAppId").Value;
  74. }
  75. }
  76. public string RTMPAppKey
  77. {
  78. get
  79. {
  80. return EnvironmentConfigManager.GetParammeter<StringParameter>(_name, "RTMPAppKey").Value;
  81. }
  82. }
  83. public string RTMPPlayUrl
  84. {
  85. get
  86. {
  87. return EnvironmentConfigManager.GetParammeter<StringParameter>(_name, "RTMPPlayUrl").Value;
  88. }
  89. }
  90. public string RTMPPushUrl
  91. {
  92. get
  93. {
  94. return EnvironmentConfigManager.GetParammeter<StringParameter>(_name, "RTMPPushUrl").Value;
  95. }
  96. }
  97. }
  98. /// <summary>
  99. /// RTC
  100. /// </summary>
  101. public class Rtc : BaseEnvironment
  102. {
  103. public Rtc() : base()
  104. {
  105. }
  106. public string RTCType
  107. {
  108. get
  109. {
  110. return EnvironmentConfigManager.GetParammeter<StringParameter>(_name, "RTCType").Value;
  111. }
  112. }
  113. public string AppId
  114. {
  115. get
  116. {
  117. return EnvironmentConfigManager.GetParammeter<StringParameter>(_name, "AppId").Value;
  118. }
  119. }
  120. public string RTCAppKey
  121. {
  122. get
  123. {
  124. return EnvironmentConfigManager.GetParammeter<StringParameter>(_name, "RTCAppKey").Value;
  125. }
  126. }
  127. public int RTCBizid
  128. {
  129. get
  130. {
  131. return EnvironmentConfigManager.GetParammeter<IntParameter>(_name, "RTCBizid").Value;
  132. }
  133. }
  134. public string RTCPlayUrl
  135. {
  136. get
  137. {
  138. return EnvironmentConfigManager.GetParammeter<StringParameter>(_name, "RTCPlayUrl").Value;
  139. }
  140. }
  141. public string RTCPushUrl
  142. {
  143. get
  144. {
  145. return EnvironmentConfigManager.GetParammeter<StringParameter>(_name, "RTCPushUrl").Value;
  146. }
  147. }
  148. public string RTCStartingRoomId
  149. {
  150. get
  151. {
  152. return EnvironmentConfigManager.GetParammeter<StringParameter>(_name, "RTCStartingRoomId").Value;
  153. }
  154. }
  155. }
  156. /// <summary>
  157. /// Storage
  158. /// </summary>
  159. public class Storage : BaseEnvironment
  160. {
  161. public Storage() : base()
  162. {
  163. }
  164. public int AutoSliceSizeForUpload
  165. {
  166. get
  167. {
  168. return EnvironmentConfigManager.GetParammeter<IntParameter>(_name, "AutoSliceSizeForUpload").Value;
  169. }
  170. }
  171. public int ManualDivisionForUpload
  172. {
  173. get
  174. {
  175. return EnvironmentConfigManager.GetParammeter<IntParameter>(_name, "ManualDivisionForUpload").Value;
  176. }
  177. }
  178. public string OtherNodes
  179. {
  180. get
  181. {
  182. return EnvironmentConfigManager.GetParammeter<StringParameter>(_name, "OtherNodes").Value;
  183. }
  184. }
  185. public string ServerHost
  186. {
  187. get
  188. {
  189. return EnvironmentConfigManager.GetParammeter<StringParameter>(_name, "ServerHost").Value;
  190. }
  191. }
  192. public string StorageServer
  193. {
  194. get
  195. {
  196. return EnvironmentConfigManager.GetParammeter<StringParameter>(_name, "StorageServer").Value;
  197. }
  198. }
  199. public string AppId
  200. {
  201. get
  202. {
  203. return EnvironmentConfigManager.GetParammeter<StringParameter>(_name, "AppId").Value;
  204. }
  205. }
  206. public string Sercret
  207. {
  208. get
  209. {
  210. return EnvironmentConfigManager.GetParammeter<StringParameter>(_name, "Sercret").Value;
  211. }
  212. }
  213. public string CFSServerUrl
  214. {
  215. get
  216. {
  217. return EnvironmentConfigManager.GetParammeter<StringParameter>(_name, "CFSServerUrl").Value;
  218. }
  219. }
  220. public string CDNServerUrl
  221. {
  222. get
  223. {
  224. return EnvironmentConfigManager.GetParammeter<StringParameter>(_name, "CDNServerUrl").Value;
  225. }
  226. }
  227. public string VCSStorageDisk
  228. {
  229. get
  230. {
  231. return EnvironmentConfigManager.GetParammeter<StringParameter>(_name, "VCSStorageDisk").Value;
  232. }
  233. }
  234. }
  235. /// <summary>
  236. /// Gateway
  237. /// </summary>
  238. public class Gateway : BaseEnvironment
  239. {
  240. public Gateway() : base()
  241. {
  242. }
  243. public string Host
  244. {
  245. get
  246. {
  247. return EnvironmentConfigManager.GetParammeter<StringParameter>(_name, "Host").Value;
  248. }
  249. }
  250. public string Domains
  251. {
  252. get
  253. {
  254. return EnvironmentConfigManager.GetParammeter<StringParameter>(_name, "Domains").Value;
  255. }
  256. }
  257. }
  258. }