DlnaManager.cs 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964
  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. Identification = new DeviceIdentification
  213. {
  214. ModelName = "Xbox 360"
  215. },
  216. TranscodingProfiles = new[]
  217. {
  218. new TranscodingProfile
  219. {
  220. Container = "mp3",
  221. Type = DlnaProfileType.Audio
  222. },
  223. new TranscodingProfile
  224. {
  225. Container = "ts",
  226. Type = DlnaProfileType.Video
  227. }
  228. },
  229. DirectPlayProfiles = new[]
  230. {
  231. new DirectPlayProfile
  232. {
  233. Containers = new[]{"mp3"},
  234. Type = DlnaProfileType.Audio
  235. },
  236. new DirectPlayProfile
  237. {
  238. Containers = new[]{"avi"},
  239. Type = DlnaProfileType.Video
  240. },
  241. new DirectPlayProfile
  242. {
  243. Containers = new[]{"mp4"},
  244. Type = DlnaProfileType.Video
  245. }
  246. },
  247. MediaProfiles = new[]
  248. {
  249. new MediaProfile
  250. {
  251. Container ="avi",
  252. MimeType = "video/avi",
  253. Type = DlnaProfileType.Video
  254. }
  255. }
  256. });
  257. list.Add(new DeviceProfile
  258. {
  259. Name = "Xbox One",
  260. ClientType = "DLNA",
  261. Identification = new DeviceIdentification
  262. {
  263. ModelName = "Xbox One",
  264. FriendlyName = "Xbox-SystemOS"
  265. },
  266. TranscodingProfiles = new[]
  267. {
  268. new TranscodingProfile
  269. {
  270. Container = "mp3",
  271. Type = DlnaProfileType.Audio
  272. },
  273. new TranscodingProfile
  274. {
  275. Container = "ts",
  276. Type = DlnaProfileType.Video
  277. }
  278. },
  279. DirectPlayProfiles = new[]
  280. {
  281. new DirectPlayProfile
  282. {
  283. Containers = new[]{"mp3"},
  284. Type = DlnaProfileType.Audio
  285. },
  286. new DirectPlayProfile
  287. {
  288. Containers = new[]{"avi"},
  289. Type = DlnaProfileType.Video
  290. }
  291. },
  292. MediaProfiles = new[]
  293. {
  294. new MediaProfile
  295. {
  296. Container ="avi",
  297. MimeType = "video/x-msvideo",
  298. Type = DlnaProfileType.Video
  299. }
  300. }
  301. });
  302. list.Add(new DeviceProfile
  303. {
  304. Name = "Sony Bravia (2012)",
  305. ClientType = "DLNA",
  306. Identification = new DeviceIdentification
  307. {
  308. FriendlyName = @"BRAVIA KDL-\d{2}[A-Z]X\d5(\d|G).*"
  309. },
  310. TranscodingProfiles = new[]
  311. {
  312. new TranscodingProfile
  313. {
  314. Container = "mp3",
  315. Type = DlnaProfileType.Audio
  316. },
  317. new TranscodingProfile
  318. {
  319. Container = "ts",
  320. Type = DlnaProfileType.Video
  321. }
  322. },
  323. DirectPlayProfiles = new[]
  324. {
  325. new DirectPlayProfile
  326. {
  327. Containers = new[]{"mp3"},
  328. Type = DlnaProfileType.Audio
  329. },
  330. new DirectPlayProfile
  331. {
  332. Containers = new[]{"avi"},
  333. Type = DlnaProfileType.Video
  334. },
  335. new DirectPlayProfile
  336. {
  337. Containers = new[]{"asf"},
  338. Type = DlnaProfileType.Audio
  339. }
  340. },
  341. MediaProfiles = new[]
  342. {
  343. new MediaProfile
  344. {
  345. Container ="avi",
  346. MimeType = "video/avi",
  347. Type = DlnaProfileType.Video
  348. },
  349. new MediaProfile
  350. {
  351. Container ="asf",
  352. MimeType = "video/x-ms-wmv",
  353. Type = DlnaProfileType.Audio
  354. }
  355. }
  356. });
  357. list.Add(new DeviceProfile
  358. {
  359. Name = "Sony Bravia (2013)",
  360. ClientType = "DLNA",
  361. Identification = new DeviceIdentification
  362. {
  363. FriendlyName = @"BRAVIA (KDL-\d{2}W[689]\d{2}A.*)|(KD-\d{2}X9\d{3}A.*)"
  364. },
  365. TranscodingProfiles = new[]
  366. {
  367. new TranscodingProfile
  368. {
  369. Container = "mp3",
  370. Type = DlnaProfileType.Audio
  371. },
  372. new TranscodingProfile
  373. {
  374. Container = "ts",
  375. Type = DlnaProfileType.Video
  376. }
  377. },
  378. DirectPlayProfiles = new[]
  379. {
  380. new DirectPlayProfile
  381. {
  382. Containers = new[]{"mp3"},
  383. Type = DlnaProfileType.Audio
  384. },
  385. new DirectPlayProfile
  386. {
  387. Containers = new[]{"wma"},
  388. Type = DlnaProfileType.Audio
  389. },
  390. new DirectPlayProfile
  391. {
  392. Containers = new[]{"avi"},
  393. Type = DlnaProfileType.Video
  394. },
  395. new DirectPlayProfile
  396. {
  397. Containers = new[]{"mp4"},
  398. Type = DlnaProfileType.Video
  399. }
  400. },
  401. MediaProfiles = new[]
  402. {
  403. new MediaProfile
  404. {
  405. Container ="avi",
  406. MimeType = "video/avi",
  407. Type = DlnaProfileType.Video
  408. },
  409. new MediaProfile
  410. {
  411. Container ="mp4",
  412. MimeType = "video/mp4",
  413. Type = DlnaProfileType.Video
  414. },
  415. new MediaProfile
  416. {
  417. Container ="ts",
  418. MimeType = "video/mpeg",
  419. Type = DlnaProfileType.Video
  420. },
  421. new MediaProfile
  422. {
  423. Container ="wma",
  424. MimeType = "video/x-ms-wma",
  425. Type = DlnaProfileType.Audio
  426. }
  427. }
  428. });
  429. list.Add(new DeviceProfile
  430. {
  431. //Panasonic Viera (2011|2012) Without AVI Support
  432. Name = "Panasonic Viera E/S/ST/VT (2011)",
  433. ClientType = "DLNA",
  434. Identification = new DeviceIdentification
  435. {
  436. FriendlyName = @"(VIERA (E|S)T?(3|5)0?.*)|(VIERA VT30.*)",
  437. Manufacturer = "Panasonic"
  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[]{"mkv"},
  462. Type = DlnaProfileType.Video
  463. }
  464. }
  465. });
  466. list.Add(new DeviceProfile
  467. {
  468. //Panasonic Viera (2011|2012) With AVI Support
  469. Name = "Panasonic Viera G/GT/DT/UT/VT (2011/2012)",
  470. ClientType = "DLNA",
  471. Identification = new DeviceIdentification
  472. {
  473. FriendlyName = @"(VIERA (G|D|U)T?(3|5)0?.*)|(VIERA VT50.*)",
  474. Manufacturer = "Panasonic"
  475. },
  476. TranscodingProfiles = new[]
  477. {
  478. new TranscodingProfile
  479. {
  480. Container = "mp3",
  481. Type = DlnaProfileType.Audio
  482. },
  483. new TranscodingProfile
  484. {
  485. Container = "ts",
  486. Type = DlnaProfileType.Video
  487. }
  488. },
  489. DirectPlayProfiles = new[]
  490. {
  491. new DirectPlayProfile
  492. {
  493. Containers = new[]{"mp3"},
  494. Type = DlnaProfileType.Audio
  495. },
  496. new DirectPlayProfile
  497. {
  498. Containers = new[]{"mkv"},
  499. Type = DlnaProfileType.Video
  500. },
  501. new DirectPlayProfile
  502. {
  503. Containers = new[]{"avi"},
  504. Type = DlnaProfileType.Video
  505. }
  506. },
  507. MediaProfiles = new[]
  508. {
  509. new MediaProfile
  510. {
  511. Container ="avi",
  512. MimeType = "video/divx",
  513. Type = DlnaProfileType.Video
  514. }
  515. }
  516. });
  517. list.Add(new DeviceProfile
  518. {
  519. Name = "Philips (2010-)",
  520. ClientType = "DLNA",
  521. Identification = new DeviceIdentification
  522. {
  523. FriendlyName = ".*PHILIPS.*",
  524. ModelName = "WD TV HD Live"
  525. },
  526. DirectPlayProfiles = new[]
  527. {
  528. new DirectPlayProfile
  529. {
  530. Containers = new[]{"mp3", "wma"},
  531. Type = DlnaProfileType.Audio
  532. },
  533. new DirectPlayProfile
  534. {
  535. Containers = new[]{"avi"},
  536. Type = DlnaProfileType.Video
  537. },
  538. new DirectPlayProfile
  539. {
  540. Containers = new[]{"mkv"},
  541. Type = DlnaProfileType.Video
  542. }
  543. },
  544. MediaProfiles = new[]
  545. {
  546. new MediaProfile
  547. {
  548. Container ="avi",
  549. MimeType = "video/avi",
  550. Type = DlnaProfileType.Video
  551. },
  552. new MediaProfile
  553. {
  554. Container ="mkv",
  555. MimeType = "video/x-matroska",
  556. Type = DlnaProfileType.Video
  557. }
  558. }
  559. });
  560. list.Add(new DeviceProfile
  561. {
  562. Name = "WDTV Live",
  563. ClientType = "DLNA",
  564. TimelineOffsetSeconds = 5,
  565. Identification = new DeviceIdentification
  566. {
  567. ModelName = "WD TV HD Live",
  568. Headers = new List<HttpHeaderInfo>
  569. {
  570. new HttpHeaderInfo{ Name="User-Agent", Value="alphanetworks", Match= HeaderMatchType.Substring},
  571. new HttpHeaderInfo{ Name="User-Agent", Value="ALPHA Networks", Match= HeaderMatchType.Substring}
  572. }
  573. },
  574. TranscodingProfiles = new[]
  575. {
  576. new TranscodingProfile
  577. {
  578. Container = "mp3",
  579. Type = DlnaProfileType.Audio,
  580. AudioCodec = "mp3"
  581. },
  582. new TranscodingProfile
  583. {
  584. Container = "ts",
  585. Type = DlnaProfileType.Video,
  586. VideoCodec = "h264",
  587. AudioCodec = "aac"
  588. },
  589. new TranscodingProfile
  590. {
  591. Container = "jpeg",
  592. Type = DlnaProfileType.Photo
  593. }
  594. },
  595. DirectPlayProfiles = new[]
  596. {
  597. new DirectPlayProfile
  598. {
  599. Containers = new[]{"avi"},
  600. Type = DlnaProfileType.Video,
  601. VideoCodec = "mpeg1video,mpeg2video,mpeg4,h264,vc1",
  602. AudioCodec = "ac3,dca,mp2,mp3,pcm"
  603. },
  604. new DirectPlayProfile
  605. {
  606. Containers = new[]{"mpeg"},
  607. Type = DlnaProfileType.Video,
  608. VideoCodec = "mpeg1video,mpeg2video",
  609. AudioCodec = "ac3,dca,mp2,mp3,pcm"
  610. },
  611. new DirectPlayProfile
  612. {
  613. Containers = new[]{"mkv"},
  614. Type = DlnaProfileType.Video,
  615. VideoCodec = "mpeg1video,mpeg2video,mpeg4,h264,vc1",
  616. AudioCodec = "ac3,dca,aac,mp2,mp3,pcm"
  617. },
  618. new DirectPlayProfile
  619. {
  620. Containers = new[]{"ts"},
  621. Type = DlnaProfileType.Video,
  622. VideoCodec = "mpeg1video,mpeg2video,h264,vc1",
  623. AudioCodec = "ac3,dca,mp2,mp3"
  624. },
  625. new DirectPlayProfile
  626. {
  627. Containers = new[]{"mp4", "mov"},
  628. Type = DlnaProfileType.Video,
  629. VideoCodec = "h264,mpeg4",
  630. AudioCodec = "ac3,aac,mp2,mp3"
  631. },
  632. new DirectPlayProfile
  633. {
  634. Containers = new[]{"asf"},
  635. Type = DlnaProfileType.Video,
  636. VideoCodec = "vc1",
  637. AudioCodec = "wmav2,wmapro"
  638. },
  639. new DirectPlayProfile
  640. {
  641. Containers = new[]{"asf"},
  642. Type = DlnaProfileType.Video,
  643. VideoCodec = "mpeg2video",
  644. AudioCodec = "mp2,ac3"
  645. },
  646. new DirectPlayProfile
  647. {
  648. Containers = new[]{"mp3"},
  649. AudioCodec = "mp2,mp3",
  650. Type = DlnaProfileType.Audio
  651. },
  652. new DirectPlayProfile
  653. {
  654. Containers = new[]{"mp4"},
  655. AudioCodec = "mp4",
  656. Type = DlnaProfileType.Audio
  657. },
  658. new DirectPlayProfile
  659. {
  660. Containers = new[]{"flac"},
  661. AudioCodec = "flac",
  662. Type = DlnaProfileType.Audio
  663. },
  664. new DirectPlayProfile
  665. {
  666. Containers = new[]{"asf"},
  667. AudioCodec = "wmav2,wmapro,wmavoice",
  668. Type = DlnaProfileType.Audio
  669. },
  670. new DirectPlayProfile
  671. {
  672. Containers = new[]{"ogg"},
  673. AudioCodec = "vorbis",
  674. Type = DlnaProfileType.Audio
  675. },
  676. new DirectPlayProfile
  677. {
  678. Type = DlnaProfileType.Photo,
  679. Containers = new[]{"jpeg", "png", "gif", "bmp", "tiff"},
  680. Conditions = new List<ProfileCondition>
  681. {
  682. new ProfileCondition{ Condition = ProfileConditionType.LessThanEqual, Property = ProfileConditionValue.Width, Value = "1920"},
  683. new ProfileCondition{ Condition = ProfileConditionType.LessThanEqual, Property = ProfileConditionValue.Height, Value = "1080"}
  684. }
  685. }
  686. },
  687. MediaProfiles = new[]
  688. {
  689. new MediaProfile
  690. {
  691. Container ="ts",
  692. OrgPn = "MPEG_TS_SD_NA",
  693. Type = DlnaProfileType.Video
  694. }
  695. },
  696. CodecProfiles = new[]
  697. {
  698. new CodecProfile
  699. {
  700. Type = CodecType.VideoCodec,
  701. Codec= "h264",
  702. Conditions = new List<ProfileCondition>
  703. {
  704. new ProfileCondition{ Condition = ProfileConditionType.LessThanEqual, Property = ProfileConditionValue.Width, Value = "1920"},
  705. new ProfileCondition{ Condition = ProfileConditionType.LessThanEqual, Property = ProfileConditionValue.Height, Value = "1080"},
  706. new ProfileCondition{ Condition = ProfileConditionType.LessThanEqual, Property = ProfileConditionValue.VideoLevel, Value = "41"}
  707. }
  708. },
  709. new CodecProfile
  710. {
  711. Type = CodecType.VideoAudioCodec,
  712. Codec= "aac",
  713. Conditions = new List<ProfileCondition>
  714. {
  715. new ProfileCondition{ Condition = ProfileConditionType.LessThanEqual, Property = ProfileConditionValue.AudioChannels, Value = "2"}
  716. }
  717. }
  718. }
  719. });
  720. list.Add(new DeviceProfile
  721. {
  722. // Linksys DMA2100us does not need any transcoding of the formats we support statically
  723. Name = "Linksys DMA2100",
  724. ClientType = "DLNA",
  725. Identification = new DeviceIdentification
  726. {
  727. ModelName = "DMA2100us"
  728. },
  729. DirectPlayProfiles = new[]
  730. {
  731. new DirectPlayProfile
  732. {
  733. Containers = new[]{"mp3", "flac", "m4a", "wma"},
  734. Type = DlnaProfileType.Audio
  735. },
  736. new DirectPlayProfile
  737. {
  738. Containers = new[]{"avi", "mp4", "mkv", "ts"},
  739. Type = DlnaProfileType.Video
  740. }
  741. }
  742. });
  743. list.Add(new DeviceProfile
  744. {
  745. Name = "Denon AVR",
  746. ClientType = "DLNA",
  747. Identification = new DeviceIdentification
  748. {
  749. FriendlyName = @"Denon:\[AVR:.*",
  750. Manufacturer = "Denon"
  751. },
  752. DirectPlayProfiles = new[]
  753. {
  754. new DirectPlayProfile
  755. {
  756. Containers = new[]{"mp3", "flac", "m4a", "wma"},
  757. Type = DlnaProfileType.Audio
  758. },
  759. }
  760. });
  761. foreach (var item in list)
  762. {
  763. //_xmlSerializer.SerializeToFile(item, "d:\\" + _fileSystem.GetValidFilename(item.Name));
  764. }
  765. return list;
  766. }
  767. public DeviceProfile GetDefaultProfile()
  768. {
  769. return new DeviceProfile
  770. {
  771. TranscodingProfiles = new[]
  772. {
  773. new TranscodingProfile
  774. {
  775. Container = "mp3",
  776. Type = DlnaProfileType.Audio
  777. },
  778. new TranscodingProfile
  779. {
  780. Container = "ts",
  781. Type = DlnaProfileType.Video
  782. }
  783. },
  784. DirectPlayProfiles = new[]
  785. {
  786. new DirectPlayProfile
  787. {
  788. Containers = new[]{"mp3", "wma"},
  789. Type = DlnaProfileType.Audio
  790. },
  791. new DirectPlayProfile
  792. {
  793. Containers = new[]{"avi", "mp4"},
  794. Type = DlnaProfileType.Video
  795. }
  796. }
  797. };
  798. }
  799. public DeviceProfile GetProfile(DeviceIdentification deviceInfo)
  800. {
  801. return GetProfiles().FirstOrDefault(i => IsMatch(deviceInfo, i.Identification)) ??
  802. GetDefaultProfile();
  803. }
  804. private bool IsMatch(DeviceIdentification deviceInfo, DeviceIdentification profileInfo)
  805. {
  806. if (!string.IsNullOrWhiteSpace(profileInfo.DeviceDescription))
  807. {
  808. if (!Regex.IsMatch(deviceInfo.DeviceDescription, profileInfo.DeviceDescription))
  809. return false;
  810. }
  811. if (!string.IsNullOrWhiteSpace(profileInfo.FriendlyName))
  812. {
  813. if (!Regex.IsMatch(deviceInfo.FriendlyName, profileInfo.FriendlyName))
  814. return false;
  815. }
  816. if (!string.IsNullOrWhiteSpace(profileInfo.Manufacturer))
  817. {
  818. if (!Regex.IsMatch(deviceInfo.Manufacturer, profileInfo.Manufacturer))
  819. return false;
  820. }
  821. if (!string.IsNullOrWhiteSpace(profileInfo.ManufacturerUrl))
  822. {
  823. if (!Regex.IsMatch(deviceInfo.ManufacturerUrl, profileInfo.ManufacturerUrl))
  824. return false;
  825. }
  826. if (!string.IsNullOrWhiteSpace(profileInfo.ModelDescription))
  827. {
  828. if (!Regex.IsMatch(deviceInfo.ModelDescription, profileInfo.ModelDescription))
  829. return false;
  830. }
  831. if (!string.IsNullOrWhiteSpace(profileInfo.ModelName))
  832. {
  833. if (!Regex.IsMatch(deviceInfo.ModelName, profileInfo.ModelName))
  834. return false;
  835. }
  836. if (!string.IsNullOrWhiteSpace(profileInfo.ModelNumber))
  837. {
  838. if (!Regex.IsMatch(deviceInfo.ModelNumber, profileInfo.ModelNumber))
  839. return false;
  840. }
  841. if (!string.IsNullOrWhiteSpace(profileInfo.ModelUrl))
  842. {
  843. if (!Regex.IsMatch(deviceInfo.ModelUrl, profileInfo.ModelUrl))
  844. return false;
  845. }
  846. if (!string.IsNullOrWhiteSpace(profileInfo.SerialNumber))
  847. {
  848. if (!Regex.IsMatch(deviceInfo.SerialNumber, profileInfo.SerialNumber))
  849. return false;
  850. }
  851. return true;
  852. }
  853. }
  854. }