1
0

odcommands.cpp 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /*
  2. * The contents of this file are subject to the Mozilla Public
  3. * License Version 1.1 (the "License"); you may not use this file
  4. * except in compliance with the License. You may obtain a copy of
  5. * the License at http://www.mozilla.org/MPL/
  6. *
  7. * Software distributed under the License is distributed on an "AS
  8. * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
  9. * implied. See the License for the specific language governing
  10. * rights and limitations under the License.
  11. *
  12. * The Original Code is MPEG4IP.
  13. *
  14. * The Initial Developer of the Original Code is Cisco Systems Inc.
  15. * Portions created by Cisco Systems Inc. are
  16. * Copyright (C) Cisco Systems Inc. 2001. All Rights Reserved.
  17. *
  18. * Contributor(s):
  19. * Dave Mackie [email protected]
  20. */
  21. #include "mp4common.h"
  22. MP4ODUpdateDescriptor::MP4ODUpdateDescriptor()
  23. : MP4Descriptor(MP4ODUpdateODCommandTag)
  24. {
  25. // just a container for ObjectDescriptors
  26. AddProperty( /* 0 */
  27. new MP4DescriptorProperty(NULL,
  28. MP4FileODescrTag, 0, Required, Many));
  29. }
  30. MP4ODRemoveDescriptor::MP4ODRemoveDescriptor()
  31. : MP4Descriptor(MP4ODRemoveODCommandTag)
  32. {
  33. MP4Integer32Property* pCount =
  34. new MP4Integer32Property("entryCount");
  35. pCount->SetImplicit();
  36. AddProperty(pCount); /* 0 */
  37. MP4TableProperty* pTable =
  38. new MP4TableProperty("entries", pCount);
  39. AddProperty(pTable); /* 1 */
  40. pTable->AddProperty( /* 1, 0 */
  41. new MP4BitfieldProperty("objectDescriptorId", 10));
  42. }
  43. void MP4ODRemoveDescriptor::Read(MP4File* pFile)
  44. {
  45. // table entry count computed from descriptor size
  46. ((MP4Integer32Property*)m_pProperties[0])->SetReadOnly(false);
  47. ((MP4Integer32Property*)m_pProperties[0])->SetValue((m_size * 8) / 10);
  48. ((MP4Integer32Property*)m_pProperties[0])->SetReadOnly(true);
  49. MP4Descriptor::Read(pFile);
  50. }
  51. MP4ESUpdateDescriptor::MP4ESUpdateDescriptor()
  52. : MP4Descriptor(MP4ESUpdateODCommandTag)
  53. {
  54. AddProperty( /* 0 */
  55. new MP4BitfieldProperty("objectDescriptorId", 10));
  56. AddProperty( /* 1 */
  57. new MP4BitfieldProperty("pad", 6));
  58. AddProperty( /* 2 */
  59. new MP4DescriptorProperty("esIdRefs",
  60. MP4ESIDRefDescrTag, 0, Required, Many));
  61. }
  62. // LATER might be able to combine with ESUpdateDescriptor
  63. MP4ESRemoveDescriptor::MP4ESRemoveDescriptor()
  64. : MP4Descriptor(MP4ESRemoveODCommandTag)
  65. {
  66. AddProperty( /* 0 */
  67. new MP4BitfieldProperty("objectDescriptorId", 10));
  68. AddProperty( /* 1 */
  69. new MP4BitfieldProperty("pad", 6));
  70. AddProperty( /* 2 */
  71. new MP4DescriptorProperty("esIdRefs",
  72. MP4ESIDRefDescrTag, 0, Required, Many));
  73. }
  74. MP4Descriptor* CreateODCommand(u_int8_t tag)
  75. {
  76. MP4Descriptor* pDescriptor = NULL;
  77. switch (tag) {
  78. case MP4ODUpdateODCommandTag:
  79. pDescriptor = new MP4ODUpdateDescriptor();
  80. break;
  81. case MP4ODRemoveODCommandTag:
  82. pDescriptor = new MP4ODRemoveDescriptor();
  83. break;
  84. case MP4ESUpdateODCommandTag:
  85. pDescriptor = new MP4ESUpdateDescriptor();
  86. break;
  87. case MP4ESRemoveODCommandTag:
  88. pDescriptor = new MP4ESRemoveDescriptor();
  89. break;
  90. }
  91. return pDescriptor;
  92. }