atom_ftyp.cpp 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. MP4FtypAtom::MP4FtypAtom()
  23. : MP4Atom("ftyp")
  24. {
  25. MP4StringProperty* pProp = new MP4StringProperty("majorBrand");
  26. pProp->SetFixedLength(4);
  27. AddProperty(pProp); /* 0 */
  28. AddProperty( /* 1 */
  29. new MP4Integer32Property("minorVersion"));
  30. MP4Integer32Property* pCount =
  31. new MP4Integer32Property("compatibleBrandsCount");
  32. pCount->SetImplicit();
  33. AddProperty(pCount); /* 2 */
  34. MP4TableProperty* pTable =
  35. new MP4TableProperty("compatibleBrands", pCount);
  36. AddProperty(pTable); /* 3 */
  37. pProp = new MP4StringProperty("brand");
  38. pProp->SetFixedLength(4);
  39. pTable->AddProperty(pProp);
  40. }
  41. void MP4FtypAtom::Generate()
  42. {
  43. MP4Atom::Generate();
  44. ((MP4StringProperty*)m_pProperties[0])->SetValue("mp42");
  45. MP4StringProperty* pBrandProperty = (MP4StringProperty*)
  46. ((MP4TableProperty*)m_pProperties[3])->GetProperty(0);
  47. ASSERT(pBrandProperty);
  48. pBrandProperty->AddValue("mp42");
  49. pBrandProperty->AddValue("isom");
  50. ((MP4Integer32Property*)m_pProperties[2])->IncrementValue();
  51. ((MP4Integer32Property*)m_pProperties[2])->IncrementValue();
  52. }
  53. void MP4FtypAtom::Read()
  54. {
  55. // table entry count computed from atom size
  56. ((MP4Integer32Property*)m_pProperties[2])->SetReadOnly(false);
  57. ((MP4Integer32Property*)m_pProperties[2])->SetValue((m_size - 8) / 4);
  58. ((MP4Integer32Property*)m_pProperties[2])->SetReadOnly(true);
  59. MP4Atom::Read();
  60. }