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

多媒体编程

开发平台:

Visual C++

  1. /*****************************************************************
  2. |
  3. |    AP4 - Track Objects
  4. |
  5. |    Copyright 2002 Gilles Boccon-Gibod
  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. #ifndef _AP4_TRAK_H_
  29. #define _AP4_TRAK_H_
  30. /*----------------------------------------------------------------------
  31. |       includes
  32. +---------------------------------------------------------------------*/
  33. #include "Ap4.h"
  34. #include "Ap4Array.h"
  35. #include "Ap4SampleDescription.h"
  36. #include "Ap4SampleTable.h"
  37. /*----------------------------------------------------------------------
  38. |       forward declarations
  39. +---------------------------------------------------------------------*/
  40. class AP4_StblAtom;
  41. class AP4_ByteStream;
  42. class AP4_Sample;
  43. class AP4_DataBuffer;
  44. class AP4_TrakAtom;
  45. class AP4_MoovAtom;
  46. /*----------------------------------------------------------------------
  47. |       constants
  48. +---------------------------------------------------------------------*/
  49. const AP4_UI32 AP4_TRACK_DEFAULT_MOVIE_TIMESCALE = 1000;
  50. /*----------------------------------------------------------------------
  51. |       AP4_Track
  52. +---------------------------------------------------------------------*/
  53. class AP4_Track {
  54.  public:
  55.     // types
  56.     typedef enum {
  57.         TYPE_UNKNOWN,
  58.         TYPE_AUDIO,
  59.         TYPE_VIDEO,
  60.         TYPE_TEXT,
  61.         TYPE_HINT
  62.     } Type;
  63.     // methods
  64.     AP4_Track(Type             type,
  65.               AP4_SampleTable* sample_table,
  66.               AP4_UI32         track_id, 
  67.               AP4_UI32         movie_time_scale, // 0 = use default
  68.               AP4_UI32         media_time_scale,
  69.               AP4_UI32         media_duration,
  70.               const char*      language,
  71.               AP4_UI32         width,
  72.               AP4_UI32         height);
  73.     AP4_Track(AP4_TrakAtom&   atom, 
  74.               AP4_ByteStream& sample_stream,
  75.               AP4_UI32        movie_time_scale);
  76.     virtual ~AP4_Track();
  77.     AP4_Track::Type GetType() { return m_Type; }
  78.     AP4_UI32     GetDuration();
  79.     AP4_Duration GetDurationMs();
  80.     AP4_Cardinal GetSampleCount();
  81. AP4_Result   GetSample(AP4_Ordinal index, AP4_Sample& sample);
  82. AP4_Result   ReadSample(AP4_Ordinal     index, 
  83.                             AP4_Sample&     sample,
  84.                             AP4_DataBuffer& data);
  85.     AP4_Result   GetSampleIndexForTimeStampMs(AP4_TimeStamp ts, 
  86.                                               AP4_Ordinal& index);
  87.     AP4_SampleDescription* GetSampleDescription(AP4_Ordinal index);
  88.     AP4_UI32      GetId();
  89.     AP4_Result    SetId(AP4_UI32 track_id);
  90.     AP4_TrakAtom* GetTrakAtom() { return m_TrakAtom; }
  91.     AP4_Result    SetMovieTimeScale(AP4_UI32 time_scale);
  92.     AP4_UI32      GetMediaTimeScale();
  93. AP4_String    GetTrackName();
  94. AP4_String    GetTrackLanguage();
  95.  protected:
  96.     // members
  97.     AP4_TrakAtom*    m_TrakAtom;
  98.     bool             m_TrakAtomIsOwned;
  99.     Type             m_Type;
  100.     AP4_SampleTable* m_SampleTable;
  101.     bool             m_SampleTableIsOwned;
  102.     AP4_UI32         m_MovieTimeScale;
  103.     AP4_UI32         m_MediaTimeScale;
  104. };
  105. #endif // _AP4_TRAK_H_