xbmc
DVDInputStreamNavigator.h
1 /*
2  * Copyright (C) 2005-2022 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 "../DVDCodecs/Overlay/DVDOverlaySpu.h"
12 #include "../IVideoPlayer.h"
13 #include "DVDDemuxers/DVDDemux.h"
14 #include "DVDInputStream.h"
15 #include "DVDInputStreamFile.h"
16 #include "DVDStateSerializer.h"
17 #include "DllDvdNav.h"
18 #include "cores/MenuType.h"
19 #include "utils/Geometry.h"
20 
21 #include <string>
22 
23 #define DVD_VIDEO_BLOCKSIZE DVD_VIDEO_LB_LEN // 2048 bytes
24 
25 #define NAVRESULT_NOP 0x00000001 // keep processing messages
26 #define NAVRESULT_DATA 0x00000002 // return data to demuxer
27 #define NAVRESULT_ERROR 0x00000003 // return read error to demuxer
28 #define NAVRESULT_HOLD 0x00000004 // return eof to demuxer
29 
30 #define LIBDVDNAV_BUTTON_NORMAL 0
31 #define LIBDVDNAV_BUTTON_CLICKED 1
32 
33 #define DVDNAV_ERROR -1
34 
35 class CDVDDemuxSPU;
36 class CSPUInfo;
37 class CDVDOverlayPicture;
38 
39 struct dvdnav_s;
40 
42  : public CDVDInputStream
47 {
48 public:
49  CDVDInputStreamNavigator(IVideoPlayer* player, const CFileItem& fileitem);
50  ~CDVDInputStreamNavigator() override;
51 
52  bool Open() override;
53  void Close() override;
54  int Read(uint8_t* buf, int buf_size) override;
55  int64_t Seek(int64_t offset, int whence) override;
56  int GetBlockSize() override { return DVDSTREAM_BLOCK_SIZE_DVD; }
57  bool IsEOF() override { return m_bEOF; }
58  int64_t GetLength() override { return 0; }
59  ENextStream NextStream() override ;
60 
61  void ActivateButton() override;
62  void SelectButton(int iButton) override;
63  void SkipStill() override;
64  void SkipWait();
65  void OnUp() override;
66  void OnDown() override;
67  void OnLeft() override;
68  void OnRight() override;
69 
73  bool OnMenu() override;
74 
75  void OnBack() override;
76  void OnNext() override;
77  void OnPrevious() override;
78  bool OnMouseMove(const CPoint &point) override;
79  bool OnMouseClick(const CPoint &point) override;
80 
81  int GetCurrentButton() override;
82  int GetTotalButtons() override;
83  bool GetCurrentButtonInfo(CDVDOverlaySpu& pOverlayPicture,
84  CDVDDemuxSPU* pSPU,
85  int iButtonType /* 0 = selection, 1 = action (clicked)*/);
86 
91  MenuType GetSupportedMenuType() override { return MenuType::NATIVE; }
92 
93  bool IsInMenu() override { return m_bInMenu; }
94  double GetTimeStampCorrection() override { return (double)(m_iVobUnitCorrection * 1000) / 90; }
95 
96  int GetActiveSubtitleStream();
97  int GetSubTitleStreamCount();
98  SubtitleStreamInfo GetSubtitleStreamInfo(const int iId);
99 
100  bool SetActiveSubtitleStream(int iId);
101  void EnableSubtitleStream(bool bEnable);
102  bool IsSubtitleStreamEnabled();
103 
104  int GetActiveAudioStream();
105  int GetAudioStreamCount();
106  int GetActiveAngle();
107  bool SetAngle(int angle);
108  bool SetActiveAudioStream(int iId);
109  AudioStreamInfo GetAudioStreamInfo(const int iId);
110 
111  bool GetState(std::string &xmlstate) override;
112  bool SetState(const std::string &xmlstate) override;
113 
114  int GetChapter() override { return m_iPart; } // the current part in the current title
115  int GetChapterCount() override { return m_iPartCount; } // the number of parts in the current title
116  void GetChapterName(std::string& name, int idx=-1) override {};
117  int64_t GetChapterPos(int ch=-1) override;
118  bool SeekChapter(int iChapter) override;
119 
120  CDVDInputStream::IDisplayTime* GetIDisplayTime() override { return this; }
121  int GetTotalTime() override; // the total time in milli seconds
122  int GetTime() override; // the current position in milli seconds
123 
124  float GetVideoAspectRatio();
125 
126  CDVDInputStream::IPosTime* GetIPosTime() override { return this; }
127  bool PosTime(int iTimeInMsec) override; //seek within current pg(c)
128 
129  std::string GetDVDTitleString();
130 
136  std::string GetDVDVolIdString();
137 
138  std::string GetDVDSerialString();
139 
140  void CheckButtons();
141 
142  VideoStreamInfo GetVideoStreamInfo();
143 
144 protected:
145 
146  int ProcessBlock(uint8_t* buffer, int* read);
147 
148  static void SetAudioStreamName(AudioStreamInfo &info, const audio_attr_t &audio_attributes);
149  static void SetSubtitleStreamName(SubtitleStreamInfo &info, const subp_attr_t &subp_attributes);
150 
151  int GetAngleCount();
152  void GetVideoResolution(uint32_t * width, uint32_t * height);
153 
158  bool FillDVDState(DVDState& dvdstate);
159 
160  DllDvdNav m_dll;
161  bool m_bCheckButtons;
162  bool m_bEOF;
163 
164  int m_holdmode;
165 
166  int m_iTotalTime;
167  int m_iTime;
168  int64_t m_iCellStart; // start time of current cell in pts units (90khz clock)
169 
170  bool m_bInMenu;
171 
172  int64_t m_iVobUnitStart;
173  int64_t m_iVobUnitStop;
174  int64_t m_iVobUnitCorrection;
175 
176  int m_iTitleCount;
177  int m_iTitle;
178 
179  int m_iPartCount;
180  int m_iPart;
181 
182  struct dvdnav_s* m_dvdnav;
183  dvdnav_stream_cb m_dvdnav_stream_cb;
184  std::unique_ptr<CDVDInputStreamFile> m_pstream;
185 
186  IVideoPlayer* m_pVideoPlayer;
187 
188  uint8_t m_lastblock[DVD_VIDEO_BLOCKSIZE];
189  int m_lastevent;
190 
191  std::map<int, std::map<int, int64_t>> m_mapTitleChapters;
192 
195 };
196 
Definition: IVideoPlayer.h:28
Definition: StreamInfo.h:65
Pod structure which represents the current dvd state with respect to dvdnav properties.
Definition: DVDStateSerializer.h:16
bool FillDVDState(DVDState &dvdstate)
Provided a pod DVDState struct, fill it with the current dvdnav state.
Definition: DVDInputStreamNavigator.cpp:1314
Definition: DVDInputStream.h:50
Definition: DllDvdNav.h:123
bool OnMenu() override
Open the Menu.
Definition: DVDInputStreamNavigator.cpp:821
Definition: DVDInputStream.h:54
MenuType GetSupportedMenuType() override
Get the supported menu type.
Definition: DVDInputStreamNavigator.h:91
Definition: StreamInfo.h:55
Definition: DVDInputStream.h:83
CDVDStateSerializer m_dvdStateSerializer
Definition: DVDInputStreamNavigator.h:194
std::string GetDVDVolIdString()
Get the DVD volume ID string. Alternative to the dvd title (since some DVD authors even forget to set...
Definition: DVDInputStreamNavigator.cpp:1417
Definition: DVDDemuxSPU.h:30
Definition: StreamInfo.h:62
bool Open() override
Definition: DVDInputStreamNavigator.cpp:99
Definition: DVDInputStream.h:94
Definition: DVDInputStreamNavigator.h:41
Definition: dvd_reader.h:81
Definition: DVDInputStream.h:76
Auxiliar class to serialize/deserialize the dvd state (into/from XML)
Definition: DVDStateSerializer.h:36
Definition: DVDOverlaySpu.h:16
Represents a file on a share.
Definition: FileItem.h:102