DlnaManager.cs 40 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104
  1. using MediaBrowser.Common.Configuration;
  2. using MediaBrowser.Common.IO;
  3. using MediaBrowser.Controller.Dlna;
  4. using MediaBrowser.Model.Serialization;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. using System.Text.RegularExpressions;
  8. namespace MediaBrowser.Dlna
  9. {
  10. public class DlnaManager : IDlnaManager
  11. {
  12. private IApplicationPaths _appPaths;
  13. private readonly IXmlSerializer _xmlSerializer;
  14. private readonly IFileSystem _fileSystem;
  15. public DlnaManager(IXmlSerializer xmlSerializer, IFileSystem fileSystem)
  16. {
  17. _xmlSerializer = xmlSerializer;
  18. _fileSystem = fileSystem;
  19. //GetProfiles();
  20. }
  21. public IEnumerable<DeviceProfile> GetProfiles()
  22. {
  23. var list = new List<DeviceProfile>();
  24. list.Add(new DeviceProfile
  25. {
  26. Name = "Samsung TV (B Series)",
  27. ClientType = "DLNA",
  28. Identification = new DeviceIdentification
  29. {
  30. FriendlyName = "^TV$",
  31. ModelNumber = @"1\.0",
  32. ModelName = "Samsung DTV DMR"
  33. },
  34. TranscodingProfiles = new[]
  35. {
  36. new TranscodingProfile
  37. {
  38. Container = "mp3",
  39. Type = DlnaProfileType.Audio,
  40. },
  41. new TranscodingProfile
  42. {
  43. Container = "ts",
  44. Type = DlnaProfileType.Video
  45. }
  46. },
  47. DirectPlayProfiles = new[]
  48. {
  49. new DirectPlayProfile
  50. {
  51. Containers = new[]{"mp3"},
  52. Type = DlnaProfileType.Audio,
  53. },
  54. new DirectPlayProfile
  55. {
  56. Containers = new[]{"mkv"},
  57. Type = DlnaProfileType.Video
  58. },
  59. new DirectPlayProfile
  60. {
  61. Containers = new[]{"avi"},
  62. Type = DlnaProfileType.Video
  63. },
  64. new DirectPlayProfile
  65. {
  66. Containers = new[]{"mp4"},
  67. Type = DlnaProfileType.Video
  68. }
  69. },
  70. MediaProfiles = new[]
  71. {
  72. new MediaProfile
  73. {
  74. Container ="avi",
  75. MimeType = "video/x-msvideo",
  76. Type = DlnaProfileType.Video
  77. },
  78. new MediaProfile
  79. {
  80. Container ="mkv",
  81. MimeType = "video/x-mkv",
  82. Type = DlnaProfileType.Video
  83. }
  84. }
  85. });
  86. list.Add(new DeviceProfile
  87. {
  88. Name = "Samsung TV (E/F-series)",
  89. ClientType = "DLNA",
  90. Identification = new DeviceIdentification
  91. {
  92. FriendlyName = @"(^\[TV\][A-Z]{2}\d{2}(E|F)[A-Z]?\d{3,4}.*)|^\[TV\] Samsung|(^\[TV\]Samsung [A-Z]{2}\d{2}(E|F)[A-Z]?\d{3,4}.*)",
  93. ModelNumber = @"(1\.0)|(AllShare1\.0)"
  94. },
  95. TranscodingProfiles = new[]
  96. {
  97. new TranscodingProfile
  98. {
  99. Container = "mp3",
  100. Type = DlnaProfileType.Audio
  101. },
  102. new TranscodingProfile
  103. {
  104. Container = "ts",
  105. Type = DlnaProfileType.Video
  106. }
  107. },
  108. DirectPlayProfiles = new[]
  109. {
  110. new DirectPlayProfile
  111. {
  112. Containers = new[]{"mp3"},
  113. Type = DlnaProfileType.Audio
  114. },
  115. new DirectPlayProfile
  116. {
  117. Containers = new[]{"mkv"},
  118. Type = DlnaProfileType.Video
  119. },
  120. new DirectPlayProfile
  121. {
  122. Containers = new[]{"avi"},
  123. Type = DlnaProfileType.Video
  124. },
  125. new DirectPlayProfile
  126. {
  127. Containers = new[]{"mp4"},
  128. Type = DlnaProfileType.Video
  129. }
  130. },
  131. MediaProfiles = new[]
  132. {
  133. new MediaProfile
  134. {
  135. Container ="avi",
  136. MimeType = "video/x-msvideo",
  137. Type = DlnaProfileType.Video
  138. },
  139. new MediaProfile
  140. {
  141. Container ="mkv",
  142. MimeType = "video/x-mkv",
  143. Type = DlnaProfileType.Video
  144. }
  145. }
  146. });
  147. list.Add(new DeviceProfile
  148. {
  149. Name = "Samsung TV (C/D-series)",
  150. ClientType = "DLNA",
  151. Identification = new DeviceIdentification
  152. {
  153. FriendlyName = @"(^TV-\d{2}C\d{3}.*)|(^\[TV\][A-Z]{2}\d{2}(D)[A-Z]?\d{3,4}.*)|^\[TV\] Samsung",
  154. ModelNumber = @"(1\.0)|(AllShare1\.0)"
  155. },
  156. TranscodingProfiles = new[]
  157. {
  158. new TranscodingProfile
  159. {
  160. Container = "mp3",
  161. Type = DlnaProfileType.Audio
  162. },
  163. new TranscodingProfile
  164. {
  165. Container = "ts",
  166. Type = DlnaProfileType.Video
  167. }
  168. },
  169. DirectPlayProfiles = new[]
  170. {
  171. new DirectPlayProfile
  172. {
  173. Containers = new[]{"mp3"},
  174. Type = DlnaProfileType.Audio
  175. },
  176. new DirectPlayProfile
  177. {
  178. Containers = new[]{"mkv"},
  179. Type = DlnaProfileType.Video
  180. },
  181. new DirectPlayProfile
  182. {
  183. Containers = new[]{"avi"},
  184. Type = DlnaProfileType.Video
  185. },
  186. new DirectPlayProfile
  187. {
  188. Containers = new[]{"mp4"},
  189. Type = DlnaProfileType.Video
  190. }
  191. },
  192. MediaProfiles = new[]
  193. {
  194. new MediaProfile
  195. {
  196. Container ="avi",
  197. MimeType = "video/x-msvideo",
  198. Type = DlnaProfileType.Video
  199. },
  200. new MediaProfile
  201. {
  202. Container ="mkv",
  203. MimeType = "video/x-mkv",
  204. Type = DlnaProfileType.Video
  205. }
  206. }
  207. });
  208. list.Add(new DeviceProfile
  209. {
  210. Name = "Xbox 360",
  211. ClientType = "DLNA",
  212. ModelName = "Windows Media Player Sharing",
  213. ModelNumber = "12.0",
  214. ModelUrl = "http://www.microsoft.com/",
  215. Manufacturer = "Microsoft Corporation",
  216. ManufacturerUrl = "http://www.microsoft.com/",
  217. XDlnaDoc = "DMS-1.50",
  218. TimelineOffsetSeconds = 40,
  219. RequiresPlainFolders = true,
  220. RequiresPlainVideoItems = true,
  221. Identification = new DeviceIdentification
  222. {
  223. ModelName = "Xbox 360",
  224. Headers = new List<HttpHeaderInfo>
  225. {
  226. new HttpHeaderInfo{ Name="User-Agent", Value="Xbox", Match= HeaderMatchType.Substring},
  227. new HttpHeaderInfo{ Name="User-Agent", Value="Xenon", Match= HeaderMatchType.Substring}
  228. }
  229. },
  230. TranscodingProfiles = new[]
  231. {
  232. new TranscodingProfile
  233. {
  234. Container = "mp3",
  235. AudioCodec = "mp3",
  236. Type = DlnaProfileType.Audio
  237. },
  238. new TranscodingProfile
  239. {
  240. Container = "asf",
  241. VideoCodec = "wmv2",
  242. AudioCodec = "wmav2",
  243. Type = DlnaProfileType.Video,
  244. TranscodeSeekInfo = TranscodeSeekInfo.Bytes,
  245. EstimateContentLength = true,
  246. Settings = new List<TranscodingSetting>
  247. {
  248. new TranscodingSetting
  249. {
  250. Name = TranscodingSettingType.MaxAudioChannels,
  251. Value = "6"
  252. }
  253. }
  254. },
  255. new TranscodingProfile
  256. {
  257. Container = "jpeg",
  258. Type = DlnaProfileType.Photo
  259. }
  260. },
  261. DirectPlayProfiles = new[]
  262. {
  263. new DirectPlayProfile
  264. {
  265. Containers = new[]{"avi"},
  266. VideoCodec = "mpeg4",
  267. AudioCodec = "ac3,mp3",
  268. Type = DlnaProfileType.Video
  269. },
  270. new DirectPlayProfile
  271. {
  272. Containers = new[]{"avi"},
  273. VideoCodec = "h264",
  274. AudioCodec = "aac",
  275. Type = DlnaProfileType.Video
  276. },
  277. new DirectPlayProfile
  278. {
  279. Containers = new[]{"mp4", "mov"},
  280. VideoCodec = "h264,mpeg4",
  281. AudioCodec = "aac,ac3",
  282. Type = DlnaProfileType.Video,
  283. Conditions = new List<ProfileCondition>
  284. {
  285. new ProfileCondition{ Condition = ProfileConditionType.LessThanEqual, Property = ProfileConditionValue.Has64BitOffsets, Value = "false", IsRequired=false}
  286. }
  287. },
  288. new DirectPlayProfile
  289. {
  290. Containers = new[]{"asf"},
  291. VideoCodec = "wmv2,wmv3,vc1",
  292. AudioCodec = "wmav2,wmapro",
  293. Type = DlnaProfileType.Video
  294. },
  295. new DirectPlayProfile
  296. {
  297. Containers = new[]{"asf"},
  298. AudioCodec = "wmav2,wmapro,wmavoice",
  299. Type = DlnaProfileType.Audio
  300. },
  301. new DirectPlayProfile
  302. {
  303. Containers = new[]{"mp3"},
  304. AudioCodec = "mp3",
  305. Type = DlnaProfileType.Audio
  306. },
  307. new DirectPlayProfile
  308. {
  309. Containers = new[]{"jpeg"},
  310. Type = DlnaProfileType.Photo,
  311. Conditions = new List<ProfileCondition>
  312. {
  313. new ProfileCondition{ Condition = ProfileConditionType.LessThanEqual, Property = ProfileConditionValue.Width, Value = "1920"},
  314. new ProfileCondition{ Condition = ProfileConditionType.LessThanEqual, Property = ProfileConditionValue.Height, Value = "1080"}
  315. }
  316. }
  317. },
  318. MediaProfiles = new[]
  319. {
  320. new MediaProfile
  321. {
  322. Container ="avi",
  323. MimeType = "video/avi",
  324. Type = DlnaProfileType.Video
  325. }
  326. },
  327. CodecProfiles = new[]
  328. {
  329. new CodecProfile
  330. {
  331. Type = CodecType.VideoCodec,
  332. Codec = "mpeg4",
  333. Conditions = new List<ProfileCondition>
  334. {
  335. new ProfileCondition{ Condition = ProfileConditionType.LessThanEqual, Property = ProfileConditionValue.Width, Value = "1280"},
  336. new ProfileCondition{ Condition = ProfileConditionType.LessThanEqual, Property = ProfileConditionValue.Height, Value = "720"},
  337. new ProfileCondition{ Condition = ProfileConditionType.LessThanEqual, Property = ProfileConditionValue.VideoFramerate, Value = "30", IsRequired=false},
  338. new ProfileCondition{ Condition = ProfileConditionType.LessThanEqual, Property = ProfileConditionValue.VideoBitrate, Value = "5120000", IsRequired=false}
  339. }
  340. },
  341. new CodecProfile
  342. {
  343. Type = CodecType.VideoCodec,
  344. Codec = "h264",
  345. Conditions = new List<ProfileCondition>
  346. {
  347. new ProfileCondition{ Condition = ProfileConditionType.LessThanEqual, Property = ProfileConditionValue.Width, Value = "1920"},
  348. new ProfileCondition{ Condition = ProfileConditionType.LessThanEqual, Property = ProfileConditionValue.Height, Value = "1080"},
  349. new ProfileCondition{ Condition = ProfileConditionType.LessThanEqual, Property = ProfileConditionValue.VideoLevel, Value = "41", IsRequired=false},
  350. new ProfileCondition{ Condition = ProfileConditionType.LessThanEqual, Property = ProfileConditionValue.VideoBitrate, Value = "10240000", IsRequired=false}
  351. }
  352. },
  353. new CodecProfile
  354. {
  355. Type = CodecType.VideoCodec,
  356. Codec = "wmv2,wmv3,vc1",
  357. Conditions = new List<ProfileCondition>
  358. {
  359. new ProfileCondition{ Condition = ProfileConditionType.LessThanEqual, Property = ProfileConditionValue.Width, Value = "1920"},
  360. new ProfileCondition{ Condition = ProfileConditionType.LessThanEqual, Property = ProfileConditionValue.Height, Value = "1080"},
  361. new ProfileCondition{ Condition = ProfileConditionType.LessThanEqual, Property = ProfileConditionValue.VideoFramerate, Value = "30", IsRequired=false},
  362. new ProfileCondition{ Condition = ProfileConditionType.LessThanEqual, Property = ProfileConditionValue.VideoBitrate, Value = "15360000", IsRequired=false}
  363. }
  364. },
  365. new CodecProfile
  366. {
  367. Type = CodecType.VideoAudioCodec,
  368. Codec = "ac3,wmav2,wmapro",
  369. Conditions = new List<ProfileCondition>
  370. {
  371. new ProfileCondition{ Condition = ProfileConditionType.LessThanEqual, Property = ProfileConditionValue.AudioChannels, Value = "6", IsRequired=false}
  372. }
  373. },
  374. new CodecProfile
  375. {
  376. Type = CodecType.VideoAudioCodec,
  377. Codec = "aac",
  378. Conditions = new List<ProfileCondition>
  379. {
  380. new ProfileCondition{ Condition = ProfileConditionType.LessThanEqual, Property = ProfileConditionValue.AudioChannels, Value = "6", IsRequired=false},
  381. new ProfileCondition{ Condition = ProfileConditionType.Equals, Property = ProfileConditionValue.AudioProfile, Value = "lc", IsRequired=false}
  382. }
  383. }
  384. }
  385. });
  386. list.Add(new DeviceProfile
  387. {
  388. Name = "Xbox One",
  389. ClientType = "DLNA",
  390. Identification = new DeviceIdentification
  391. {
  392. ModelName = "Xbox One",
  393. FriendlyName = "Xbox-SystemOS"
  394. },
  395. TranscodingProfiles = new[]
  396. {
  397. new TranscodingProfile
  398. {
  399. Container = "mp3",
  400. Type = DlnaProfileType.Audio
  401. },
  402. new TranscodingProfile
  403. {
  404. Container = "ts",
  405. Type = DlnaProfileType.Video
  406. }
  407. },
  408. DirectPlayProfiles = new[]
  409. {
  410. new DirectPlayProfile
  411. {
  412. Containers = new[]{"mp3"},
  413. Type = DlnaProfileType.Audio
  414. },
  415. new DirectPlayProfile
  416. {
  417. Containers = new[]{"avi"},
  418. Type = DlnaProfileType.Video
  419. }
  420. },
  421. MediaProfiles = new[]
  422. {
  423. new MediaProfile
  424. {
  425. Container ="avi",
  426. MimeType = "video/x-msvideo",
  427. Type = DlnaProfileType.Video
  428. }
  429. }
  430. });
  431. list.Add(new DeviceProfile
  432. {
  433. Name = "Sony Bravia (2012)",
  434. ClientType = "DLNA",
  435. Identification = new DeviceIdentification
  436. {
  437. FriendlyName = @"BRAVIA KDL-\d{2}[A-Z]X\d5(\d|G).*"
  438. },
  439. TranscodingProfiles = new[]
  440. {
  441. new TranscodingProfile
  442. {
  443. Container = "mp3",
  444. Type = DlnaProfileType.Audio
  445. },
  446. new TranscodingProfile
  447. {
  448. Container = "ts",
  449. Type = DlnaProfileType.Video
  450. }
  451. },
  452. DirectPlayProfiles = new[]
  453. {
  454. new DirectPlayProfile
  455. {
  456. Containers = new[]{"mp3"},
  457. Type = DlnaProfileType.Audio
  458. },
  459. new DirectPlayProfile
  460. {
  461. Containers = new[]{"avi"},
  462. Type = DlnaProfileType.Video
  463. },
  464. new DirectPlayProfile
  465. {
  466. Containers = new[]{"asf"},
  467. Type = DlnaProfileType.Audio
  468. }
  469. },
  470. MediaProfiles = new[]
  471. {
  472. new MediaProfile
  473. {
  474. Container ="avi",
  475. MimeType = "video/avi",
  476. Type = DlnaProfileType.Video
  477. },
  478. new MediaProfile
  479. {
  480. Container ="asf",
  481. MimeType = "video/x-ms-wmv",
  482. Type = DlnaProfileType.Audio
  483. }
  484. }
  485. });
  486. list.Add(new DeviceProfile
  487. {
  488. Name = "Sony Bravia (2013)",
  489. ClientType = "DLNA",
  490. Identification = new DeviceIdentification
  491. {
  492. FriendlyName = @"BRAVIA (KDL-\d{2}W[689]\d{2}A.*)|(KD-\d{2}X9\d{3}A.*)"
  493. },
  494. TranscodingProfiles = new[]
  495. {
  496. new TranscodingProfile
  497. {
  498. Container = "mp3",
  499. Type = DlnaProfileType.Audio
  500. },
  501. new TranscodingProfile
  502. {
  503. Container = "ts",
  504. Type = DlnaProfileType.Video
  505. }
  506. },
  507. DirectPlayProfiles = new[]
  508. {
  509. new DirectPlayProfile
  510. {
  511. Containers = new[]{"mp3"},
  512. Type = DlnaProfileType.Audio
  513. },
  514. new DirectPlayProfile
  515. {
  516. Containers = new[]{"wma"},
  517. Type = DlnaProfileType.Audio
  518. },
  519. new DirectPlayProfile
  520. {
  521. Containers = new[]{"avi"},
  522. Type = DlnaProfileType.Video
  523. },
  524. new DirectPlayProfile
  525. {
  526. Containers = new[]{"mp4"},
  527. Type = DlnaProfileType.Video
  528. }
  529. },
  530. MediaProfiles = new[]
  531. {
  532. new MediaProfile
  533. {
  534. Container ="avi",
  535. MimeType = "video/avi",
  536. Type = DlnaProfileType.Video
  537. },
  538. new MediaProfile
  539. {
  540. Container ="mp4",
  541. MimeType = "video/mp4",
  542. Type = DlnaProfileType.Video
  543. },
  544. new MediaProfile
  545. {
  546. Container ="ts",
  547. MimeType = "video/mpeg",
  548. Type = DlnaProfileType.Video
  549. },
  550. new MediaProfile
  551. {
  552. Container ="wma",
  553. MimeType = "video/x-ms-wma",
  554. Type = DlnaProfileType.Audio
  555. }
  556. }
  557. });
  558. list.Add(new DeviceProfile
  559. {
  560. //Panasonic Viera (2011|2012) Without AVI Support
  561. Name = "Panasonic Viera E/S/ST/VT (2011)",
  562. ClientType = "DLNA",
  563. Identification = new DeviceIdentification
  564. {
  565. FriendlyName = @"(VIERA (E|S)T?(3|5)0?.*)|(VIERA VT30.*)",
  566. Manufacturer = "Panasonic"
  567. },
  568. TranscodingProfiles = new[]
  569. {
  570. new TranscodingProfile
  571. {
  572. Container = "mp3",
  573. Type = DlnaProfileType.Audio
  574. },
  575. new TranscodingProfile
  576. {
  577. Container = "ts",
  578. Type = DlnaProfileType.Video
  579. }
  580. },
  581. DirectPlayProfiles = new[]
  582. {
  583. new DirectPlayProfile
  584. {
  585. Containers = new[]{"mp3"},
  586. Type = DlnaProfileType.Audio
  587. },
  588. new DirectPlayProfile
  589. {
  590. Containers = new[]{"mkv"},
  591. Type = DlnaProfileType.Video
  592. }
  593. }
  594. });
  595. list.Add(new DeviceProfile
  596. {
  597. //Panasonic Viera (2011|2012) With AVI Support
  598. Name = "Panasonic Viera G/GT/DT/UT/VT (2011/2012)",
  599. ClientType = "DLNA",
  600. Identification = new DeviceIdentification
  601. {
  602. FriendlyName = @"(VIERA (G|D|U)T?(3|5)0?.*)|(VIERA VT50.*)",
  603. Manufacturer = "Panasonic"
  604. },
  605. TranscodingProfiles = new[]
  606. {
  607. new TranscodingProfile
  608. {
  609. Container = "mp3",
  610. Type = DlnaProfileType.Audio
  611. },
  612. new TranscodingProfile
  613. {
  614. Container = "ts",
  615. Type = DlnaProfileType.Video
  616. }
  617. },
  618. DirectPlayProfiles = new[]
  619. {
  620. new DirectPlayProfile
  621. {
  622. Containers = new[]{"mp3"},
  623. Type = DlnaProfileType.Audio
  624. },
  625. new DirectPlayProfile
  626. {
  627. Containers = new[]{"mkv"},
  628. Type = DlnaProfileType.Video
  629. },
  630. new DirectPlayProfile
  631. {
  632. Containers = new[]{"avi"},
  633. Type = DlnaProfileType.Video
  634. }
  635. },
  636. MediaProfiles = new[]
  637. {
  638. new MediaProfile
  639. {
  640. Container ="avi",
  641. MimeType = "video/divx",
  642. Type = DlnaProfileType.Video
  643. }
  644. }
  645. });
  646. list.Add(new DeviceProfile
  647. {
  648. Name = "Philips (2010-)",
  649. ClientType = "DLNA",
  650. Identification = new DeviceIdentification
  651. {
  652. FriendlyName = ".*PHILIPS.*",
  653. ModelName = "WD TV HD Live"
  654. },
  655. DirectPlayProfiles = new[]
  656. {
  657. new DirectPlayProfile
  658. {
  659. Containers = new[]{"mp3", "wma"},
  660. Type = DlnaProfileType.Audio
  661. },
  662. new DirectPlayProfile
  663. {
  664. Containers = new[]{"avi"},
  665. Type = DlnaProfileType.Video
  666. },
  667. new DirectPlayProfile
  668. {
  669. Containers = new[]{"mkv"},
  670. Type = DlnaProfileType.Video
  671. }
  672. },
  673. MediaProfiles = new[]
  674. {
  675. new MediaProfile
  676. {
  677. Container ="avi",
  678. MimeType = "video/avi",
  679. Type = DlnaProfileType.Video
  680. },
  681. new MediaProfile
  682. {
  683. Container ="mkv",
  684. MimeType = "video/x-matroska",
  685. Type = DlnaProfileType.Video
  686. }
  687. }
  688. });
  689. list.Add(new DeviceProfile
  690. {
  691. Name = "WDTV Live",
  692. ClientType = "DLNA",
  693. TimelineOffsetSeconds = 5,
  694. Identification = new DeviceIdentification
  695. {
  696. ModelName = "WD TV HD Live",
  697. Headers = new List<HttpHeaderInfo>
  698. {
  699. new HttpHeaderInfo{ Name="User-Agent", Value="alphanetworks", Match= HeaderMatchType.Substring},
  700. new HttpHeaderInfo{ Name="User-Agent", Value="ALPHA Networks", Match= HeaderMatchType.Substring}
  701. }
  702. },
  703. TranscodingProfiles = new[]
  704. {
  705. new TranscodingProfile
  706. {
  707. Container = "mp3",
  708. Type = DlnaProfileType.Audio,
  709. AudioCodec = "mp3"
  710. },
  711. new TranscodingProfile
  712. {
  713. Container = "ts",
  714. Type = DlnaProfileType.Video,
  715. VideoCodec = "h264",
  716. AudioCodec = "aac"
  717. },
  718. new TranscodingProfile
  719. {
  720. Container = "jpeg",
  721. Type = DlnaProfileType.Photo
  722. }
  723. },
  724. DirectPlayProfiles = new[]
  725. {
  726. new DirectPlayProfile
  727. {
  728. Containers = new[]{"avi"},
  729. Type = DlnaProfileType.Video,
  730. VideoCodec = "mpeg1video,mpeg2video,mpeg4,h264,vc1",
  731. AudioCodec = "ac3,dca,mp2,mp3,pcm"
  732. },
  733. new DirectPlayProfile
  734. {
  735. Containers = new[]{"mpeg"},
  736. Type = DlnaProfileType.Video,
  737. VideoCodec = "mpeg1video,mpeg2video",
  738. AudioCodec = "ac3,dca,mp2,mp3,pcm"
  739. },
  740. new DirectPlayProfile
  741. {
  742. Containers = new[]{"mkv"},
  743. Type = DlnaProfileType.Video,
  744. VideoCodec = "mpeg1video,mpeg2video,mpeg4,h264,vc1",
  745. AudioCodec = "ac3,dca,aac,mp2,mp3,pcm"
  746. },
  747. new DirectPlayProfile
  748. {
  749. Containers = new[]{"ts"},
  750. Type = DlnaProfileType.Video,
  751. VideoCodec = "mpeg1video,mpeg2video,h264,vc1",
  752. AudioCodec = "ac3,dca,mp2,mp3"
  753. },
  754. new DirectPlayProfile
  755. {
  756. Containers = new[]{"mp4", "mov"},
  757. Type = DlnaProfileType.Video,
  758. VideoCodec = "h264,mpeg4",
  759. AudioCodec = "ac3,aac,mp2,mp3"
  760. },
  761. new DirectPlayProfile
  762. {
  763. Containers = new[]{"asf"},
  764. Type = DlnaProfileType.Video,
  765. VideoCodec = "vc1",
  766. AudioCodec = "wmav2,wmapro"
  767. },
  768. new DirectPlayProfile
  769. {
  770. Containers = new[]{"asf"},
  771. Type = DlnaProfileType.Video,
  772. VideoCodec = "mpeg2video",
  773. AudioCodec = "mp2,ac3"
  774. },
  775. new DirectPlayProfile
  776. {
  777. Containers = new[]{"mp3"},
  778. AudioCodec = "mp2,mp3",
  779. Type = DlnaProfileType.Audio
  780. },
  781. new DirectPlayProfile
  782. {
  783. Containers = new[]{"mp4"},
  784. AudioCodec = "mp4",
  785. Type = DlnaProfileType.Audio
  786. },
  787. new DirectPlayProfile
  788. {
  789. Containers = new[]{"flac"},
  790. AudioCodec = "flac",
  791. Type = DlnaProfileType.Audio
  792. },
  793. new DirectPlayProfile
  794. {
  795. Containers = new[]{"asf"},
  796. AudioCodec = "wmav2,wmapro,wmavoice",
  797. Type = DlnaProfileType.Audio
  798. },
  799. new DirectPlayProfile
  800. {
  801. Containers = new[]{"ogg"},
  802. AudioCodec = "vorbis",
  803. Type = DlnaProfileType.Audio
  804. },
  805. new DirectPlayProfile
  806. {
  807. Type = DlnaProfileType.Photo,
  808. Containers = new[]{"jpeg", "png", "gif", "bmp", "tiff"},
  809. Conditions = new List<ProfileCondition>
  810. {
  811. new ProfileCondition{ Condition = ProfileConditionType.LessThanEqual, Property = ProfileConditionValue.Width, Value = "1920"},
  812. new ProfileCondition{ Condition = ProfileConditionType.LessThanEqual, Property = ProfileConditionValue.Height, Value = "1080"}
  813. }
  814. }
  815. },
  816. MediaProfiles = new[]
  817. {
  818. new MediaProfile
  819. {
  820. Container ="ts",
  821. OrgPn = "MPEG_TS_SD_NA",
  822. Type = DlnaProfileType.Video
  823. }
  824. },
  825. CodecProfiles = new[]
  826. {
  827. new CodecProfile
  828. {
  829. Type = CodecType.VideoCodec,
  830. Codec= "h264",
  831. Conditions = new List<ProfileCondition>
  832. {
  833. new ProfileCondition{ Condition = ProfileConditionType.LessThanEqual, Property = ProfileConditionValue.Width, Value = "1920"},
  834. new ProfileCondition{ Condition = ProfileConditionType.LessThanEqual, Property = ProfileConditionValue.Height, Value = "1080"},
  835. new ProfileCondition{ Condition = ProfileConditionType.LessThanEqual, Property = ProfileConditionValue.VideoLevel, Value = "41"}
  836. }
  837. },
  838. new CodecProfile
  839. {
  840. Type = CodecType.VideoAudioCodec,
  841. Codec= "aac",
  842. Conditions = new List<ProfileCondition>
  843. {
  844. new ProfileCondition{ Condition = ProfileConditionType.LessThanEqual, Property = ProfileConditionValue.AudioChannels, Value = "2"}
  845. }
  846. }
  847. }
  848. });
  849. list.Add(new DeviceProfile
  850. {
  851. // Linksys DMA2100us does not need any transcoding of the formats we support statically
  852. Name = "Linksys DMA2100",
  853. ClientType = "DLNA",
  854. Identification = new DeviceIdentification
  855. {
  856. ModelName = "DMA2100us"
  857. },
  858. DirectPlayProfiles = new[]
  859. {
  860. new DirectPlayProfile
  861. {
  862. Containers = new[]{"mp3", "flac", "m4a", "wma"},
  863. Type = DlnaProfileType.Audio
  864. },
  865. new DirectPlayProfile
  866. {
  867. Containers = new[]{"avi", "mp4", "mkv", "ts"},
  868. Type = DlnaProfileType.Video
  869. }
  870. }
  871. });
  872. list.Add(new DeviceProfile
  873. {
  874. Name = "Denon AVR",
  875. ClientType = "DLNA",
  876. Identification = new DeviceIdentification
  877. {
  878. FriendlyName = @"Denon:\[AVR:.*",
  879. Manufacturer = "Denon"
  880. },
  881. DirectPlayProfiles = new[]
  882. {
  883. new DirectPlayProfile
  884. {
  885. Containers = new[]{"mp3", "flac", "m4a", "wma"},
  886. Type = DlnaProfileType.Audio
  887. },
  888. }
  889. });
  890. foreach (var item in list)
  891. {
  892. //_xmlSerializer.SerializeToFile(item, "d:\\" + _fileSystem.GetValidFilename(item.Name));
  893. }
  894. return list;
  895. }
  896. public DeviceProfile GetDefaultProfile()
  897. {
  898. return new DeviceProfile
  899. {
  900. TranscodingProfiles = new[]
  901. {
  902. new TranscodingProfile
  903. {
  904. Container = "mp3",
  905. Type = DlnaProfileType.Audio
  906. },
  907. new TranscodingProfile
  908. {
  909. Container = "ts",
  910. Type = DlnaProfileType.Video
  911. }
  912. },
  913. DirectPlayProfiles = new[]
  914. {
  915. new DirectPlayProfile
  916. {
  917. Containers = new[]{"mp3", "wma"},
  918. Type = DlnaProfileType.Audio
  919. },
  920. new DirectPlayProfile
  921. {
  922. Containers = new[]{"avi", "mp4"},
  923. Type = DlnaProfileType.Video
  924. }
  925. }
  926. };
  927. }
  928. public DeviceProfile GetProfile(DeviceIdentification deviceInfo)
  929. {
  930. return GetProfiles().FirstOrDefault(i => IsMatch(deviceInfo, i.Identification)) ??
  931. GetDefaultProfile();
  932. }
  933. private bool IsMatch(DeviceIdentification deviceInfo, DeviceIdentification profileInfo)
  934. {
  935. if (!string.IsNullOrWhiteSpace(profileInfo.DeviceDescription))
  936. {
  937. if (!Regex.IsMatch(deviceInfo.DeviceDescription, profileInfo.DeviceDescription))
  938. return false;
  939. }
  940. if (!string.IsNullOrWhiteSpace(profileInfo.FriendlyName))
  941. {
  942. if (!Regex.IsMatch(deviceInfo.FriendlyName, profileInfo.FriendlyName))
  943. return false;
  944. }
  945. if (!string.IsNullOrWhiteSpace(profileInfo.Manufacturer))
  946. {
  947. if (!Regex.IsMatch(deviceInfo.Manufacturer, profileInfo.Manufacturer))
  948. return false;
  949. }
  950. if (!string.IsNullOrWhiteSpace(profileInfo.ManufacturerUrl))
  951. {
  952. if (!Regex.IsMatch(deviceInfo.ManufacturerUrl, profileInfo.ManufacturerUrl))
  953. return false;
  954. }
  955. if (!string.IsNullOrWhiteSpace(profileInfo.ModelDescription))
  956. {
  957. if (!Regex.IsMatch(deviceInfo.ModelDescription, profileInfo.ModelDescription))
  958. return false;
  959. }
  960. if (!string.IsNullOrWhiteSpace(profileInfo.ModelName))
  961. {
  962. if (!Regex.IsMatch(deviceInfo.ModelName, profileInfo.ModelName))
  963. return false;
  964. }
  965. if (!string.IsNullOrWhiteSpace(profileInfo.ModelNumber))
  966. {
  967. if (!Regex.IsMatch(deviceInfo.ModelNumber, profileInfo.ModelNumber))
  968. return false;
  969. }
  970. if (!string.IsNullOrWhiteSpace(profileInfo.ModelUrl))
  971. {
  972. if (!Regex.IsMatch(deviceInfo.ModelUrl, profileInfo.ModelUrl))
  973. return false;
  974. }
  975. if (!string.IsNullOrWhiteSpace(profileInfo.SerialNumber))
  976. {
  977. if (!Regex.IsMatch(deviceInfo.SerialNumber, profileInfo.SerialNumber))
  978. return false;
  979. }
  980. return true;
  981. }
  982. }
  983. }