atom_url.cpp 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. MP4UrlAtom::MP4UrlAtom(const char *type)
  23. : MP4Atom(type)
  24. {
  25. AddVersionAndFlags();
  26. AddProperty(new MP4StringProperty("location"));
  27. }
  28. void MP4UrlAtom::Read()
  29. {
  30. // read the version and flags properties
  31. ReadProperties(0, 2);
  32. // check if self-contained flag is set
  33. if (!(GetFlags() & 1)) {
  34. // if not then read url location
  35. ReadProperties(2);
  36. }
  37. Skip(); // to end of atom
  38. }
  39. void MP4UrlAtom::Write()
  40. {
  41. MP4StringProperty* pLocationProp =
  42. (MP4StringProperty*)m_pProperties[2];
  43. // if no url location has been set
  44. // then set self-contained flag
  45. // and don't attempt to write anything
  46. if (pLocationProp->GetValue() == NULL) {
  47. SetFlags(GetFlags() | 1);
  48. pLocationProp->SetImplicit(true);
  49. } else {
  50. SetFlags(GetFlags() & 0xFFFFFE);
  51. pLocationProp->SetImplicit(false);
  52. }
  53. // write atom as usual
  54. MP4Atom::Write();
  55. }