Ap4TrefTypeAtom.cpp
上传用户:xjjlds
上传日期:2015-12-05
资源大小:22823k
文件大小:3k
源码类别:

多媒体编程

开发平台:

Visual C++

  1. /*****************************************************************
  2. |
  3. |    AP4 - tref type Atoms 
  4. |
  5. |    Copyright 2002-2005 Gilles Boccon-Gibod & Julien Boeuf
  6. |
  7. |
  8. |    This file is part of Bento4/AP4 (MP4 Atom Processing Library).
  9. |
  10. |    Unless you have obtained Bento4 under a difference license,
  11. |    this version of Bento4 is Bento4|GPL.
  12. |    Bento4|GPL is free software; you can redistribute it and/or modify
  13. |    it under the terms of the GNU General Public License as published by
  14. |    the Free Software Foundation; either version 2, or (at your option)
  15. |    any later version.
  16. |
  17. |    Bento4|GPL is distributed in the hope that it will be useful,
  18. |    but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. |    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  20. |    GNU General Public License for more details.
  21. |
  22. |    You should have received a copy of the GNU General Public License
  23. |    along with Bento4|GPL; see the file COPYING.  If not, write to the
  24. |    Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
  25. |    02111-1307, USA.
  26. |
  27. ****************************************************************/
  28. /*----------------------------------------------------------------------
  29. |       includes
  30. +---------------------------------------------------------------------*/
  31. #include "Ap4TrefTypeAtom.h"
  32. /*----------------------------------------------------------------------
  33. |       AP4_TrefTypeAtom::AP4_TrefTypeAtom
  34. +---------------------------------------------------------------------*/
  35. AP4_TrefTypeAtom::AP4_TrefTypeAtom(AP4_Atom::Type type, 
  36.                                    AP4_Size size, 
  37.                                    AP4_ByteStream& stream) :
  38.     AP4_Atom(type, size, false, stream)
  39. {
  40.     AP4_Size data_size = size - 8; // size and atom type
  41.     
  42.     // read the track ids
  43.     while (data_size != 0) {
  44.         AP4_UI32 track_id;
  45.         stream.ReadUI32(track_id);
  46.         m_TrackIds.Append(track_id);
  47.         data_size -= 4;
  48.     }
  49. }
  50. /*----------------------------------------------------------------------
  51. |       AP4_TrefTypeAtom::WriteFields
  52. +---------------------------------------------------------------------*/
  53. AP4_Result
  54. AP4_TrefTypeAtom::WriteFields(AP4_ByteStream& stream)
  55. {
  56.     AP4_Result result = AP4_SUCCESS;
  57.     AP4_Size track_id_count = m_TrackIds.ItemCount();
  58.     for (AP4_Ordinal i=0; i<track_id_count; i++) {
  59.         result = stream.WriteUI32(m_TrackIds[i]);
  60.         if (AP4_FAILED(result)) return result;
  61.     }
  62.     return AP4_SUCCESS;
  63. }
  64. /*----------------------------------------------------------------------
  65. |       AP4_TrefTypeAtom::InspectFields
  66. +---------------------------------------------------------------------*/
  67. AP4_Result
  68. AP4_TrefTypeAtom::InspectFields(AP4_AtomInspector& inspector)
  69. {
  70.     inspector.AddField("track_id_count", m_TrackIds.ItemCount());
  71.     for (AP4_Ordinal i=0; i<m_TrackIds.ItemCount(); i++) {
  72.      inspector.AddField("track id ", m_TrackIds[i]);
  73.     }
  74.     return AP4_SUCCESS;
  75. }