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

多媒体编程

开发平台:

Visual C++

  1. /*****************************************************************
  2. |
  3. |    AP4 - Synthetic Sample Table
  4. |
  5. |    Copyright 2003-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 "Ap4.h"
  32. #include "Ap4Atom.h"
  33. #include "Ap4SyntheticSampleTable.h"
  34. /*----------------------------------------------------------------------
  35. |       AP4_SyntheticSampleTable::AP4_SyntheticSampleTable()
  36. +---------------------------------------------------------------------*/
  37. AP4_SyntheticSampleTable::AP4_SyntheticSampleTable()
  38. {
  39. }
  40. /*----------------------------------------------------------------------
  41. |       AP4_SyntheticSampleTable::~AP4_SyntheticSampleTable()
  42. +---------------------------------------------------------------------*/
  43. AP4_SyntheticSampleTable::~AP4_SyntheticSampleTable()
  44. {
  45.     m_SampleDescriptions.DeleteReferences();
  46. }
  47. /*----------------------------------------------------------------------
  48. |       AP4_SyntheticSampleTable::GetSample
  49. +---------------------------------------------------------------------*/
  50. AP4_Result
  51. AP4_SyntheticSampleTable::GetSample(AP4_Ordinal index, AP4_Sample& sample)
  52. {
  53.     if (index < m_Samples.ItemCount()) {
  54.         sample = m_Samples[index];
  55.         return AP4_SUCCESS;
  56.     } else {
  57.         return AP4_ERROR_OUT_OF_RANGE;
  58.     }
  59. }
  60. /*----------------------------------------------------------------------
  61. |       AP4_SyntheticSampleTable::GetSampleCount
  62. +---------------------------------------------------------------------*/
  63. AP4_Cardinal 
  64. AP4_SyntheticSampleTable::GetSampleCount()
  65. {
  66.     return m_Samples.ItemCount();
  67. }
  68. /*----------------------------------------------------------------------
  69. |       AP4_SyntheticSampleTable::GetSampleDescriptionCount
  70. +---------------------------------------------------------------------*/
  71. AP4_Cardinal 
  72. AP4_SyntheticSampleTable::GetSampleDescriptionCount()
  73. {
  74.     return m_SampleDescriptions.ItemCount();
  75. }
  76. /*----------------------------------------------------------------------
  77. |       AP4_SyntheticSampleTable::GetSampleDescription
  78. +---------------------------------------------------------------------*/
  79. AP4_SampleDescription* 
  80. AP4_SyntheticSampleTable::GetSampleDescription(AP4_Ordinal index)
  81. {
  82.     AP4_SampleDescription* description;
  83.     if (AP4_SUCCEEDED(m_SampleDescriptions.Get(index, description))) {
  84.         return description;
  85.     } else {
  86.         return NULL;
  87.     }
  88. }
  89. /*----------------------------------------------------------------------
  90. |       AP4_SyntheticSampleTable::AddSampleDescription
  91. +---------------------------------------------------------------------*/
  92. AP4_Result 
  93. AP4_SyntheticSampleTable::AddSampleDescription(AP4_SampleDescription* description)
  94. {
  95.     return m_SampleDescriptions.Add(description);
  96. }
  97. /*----------------------------------------------------------------------
  98. |       AP4_SyntheticSampleTable::AddSample
  99. +---------------------------------------------------------------------*/
  100. AP4_Result 
  101. AP4_SyntheticSampleTable::AddSample(AP4_ByteStream& data_stream,
  102.                                     AP4_Offset      offset,
  103.                                     AP4_Size        size,
  104.                                     AP4_Ordinal     description_index,
  105.                                     AP4_TimeStamp   cts,
  106.                                     AP4_TimeStamp   dts,
  107.                                     bool            sync)
  108. {
  109.     AP4_Sample sample(data_stream, offset, size, description_index, dts, cts-dts);
  110.     return m_Samples.Append(sample);
  111. }
  112. /*----------------------------------------------------------------------
  113. |       AP4_SyntheticSampleTable::GetSample
  114. +---------------------------------------------------------------------*/
  115. AP4_Result 
  116. AP4_SyntheticSampleTable::GetSampleIndexForTimeStamp(AP4_TimeStamp ts, 
  117.                                                      AP4_Ordinal& index)
  118. {
  119.     return AP4_ERROR_NOT_SUPPORTED_YET;
  120. }