CloudSyncProfile.cs 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  1. using System.Collections.Generic;
  2. using MediaBrowser.Model.Dlna;
  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";
  22. }
  23. var videoProfile = "high|main|baseline|constrained baseline";
  24. var videoLevel = "41";
  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. var maxAudioChannels = supportsAc3 || supportsDca ? "5" : "2";
  189. codecProfiles.Add(new CodecProfile
  190. {
  191. Type = CodecType.VideoAudio,
  192. Conditions = new[]
  193. {
  194. new ProfileCondition
  195. {
  196. Condition = ProfileConditionType.LessThanEqual,
  197. Property = ProfileConditionValue.AudioChannels,
  198. Value = maxAudioChannels,
  199. IsRequired = true
  200. },
  201. new ProfileCondition
  202. {
  203. Condition = ProfileConditionType.Equals,
  204. Property = ProfileConditionValue.IsSecondaryAudio,
  205. Value = "false",
  206. IsRequired = false
  207. }
  208. }
  209. });
  210. CodecProfiles = codecProfiles.ToArray();
  211. SubtitleProfiles = new[]
  212. {
  213. new SubtitleProfile
  214. {
  215. Format = "srt",
  216. Method = SubtitleDeliveryMethod.External
  217. },
  218. new SubtitleProfile
  219. {
  220. Format = "vtt",
  221. Method = SubtitleDeliveryMethod.External
  222. }
  223. };
  224. TranscodingProfiles = new[]
  225. {
  226. new TranscodingProfile
  227. {
  228. Container = "mp3",
  229. AudioCodec = "mp3",
  230. Type = DlnaProfileType.Audio,
  231. Context = EncodingContext.Static
  232. },
  233. new TranscodingProfile
  234. {
  235. Container = "mp4",
  236. Type = DlnaProfileType.Video,
  237. AudioCodec = "aac",
  238. VideoCodec = "h264",
  239. Context = EncodingContext.Static
  240. },
  241. new TranscodingProfile
  242. {
  243. Container = "jpeg",
  244. Type = DlnaProfileType.Photo,
  245. Context = EncodingContext.Static
  246. }
  247. };
  248. }
  249. }
  250. }