/xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxVobsub.h

http://github.com/xbmc/xbmc · C Header · 98 lines · 66 code · 13 blank · 19 comment · 3 complexity · 2b26b1233536889e05ccd23951dffd2f MD5 · raw file

  1. #pragma once
  2. /*
  3. * Copyright (C) 2005-2013 Team XBMC
  4. * http://xbmc.org
  5. *
  6. * This Program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2, or (at your option)
  9. * any later version.
  10. *
  11. * This Program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with XBMC; see the file COPYING. If not, see
  18. * <http://www.gnu.org/licenses/>.
  19. *
  20. */
  21. #include "DVDDemux.h"
  22. #include <memory>
  23. class CDVDOverlayCodecFFmpeg;
  24. class CDVDInputStream;
  25. class CDVDDemuxFFmpeg;
  26. class CDVDDemuxVobsub : public CDVDDemux
  27. {
  28. public:
  29. CDVDDemuxVobsub();
  30. virtual ~CDVDDemuxVobsub();
  31. virtual bool Open(const std::string& filename, const std::string& subfilename = "");
  32. virtual void Reset();
  33. virtual void Abort() {};
  34. virtual void Flush();
  35. virtual DemuxPacket* Read();
  36. virtual bool SeekTime(int time, bool backwords, double* startpts = NULL);
  37. virtual void SetSpeed(int speed) {}
  38. virtual CDemuxStream* GetStream(int index) { return m_Streams[index]; }
  39. virtual int GetNrOfStreams() { return m_Streams.size(); }
  40. virtual int GetStreamLength() { return 0; }
  41. virtual std::string GetFileName() { return m_Filename; }
  42. private:
  43. class CStream
  44. : public CDemuxStreamSubtitle
  45. {
  46. public:
  47. CStream(CDVDDemuxVobsub* parent)
  48. : m_discard(AVDISCARD_NONE), m_parent(parent)
  49. {}
  50. virtual void SetDiscard(AVDiscard discard) { m_discard = discard; }
  51. virtual AVDiscard GetDiscard() { return m_discard; }
  52. AVDiscard m_discard;
  53. CDVDDemuxVobsub* m_parent;
  54. };
  55. typedef struct STimestamp
  56. {
  57. int64_t pos;
  58. double pts;
  59. int id;
  60. } STimestamp;
  61. std::string m_Filename;
  62. std::auto_ptr<CDVDInputStream> m_Input;
  63. std::auto_ptr<CDVDDemuxFFmpeg> m_Demuxer;
  64. std::vector<STimestamp> m_Timestamps;
  65. std::vector<STimestamp>::iterator m_Timestamp;
  66. std::vector<CStream*> m_Streams;
  67. typedef struct SState
  68. {
  69. int id;
  70. double delay;
  71. std::string extra;
  72. } SState;
  73. struct sorter
  74. {
  75. bool operator()(const STimestamp &p1, const STimestamp &p2)
  76. {
  77. return p1.pts < p2.pts || (p1.pts == p2.pts && p1.id < p2.id);
  78. }
  79. };
  80. bool ParseLangIdx(SState& state, char* line);
  81. bool ParseDelay(SState& state, char* line);
  82. bool ParseId(SState& state, char* line);
  83. bool ParseExtra(SState& state, char* line);
  84. bool ParseTimestamp(SState& state, char* line);
  85. };