1
0

atom_meta.cpp 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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. * M. Bakker mbakker at nero.com
  20. *
  21. * Apple iTunes META data
  22. */
  23. #include "mp4common.h"
  24. MP4Meta1Atom::MP4Meta1Atom(const char *name)
  25. : MP4Atom(name)
  26. {
  27. AddVersionAndFlags(); /* 0, 1 */
  28. AddProperty(new MP4BytesProperty("metadata")); /* 2 */
  29. }
  30. void MP4Meta1Atom::Read()
  31. {
  32. // calculate size of the metadata from the atom size
  33. ((MP4BytesProperty*)m_pProperties[2])->SetValueSize(m_size - 4);
  34. MP4Atom::Read();
  35. }
  36. MP4DataAtom::MP4DataAtom()
  37. : MP4Atom("data")
  38. {
  39. AddVersionAndFlags(); /* 0, 1 */
  40. AddReserved("reserved2", 4); /* 2 */
  41. AddProperty(
  42. new MP4BytesProperty("metadata")); /* 3 */
  43. }
  44. void MP4DataAtom::Read()
  45. {
  46. // calculate size of the metadata from the atom size
  47. ((MP4BytesProperty*)m_pProperties[3])->SetValueSize(m_size - 8);
  48. MP4Atom::Read();
  49. }
  50. // MP4Meta2Atom is for \251nam and \251cmt flags, which appear differently
  51. // in .mov and in itunes file. In .movs, they appear under udata, in
  52. // itunes, they appear under ilst.
  53. MP4Meta2Atom::MP4Meta2Atom (const char *name) : MP4Atom(name)
  54. {
  55. }
  56. void MP4Meta2Atom::Read ()
  57. {
  58. MP4Atom *parent = GetParentAtom();
  59. if (ATOMID(parent->GetType()) == ATOMID("udta")) {
  60. // add data property
  61. AddReserved("reserved2", 4); /* 0 */
  62. AddProperty(
  63. new MP4BytesProperty("metadata")); /* 1 */
  64. ((MP4BytesProperty*)m_pProperties[1])->SetValueSize(m_size - 4);
  65. } else {
  66. ExpectChildAtom("data", Required, OnlyOne);
  67. }
  68. MP4Atom::Read();
  69. }
  70. MP4Meta3Atom::MP4Meta3Atom (const char *name) : MP4Atom(name)
  71. {
  72. // add data property
  73. AddReserved("reserved2", 4); /* 0 */
  74. AddProperty(new MP4Integer16Property("language"));
  75. MP4StringProperty *strProp = new MP4StringProperty("metadata");
  76. strProp->SetUnicode(true);
  77. AddProperty(strProp); /* 3 */
  78. }
  79. void MP4Meta3Atom::Read ()
  80. {
  81. MP4Atom::Read();
  82. }
  83. MP4Meta4Atom::MP4Meta4Atom (const char *name) : MP4Atom(name)
  84. {
  85. // add data property
  86. AddReserved("reserved2", 4); /* 0 */
  87. AddProperty(new MP4Integer16Property("metadata")); /* 1 */
  88. }
  89. void MP4Meta4Atom::Read ()
  90. {
  91. MP4Atom::Read();
  92. }