4 * Copyright (C) 2005-2013 Team XBMC
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)
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.
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/>.
23 #include "DVDInputStream.h"
24 #include "../IDVDPlayer.h"
25 #include "../DVDCodecs/Overlay/DVDOverlaySpu.h"
27 #include "guilib/Geometry.h"
29 #include "DllDvdNav.h"
31 #define DVD_VIDEO_BLOCKSIZE DVD_VIDEO_LB_LEN // 2048 bytes
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
38 #define LIBDVDNAV_BUTTON_NORMAL 0
39 #define LIBDVDNAV_BUTTON_CLICKED 1
43 class CDVDOverlayPicture;
51 DVDNavResult(void* p, int t) { pData = p; type = t; };
56 class CDVDInputStreamNavigator
57 : public CDVDInputStream
58 , public CDVDInputStream::IDisplayTime
59 , public CDVDInputStream::IChapter
60 , public CDVDInputStream::ISeekTime
61 , public CDVDInputStream::IMenus
64 CDVDInputStreamNavigator(IDVDPlayer* player);
65 virtual ~CDVDInputStreamNavigator();
67 virtual bool Open(const char* strFile, const std::string& content);
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() ;
77 void ActivateButton();
78 void SelectButton(int iButton);
89 bool OnMouseMove(const CPoint &point);
90 bool OnMouseClick(const CPoint &point);
92 int GetCurrentButton();
93 int GetTotalButtons();
94 bool GetCurrentButtonInfo(CDVDOverlaySpu* pOverlayPicture, CDVDDemuxSPU* pSPU, int iButtonType /* 0 = selection, 1 = action (clicked)*/);
96 bool IsInMenu() { return m_bInMenu; }
98 int GetActiveSubtitleStream();
99 std::string GetSubtitleStreamLanguage(int iId);
100 int GetSubTitleStreamCount();
102 bool SetActiveSubtitleStream(int iId);
103 void EnableSubtitleStream(bool bEnable);
104 bool IsSubtitleStreamEnabled();
106 int GetActiveAudioStream();
107 std::string GetAudioStreamLanguage(int iId);
108 int GetAudioStreamCount();
109 bool SetActiveAudioStream(int iId);
111 bool GetNavigatorState(std::string &xmlstate);
112 bool SetNavigatorState(std::string &xmlstate);
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);
119 int GetTotalTime(); // the total time in milli seconds
120 int GetTime(); // the current position in milli seconds
122 float GetVideoAspectRatio();
124 bool SeekTime(int iTimeInMsec); //seek within current pg(c)
125 virtual int GetCurrentGroupId() { return m_icurrentGroupId; }
127 double GetTimeStampCorrection() { return (double)(m_iVobUnitCorrection * 1000) / 90; }
130 int ProcessBlock(BYTE* buffer, int* read);
135 * XBMC : the audio stream id we use in xbmc
136 * external : the audio stream id that is used in libdvdnav
138 int ConvertAudioStreamId_XBMCToExternal(int id);
139 int ConvertAudioStreamId_ExternalToXBMC(int id);
142 * XBMC : the subtitle stream id we use in xbmc
143 * external : the subtitle stream id that is used in libdvdnav
145 int ConvertSubtitleStreamId_XBMCToExternal(int id);
146 int ConvertSubtitleStreamId_ExternalToXBMC(int id);
149 bool m_bCheckButtons;
152 unsigned int m_icurrentGroupId;
157 int64_t m_iCellStart; // start time of current cell in pts units (90khz clock)
161 int64_t m_iVobUnitStart;
162 int64_t m_iVobUnitStop;
163 int64_t m_iVobUnitCorrection;
171 struct dvdnav_s* m_dvdnav;
173 IDVDPlayer* m_pDVDPlayer;
175 BYTE m_lastblock[DVD_VIDEO_BLOCKSIZE];