[cosmetics] update date in GPL header
[vuplus_xbmc] / xbmc / cores / dvdplayer / DVDInputStreams / DVDInputStreamNavigator.h
1 #pragma once
2
3 /*
4  *      Copyright (C) 2005-2013 Team XBMC
5  *      http://www.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 "DVDInputStream.h"
24 #include "../IDVDPlayer.h"
25 #include "../DVDCodecs/Overlay/DVDOverlaySpu.h"
26 #include <string>
27 #include "guilib/Geometry.h"
28
29 #include "DllDvdNav.h"
30
31 #define DVD_VIDEO_BLOCKSIZE         DVD_VIDEO_LB_LEN // 2048 bytes
32
33 #define NAVRESULT_NOP               0x00000001 // keep processing messages
34 #define NAVRESULT_DATA              0x00000002 // return data to demuxer
35 #define NAVRESULT_ERROR             0x00000003 // return read error to demuxer
36 #define NAVRESULT_HOLD              0x00000004 // return eof to demuxer
37
38 #define LIBDVDNAV_BUTTON_NORMAL 0
39 #define LIBDVDNAV_BUTTON_CLICKED 1
40
41 class CDVDDemuxSPU;
42 class CSPUInfo;
43 class CDVDOverlayPicture;
44
45 struct dvdnav_s;
46
47 class DVDNavResult
48 {
49 public:
50   DVDNavResult(){};
51   DVDNavResult(void* p, int t) { pData = p; type = t; };
52   void* pData;
53   int type;
54 };
55
56 class CDVDInputStreamNavigator
57   : public CDVDInputStream
58   , public CDVDInputStream::IDisplayTime
59   , public CDVDInputStream::IChapter
60   , public CDVDInputStream::ISeekTime
61   , public CDVDInputStream::IMenus
62 {
63 public:
64   CDVDInputStreamNavigator(IDVDPlayer* player);
65   virtual ~CDVDInputStreamNavigator();
66
67   virtual bool Open(const char* strFile, const std::string& content);
68   virtual void Close();
69   virtual int Read(BYTE* buf, int buf_size);
70   virtual int64_t Seek(int64_t offset, int whence);
71   virtual bool Pause(double dTime) { return false; };
72   virtual int GetBlockSize() { return DVDSTREAM_BLOCK_SIZE_DVD; }
73   virtual bool IsEOF() { return m_bEOF; }
74   virtual int64_t GetLength()             { return 0; }
75   virtual ENextStream NextStream() ;
76
77   void ActivateButton();
78   void SelectButton(int iButton);
79   void SkipStill();
80   void SkipWait();
81   void OnUp();
82   void OnDown();
83   void OnLeft();
84   void OnRight();
85   void OnMenu();
86   void OnBack();
87   void OnNext();
88   void OnPrevious();
89   bool OnMouseMove(const CPoint &point);
90   bool OnMouseClick(const CPoint &point);
91
92   int GetCurrentButton();
93   int GetTotalButtons();
94   bool GetCurrentButtonInfo(CDVDOverlaySpu* pOverlayPicture, CDVDDemuxSPU* pSPU, int iButtonType /* 0 = selection, 1 = action (clicked)*/);
95
96   bool IsInMenu() { return m_bInMenu; }
97
98   int GetActiveSubtitleStream();
99   std::string GetSubtitleStreamLanguage(int iId);
100   int GetSubTitleStreamCount();
101
102   bool SetActiveSubtitleStream(int iId);
103   void EnableSubtitleStream(bool bEnable);
104   bool IsSubtitleStreamEnabled();
105
106   int GetActiveAudioStream();
107   std::string GetAudioStreamLanguage(int iId);
108   int GetAudioStreamCount();
109   bool SetActiveAudioStream(int iId);
110
111   bool GetNavigatorState(std::string &xmlstate);
112   bool SetNavigatorState(std::string &xmlstate);
113
114   int GetChapter()      { return m_iPart; }      // the current part in the current title
115   int GetChapterCount() { return m_iPartCount; } // the number of parts in the current title
116   void GetChapterName(std::string& name) {};
117   bool SeekChapter(int iChapter);
118
119   int GetTotalTime(); // the total time in milli seconds
120   int GetTime(); // the current position in milli seconds
121
122   float GetVideoAspectRatio();
123
124   bool SeekTime(int iTimeInMsec); //seek within current pg(c)
125   virtual int GetCurrentGroupId() { return m_icurrentGroupId; }
126
127   double GetTimeStampCorrection() { return (double)(m_iVobUnitCorrection * 1000) / 90; }
128 protected:
129
130   int ProcessBlock(BYTE* buffer, int* read);
131
132   void CheckButtons();
133
134   /**
135    * XBMC     : the audio stream id we use in xbmc
136    * external : the audio stream id that is used in libdvdnav
137    */
138   int ConvertAudioStreamId_XBMCToExternal(int id);
139   int ConvertAudioStreamId_ExternalToXBMC(int id);
140
141   /**
142    * XBMC     : the subtitle stream id we use in xbmc
143    * external : the subtitle stream id that is used in libdvdnav
144    */
145   int ConvertSubtitleStreamId_XBMCToExternal(int id);
146   int ConvertSubtitleStreamId_ExternalToXBMC(int id);
147
148   DllDvdNav m_dll;
149   bool m_bCheckButtons;
150   bool m_bEOF;
151
152   unsigned int m_icurrentGroupId;
153   int m_holdmode;
154
155   int m_iTotalTime;
156   int m_iTime;
157   int64_t m_iCellStart; // start time of current cell in pts units (90khz clock)
158
159   bool m_bInMenu;
160
161   int64_t m_iVobUnitStart;
162   int64_t m_iVobUnitStop;
163   int64_t m_iVobUnitCorrection;
164
165   int m_iTitleCount;
166   int m_iTitle;
167
168   int m_iPartCount;
169   int m_iPart;
170
171   struct dvdnav_s* m_dvdnav;
172
173   IDVDPlayer* m_pDVDPlayer;
174
175   BYTE m_lastblock[DVD_VIDEO_BLOCKSIZE];
176   int  m_lastevent;
177 };
178