MetaBox.cs 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.IO;
  6. namespace MatrixIO.IO.Bmff.Boxes
  7. {
  8. /// <summary>
  9. /// Meta Box ("meta")
  10. /// </summary>
  11. [Box("meta", "Meta Box")]
  12. public class MetaBox : FullBox, ISuperBox
  13. {
  14. public MetaBox() : base() {}
  15. public MetaBox(byte version, uint flags=0) : base(version, flags) {}
  16. public MetaBox(Stream stream) : base(stream) { }
  17. private IList<Box> _Children = Portability.CreateList<Box>();
  18. public IList<Box> Children
  19. {
  20. get { return _Children; }
  21. }
  22. public IEnumerator<Box> GetEnumerator()
  23. {
  24. return Children.GetEnumerator();
  25. }
  26. System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
  27. {
  28. return Children.GetEnumerator();
  29. }
  30. /* TODO: Support standard sub-boxes!
  31. public HandlerBox TheHandler
  32. {
  33. get
  34. {
  35. return (from c in _Children
  36. where c is HandlerBox
  37. select (HandlerBox)c).FirstOrDefault();
  38. }
  39. }
  40. public PrimaryItemBox PrimaryResource
  41. {
  42. get
  43. {
  44. return (from c in _Children
  45. where c is PrimaryItemBox
  46. select (PrimaryItemBox)c).FirstOrDefault();
  47. }
  48. }
  49. */
  50. public DataInformationBox FileLocations
  51. {
  52. get
  53. {
  54. return (from c in _Children
  55. where c is DataInformationBox
  56. select (DataInformationBox)c).FirstOrDefault();
  57. }
  58. }
  59. /*
  60. public ItemLocationBox ItemLocations
  61. {
  62. get
  63. {
  64. return (from c in _Children
  65. where c is ItemLocationBox
  66. select (ItemLocationBox)c).FirstOrDefault();
  67. }
  68. }
  69. */
  70. public ItemProtectionBox Protections
  71. {
  72. get
  73. {
  74. return (from c in _Children
  75. where c is ItemProtectionBox
  76. select (ItemProtectionBox)c).FirstOrDefault();
  77. }
  78. }
  79. /*
  80. public ItemInfoBox ItemInfos
  81. {
  82. get
  83. {
  84. return (from c in _Children
  85. where c is ItemInfonBox
  86. select (ItemInfoBox)c).FirstOrDefault();
  87. }
  88. }
  89. public IPMPControlBox IPMPControl
  90. {
  91. get
  92. {
  93. return (from c in _Children
  94. where c is IPMPControlBox
  95. select (IPMPControlBox)c).FirstOrDefault();
  96. }
  97. }
  98. */
  99. private Type[] StandardBoxes =
  100. {
  101. //typeof(HandlerBox),
  102. //typeof(PrimaryItemBox),
  103. typeof(DataInformationBox),
  104. //typeof(ItemLocationBox),
  105. typeof(ItemProtectionBox),
  106. //typeof(ItemInfoBox),
  107. //typeof(IPMPControlBox),
  108. };
  109. public IEnumerable<Box> OtherBoxes
  110. {
  111. get
  112. {
  113. return from c in _Children
  114. where !StandardBoxes.Contains(c.GetType())
  115. select c;
  116. }
  117. }
  118. }
  119. }