kodi
DVDDemuxVobsub.h
1 /*
2  * Copyright (C) 2005-2018 Team Kodi
3  * This file is part of Kodi - https://kodi.tv
4  *
5  * SPDX-License-Identifier: GPL-2.0-or-later
6  * See LICENSES/README.md for more information.
7  */
8 
9 #pragma once
10 
11 #include "DVDDemux.h"
12 
13 #include <memory>
14 #include <string>
15 #include <vector>
16 
18 class CDVDInputStream;
19 class CDVDDemuxFFmpeg;
20 
21 class CDVDDemuxVobsub : public CDVDDemux
22 {
23 public:
25  ~CDVDDemuxVobsub() override;
26 
27  bool Open(const std::string& filename, int source, const std::string& subfilename);
28 
29  // implementation of CDVDDemux
30  bool Reset() override;
31  void Flush() override;
32  DemuxPacket* Read() override;
33  bool SeekTime(double time, bool backwards, double* startpts = NULL) override;
34  CDemuxStream* GetStream(int index) const override { return m_Streams[index]; }
35  std::vector<CDemuxStream*> GetStreams() const override;
36  int GetNrOfStreams() const override { return m_Streams.size(); }
37  std::string GetFileName() override { return m_Filename; }
38  void EnableStream(int id, bool enable) override;
39 
40 private:
41  class CStream
42  : public CDemuxStreamSubtitle
43  {
44  public:
45  explicit CStream(CDVDDemuxVobsub* parent) : m_parent(parent) {}
46 
47  bool m_discard = false;
48  CDVDDemuxVobsub* m_parent;
49  };
50 
51  typedef struct STimestamp
52  {
53  int64_t pos;
54  double pts;
55  int id;
56  } STimestamp;
57 
58  std::string m_Filename;
59  std::shared_ptr<CDVDInputStream> m_Input;
60  std::unique_ptr<CDVDDemuxFFmpeg> m_Demuxer;
61  std::vector<STimestamp> m_Timestamps;
62  std::vector<STimestamp>::iterator m_Timestamp;
63  std::vector<CStream*> m_Streams;
64  int m_source = -1;
65 
66  typedef struct SState
67  {
68  int id;
69  double delay;
70  std::string extra;
71  } SState;
72 
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 
81  bool ParseLangIdx(SState& state, std::string& line);
82  bool ParseDelay(SState& state, std::string& line);
83  bool ParseId(SState& state, std::string& line);
84  bool ParseExtra(SState& state, const std::string& line);
85  bool ParseTimestamp(SState& state, std::string& line);
86 };
Definition: DVDDemux.h:221
Definition: DVDOverlayCodecFFmpeg.h:21
Definition: DVDInputStream.h:50
Definition: DVDDemuxFFmpeg.h:80
Definition: DVDDemuxVobsub.h:21
Definition: DVDDemux.h:185
Definition: LibInputPointer.h:13
Definition: DVDDemux.h:72
Definition: DemuxPacket.h:22