1
0

atom_d263.cpp 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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. * 3GPP features implementation is based on 3GPP's TS26.234-v5.60,
  19. * and was contributed by Ximpo Group Ltd.
  20. *
  21. * Portions created by Ximpo Group Ltd. are
  22. * Copyright (C) Ximpo Group Ltd. 2003, 2004. All Rights Reserved.
  23. *
  24. * Contributor(s):
  25. * Ximpo Group Ltd. [email protected]
  26. */
  27. #include "mp4common.h"
  28. #define H263_VENDOR 0x6d346970
  29. MP4D263Atom::MP4D263Atom()
  30. : MP4Atom("d263")
  31. {
  32. AddProperty( /* 0 */
  33. new MP4Integer32Property("vendor"));
  34. AddProperty( /* 1 */
  35. new MP4Integer8Property("decoderVersion"));
  36. AddProperty( /* 2 */
  37. new MP4Integer8Property("h263Level"));
  38. AddProperty( /* 3 */
  39. new MP4Integer8Property("h263Profile"));
  40. ExpectChildAtom("bitr", Optional, OnlyOne);
  41. }
  42. void MP4D263Atom::Generate()
  43. {
  44. MP4Atom::Generate();
  45. ((MP4Integer32Property*)m_pProperties[0])->SetValue(H263_VENDOR);
  46. ((MP4Integer8Property*)m_pProperties[1])->SetValue(1);
  47. }
  48. void MP4D263Atom::Write()
  49. {
  50. // Check whether we have valid values in the bitr atom
  51. // (if it exists, of course)
  52. MP4Atom* bitrAtom = FindAtomMP4("d263.bitr");
  53. if (bitrAtom) {
  54. u_int32_t avgBitrate;
  55. u_int32_t maxBitrate;
  56. MP4Integer32Property* pProp;
  57. bitrAtom->FindProperty("bitr.avgBitrate",
  58. (MP4Property**)&pProp,
  59. NULL);
  60. ASSERT(pProp);
  61. avgBitrate = pProp->GetValue();
  62. bitrAtom->FindProperty("bitr.maxBitrate",
  63. (MP4Property**)&pProp,
  64. NULL);
  65. ASSERT(pProp);
  66. maxBitrate = pProp->GetValue();
  67. if(!maxBitrate && !avgBitrate) {
  68. DeleteChildAtom(bitrAtom);
  69. }
  70. }
  71. MP4Atom::Write();
  72. }