atom_avc1.cpp 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. 2004. All Rights Reserved.
  17. *
  18. * Contributor(s):
  19. * Bill May [email protected]
  20. */
  21. #include "mp4common.h"
  22. MP4Avc1Atom::MP4Avc1Atom()
  23. : MP4Atom("avc1")
  24. {
  25. AddReserved("reserved1", 6); /* 0 */
  26. AddProperty( /* 1 */
  27. new MP4Integer16Property("dataReferenceIndex"));
  28. AddReserved("reserved2", 16); /* 2 */
  29. AddProperty( /* 3 */
  30. new MP4Integer16Property("width"));
  31. AddProperty( /* 4 */
  32. new MP4Integer16Property("height"));
  33. AddReserved("reserved3", 14); /* 5 */
  34. MP4StringProperty* pProp =
  35. new MP4StringProperty("compressorName");
  36. pProp->SetFixedLength(32);
  37. pProp->SetValue("AVC Coding");
  38. AddProperty(pProp); /* 6 */
  39. AddReserved("reserved4", 4); /* 7 */
  40. ExpectChildAtom("avcC", Required, OnlyOne);
  41. ExpectChildAtom("btrt", Optional, OnlyOne);
  42. // for now ExpectChildAtom("m4ds", Optional, OnlyOne);
  43. }
  44. void MP4Avc1Atom::Generate()
  45. {
  46. MP4Atom::Generate();
  47. ((MP4Integer16Property*)m_pProperties[1])->SetValue(1);
  48. // property reserved3 has non-zero fixed values
  49. static u_int8_t reserved3[14] = {
  50. 0x00, 0x48, 0x00, 0x00,
  51. 0x00, 0x48, 0x00, 0x00,
  52. 0x00, 0x00, 0x00, 0x00,
  53. 0x00, 0x01,
  54. };
  55. m_pProperties[5]->SetReadOnly(false);
  56. ((MP4BytesProperty*)m_pProperties[5])->
  57. SetValue(reserved3, sizeof(reserved3));
  58. m_pProperties[5]->SetReadOnly(true);
  59. // property reserved4 has non-zero fixed values
  60. static u_int8_t reserved4[4] = {
  61. 0x00, 0x18, 0xFF, 0xFF,
  62. };
  63. m_pProperties[7]->SetReadOnly(false);
  64. ((MP4BytesProperty*)m_pProperties[7])->
  65. SetValue(reserved4, sizeof(reserved4));
  66. m_pProperties[7]->SetReadOnly(true);
  67. }