PageRenderTime 19ms CodeModel.GetById 1ms app.highlight 13ms RepoModel.GetById 2ms app.codeStats 0ms

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