mp4descriptor.h 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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. #ifndef __MP4_DESCRIPTOR_INCLUDED__
  22. #define __MP4_DESCRIPTOR_INCLUDED__
  23. class MP4Descriptor {
  24. public:
  25. MP4Descriptor(u_int8_t tag = 0);
  26. virtual ~MP4Descriptor();
  27. u_int8_t GetTag() {
  28. return m_tag;
  29. }
  30. void SetTag(u_int8_t tag) {
  31. m_tag = tag;
  32. }
  33. void SetParentAtom(MP4Atom* pParentAtom) {
  34. m_pParentAtom = pParentAtom;
  35. for (u_int32_t i = 0; i < m_pProperties.Size(); i++) {
  36. m_pProperties[i]->SetParentAtom(pParentAtom);
  37. }
  38. }
  39. void AddProperty(MP4Property* pProperty);
  40. virtual void Generate();
  41. virtual void Read(MP4File* pFile);
  42. virtual void Write(MP4File* pFile);
  43. MP4Property* GetProperty(u_int32_t index) {
  44. return m_pProperties[index];
  45. }
  46. // use with extreme caution
  47. void SetProperty(u_int32_t index, MP4Property* pProperty) {
  48. m_pProperties[index] = pProperty;
  49. }
  50. bool FindProperty(const char* name,
  51. MP4Property** ppProperty, u_int32_t* pIndex = NULL) {
  52. return FindContainedProperty(name, ppProperty, pIndex);
  53. }
  54. void WriteToMemory(MP4File* pFile,
  55. u_int8_t** ppBytes, u_int64_t* pNumBytes);
  56. protected:
  57. void SetReadMutate(u_int32_t propIndex) {
  58. m_readMutatePoint = propIndex;
  59. }
  60. void ReadHeader(MP4File* pFile);
  61. void ReadProperties(MP4File* pFile,
  62. u_int32_t startIndex = 0, u_int32_t count = 0xFFFFFFFF);
  63. virtual void Mutate() {
  64. // default is a no-op
  65. };
  66. bool FindContainedProperty(const char* name,
  67. MP4Property** ppProperty, u_int32_t* pIndex);
  68. u_int8_t GetDepth();
  69. protected:
  70. MP4Atom* m_pParentAtom;
  71. u_int8_t m_tag;
  72. u_int64_t m_start;
  73. u_int32_t m_size;
  74. MP4PropertyArray m_pProperties;
  75. u_int32_t m_readMutatePoint;
  76. };
  77. #endif /* __MP4_DESCRIPTOR_INCLUDED__ */