kodi
DVDOverlayCodec.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 "cores/VideoPlayer/DVDCodecs/Overlay/DVDOverlay.h"
12 #include "cores/VideoPlayer/DVDDemuxers/DVDDemux.h"
13 
14 #include <string>
15 
16 #include "PlatformDefs.h"
17 
18 // VC_ messages, messages can be combined
19 enum class OverlayMessage
20 {
21  // an error occurred, no other messages will be returned
22  OC_ERROR = 0x00000001,
23 
24  // the decoder needs more data
25  OC_BUFFER = 0x00000002,
26 
27  // the decoder decoded an overlay, call Decode(NULL, 0) again to parse the rest of the data
28  OC_OVERLAY = 0x00000004,
29 
30  // the decoder has decoded the packet, no overlay will be provided because the previous one is still valid
31  OC_DONE = 0x00000008,
32 };
33 
34 class CDVDOverlay;
35 class CDVDStreamInfo;
36 class CDVDCodecOption;
37 class CDVDCodecOptions;
38 
40 {
41 public:
42 
43  explicit CDVDOverlayCodec(const char* name) : m_codecName(name) {}
44 
45  virtual ~CDVDOverlayCodec() = default;
46 
47  /*
48  * Open the decoder, returns true on success
49  */
50  virtual bool Open(CDVDStreamInfo &hints, CDVDCodecOptions &options) = 0;
51 
52  /*
53  * returns one or a combination of VC_ messages
54  * pData and iSize can be NULL, this means we should flush the rest of the data.
55  */
56  virtual OverlayMessage Decode(DemuxPacket* pPacket) = 0;
57 
58  /*
59  * Reset the decoder.
60  * Should be the same as calling Dispose and Open after each other
61  */
62  virtual void Reset() = 0;
63 
64  /*
65  * Flush the current working packet
66  * This may leave the internal state intact
67  */
68  virtual void Flush() = 0;
69 
70  /*
71  * returns a valid overlay or NULL
72  * the data is valid until the next Decode call
73  */
74  virtual std::shared_ptr<CDVDOverlay> GetOverlay() = 0;
75 
76  /*
77  * return codecs name
78  */
79  const std::string& GetName() const { return m_codecName; }
80 
81 protected:
82  /*
83  * \brief Adapts startTime, stopTIme from the subtitle stream (which is relative to stream pts)
84  * so that it returns the absolute start and stop timestamps.
85  */
86  static void GetAbsoluteTimes(double& starttime, double& stoptime, DemuxPacket* pkt);
87 
89  {
90  double m_chapterStartTime;
91  };
92 
93 private:
94  std::string m_codecName;
95 };
Definition: DVDStreamInfo.h:25
Definition: DVDCodecs.h:23
Definition: DVDOverlayCodec.h:39
Definition: DVDOverlayCodec.h:88
Definition: DemuxPacket.h:22
Definition: DVDCodecs.h:15
Definition: DVDOverlay.h:27