CloudSyncProfile.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302
  1. using MediaBrowser.Model.Dlna;
  2. using System.Collections.Generic;
  3. namespace MediaBrowser.Server.Implementations.Sync
  4. {
  5. public class CloudSyncProfile : DeviceProfile
  6. {
  7. public CloudSyncProfile(bool supportsAc3, bool supportsDca)
  8. {
  9. Name = "Cloud Sync";
  10. MaxStreamingBitrate = 20000000;
  11. MaxStaticBitrate = 20000000;
  12. var mkvAudio = "aac,mp3";
  13. var mp4Audio = "aac";
  14. if (supportsAc3)
  15. {
  16. mkvAudio += ",ac3";
  17. mp4Audio += ",ac3";
  18. }
  19. if (supportsDca)
  20. {
  21. mkvAudio += ",dca,dts";
  22. }
  23. var videoProfile = "high|main|baseline|constrained baseline";
  24. var videoLevel = "40";
  25. DirectPlayProfiles = new[]
  26. {
  27. //new DirectPlayProfile
  28. //{
  29. // Container = "mkv",
  30. // VideoCodec = "h264,mpeg4",
  31. // AudioCodec = mkvAudio,
  32. // Type = DlnaProfileType.Video
  33. //},
  34. new DirectPlayProfile
  35. {
  36. Container = "mp4,mov,m4v",
  37. VideoCodec = "h264,mpeg4",
  38. AudioCodec = mp4Audio,
  39. Type = DlnaProfileType.Video
  40. },
  41. new DirectPlayProfile
  42. {
  43. Container = "mp3",
  44. Type = DlnaProfileType.Audio
  45. }
  46. };
  47. ContainerProfiles = new[]
  48. {
  49. new ContainerProfile
  50. {
  51. Type = DlnaProfileType.Video,
  52. Conditions = new []
  53. {
  54. new ProfileCondition
  55. {
  56. Condition = ProfileConditionType.NotEquals,
  57. Property = ProfileConditionValue.NumAudioStreams,
  58. Value = "0",
  59. IsRequired = false
  60. },
  61. new ProfileCondition
  62. {
  63. Condition = ProfileConditionType.EqualsAny,
  64. Property = ProfileConditionValue.NumVideoStreams,
  65. Value = "1",
  66. IsRequired = false
  67. }
  68. }
  69. }
  70. };
  71. var codecProfiles = new List<CodecProfile>
  72. {
  73. new CodecProfile
  74. {
  75. Type = CodecType.Video,
  76. Codec = "h264",
  77. Conditions = new []
  78. {
  79. new ProfileCondition
  80. {
  81. Condition = ProfileConditionType.LessThanEqual,
  82. Property = ProfileConditionValue.VideoBitDepth,
  83. Value = "8",
  84. IsRequired = false
  85. },
  86. new ProfileCondition
  87. {
  88. Condition = ProfileConditionType.LessThanEqual,
  89. Property = ProfileConditionValue.Width,
  90. Value = "1920",
  91. IsRequired = true
  92. },
  93. new ProfileCondition
  94. {
  95. Condition = ProfileConditionType.LessThanEqual,
  96. Property = ProfileConditionValue.Height,
  97. Value = "1080",
  98. IsRequired = true
  99. },
  100. new ProfileCondition
  101. {
  102. Condition = ProfileConditionType.LessThanEqual,
  103. Property = ProfileConditionValue.RefFrames,
  104. Value = "4",
  105. IsRequired = false
  106. },
  107. new ProfileCondition
  108. {
  109. Condition = ProfileConditionType.LessThanEqual,
  110. Property = ProfileConditionValue.VideoFramerate,
  111. Value = "30",
  112. IsRequired = false
  113. },
  114. new ProfileCondition
  115. {
  116. Condition = ProfileConditionType.Equals,
  117. Property = ProfileConditionValue.IsAnamorphic,
  118. Value = "false",
  119. IsRequired = false
  120. },
  121. new ProfileCondition
  122. {
  123. Condition = ProfileConditionType.LessThanEqual,
  124. Property = ProfileConditionValue.VideoLevel,
  125. Value = videoLevel,
  126. IsRequired = false
  127. },
  128. new ProfileCondition
  129. {
  130. Condition = ProfileConditionType.EqualsAny,
  131. Property = ProfileConditionValue.VideoProfile,
  132. Value = videoProfile,
  133. IsRequired = false
  134. }
  135. }
  136. },
  137. new CodecProfile
  138. {
  139. Type = CodecType.Video,
  140. Codec = "mpeg4",
  141. Conditions = new []
  142. {
  143. new ProfileCondition
  144. {
  145. Condition = ProfileConditionType.LessThanEqual,
  146. Property = ProfileConditionValue.VideoBitDepth,
  147. Value = "8",
  148. IsRequired = false
  149. },
  150. new ProfileCondition
  151. {
  152. Condition = ProfileConditionType.LessThanEqual,
  153. Property = ProfileConditionValue.Width,
  154. Value = "1920",
  155. IsRequired = true
  156. },
  157. new ProfileCondition
  158. {
  159. Condition = ProfileConditionType.LessThanEqual,
  160. Property = ProfileConditionValue.Height,
  161. Value = "1080",
  162. IsRequired = true
  163. },
  164. new ProfileCondition
  165. {
  166. Condition = ProfileConditionType.LessThanEqual,
  167. Property = ProfileConditionValue.RefFrames,
  168. Value = "4",
  169. IsRequired = false
  170. },
  171. new ProfileCondition
  172. {
  173. Condition = ProfileConditionType.LessThanEqual,
  174. Property = ProfileConditionValue.VideoFramerate,
  175. Value = "30",
  176. IsRequired = false
  177. },
  178. new ProfileCondition
  179. {
  180. Condition = ProfileConditionType.Equals,
  181. Property = ProfileConditionValue.IsAnamorphic,
  182. Value = "false",
  183. IsRequired = false
  184. }
  185. }
  186. }
  187. };
  188. codecProfiles.Add(new CodecProfile
  189. {
  190. Type = CodecType.VideoAudio,
  191. Codec = "ac3",
  192. Conditions = new[]
  193. {
  194. new ProfileCondition
  195. {
  196. Condition = ProfileConditionType.LessThanEqual,
  197. Property = ProfileConditionValue.AudioChannels,
  198. Value = "6",
  199. IsRequired = false
  200. },
  201. new ProfileCondition
  202. {
  203. Condition = ProfileConditionType.LessThanEqual,
  204. Property = ProfileConditionValue.AudioBitrate,
  205. Value = "320000",
  206. IsRequired = true
  207. },
  208. new ProfileCondition
  209. {
  210. Condition = ProfileConditionType.Equals,
  211. Property = ProfileConditionValue.IsSecondaryAudio,
  212. Value = "false",
  213. IsRequired = false
  214. }
  215. }
  216. });
  217. codecProfiles.Add(new CodecProfile
  218. {
  219. Type = CodecType.VideoAudio,
  220. Codec = "aac,mp3",
  221. Conditions = new[]
  222. {
  223. new ProfileCondition
  224. {
  225. Condition = ProfileConditionType.LessThanEqual,
  226. Property = ProfileConditionValue.AudioChannels,
  227. Value = "2",
  228. IsRequired = true
  229. },
  230. new ProfileCondition
  231. {
  232. Condition = ProfileConditionType.LessThanEqual,
  233. Property = ProfileConditionValue.AudioBitrate,
  234. Value = "320000",
  235. IsRequired = true
  236. },
  237. new ProfileCondition
  238. {
  239. Condition = ProfileConditionType.Equals,
  240. Property = ProfileConditionValue.IsSecondaryAudio,
  241. Value = "false",
  242. IsRequired = false
  243. }
  244. }
  245. });
  246. CodecProfiles = codecProfiles.ToArray();
  247. SubtitleProfiles = new[]
  248. {
  249. new SubtitleProfile
  250. {
  251. Format = "srt",
  252. Method = SubtitleDeliveryMethod.External
  253. },
  254. new SubtitleProfile
  255. {
  256. Format = "vtt",
  257. Method = SubtitleDeliveryMethod.External
  258. }
  259. };
  260. TranscodingProfiles = new[]
  261. {
  262. new TranscodingProfile
  263. {
  264. Container = "mp3",
  265. AudioCodec = "mp3",
  266. Type = DlnaProfileType.Audio,
  267. Context = EncodingContext.Static
  268. },
  269. new TranscodingProfile
  270. {
  271. Container = "mp4",
  272. Type = DlnaProfileType.Video,
  273. AudioCodec = "aac",
  274. VideoCodec = "h264",
  275. Context = EncodingContext.Static
  276. },
  277. new TranscodingProfile
  278. {
  279. Container = "jpeg",
  280. Type = DlnaProfileType.Photo,
  281. Context = EncodingContext.Static
  282. }
  283. };
  284. }
  285. }
  286. }