[videodb] remove unused seasons table from episode_view
[xbmc.git] / xbmc / cores / VideoPlayer / DVDMessage.h
blob5b1dcf760271ea3a1f7b54f5a4d3b5f04a7ee993
1 /*
2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
9 #pragma once
11 #include "FileItem.h"
12 #include "cores/IPlayer.h"
14 #include <atomic>
15 #include <string.h>
16 #include <string>
18 struct DemuxPacket;
20 class CDVDMsg
22 public:
23 // clang-format off
24 enum Message
26 NONE = 1000,
28 // messages used in the whole system
29 GENERAL_RESYNC, //
30 GENERAL_FLUSH, // flush all buffers
31 GENERAL_RESET, // reset codecs for new data
32 GENERAL_PAUSE,
33 GENERAL_STREAMCHANGE, //
34 GENERAL_SYNCHRONIZE, //
35 GENERAL_GUI_ACTION, // gui action of some sort
36 GENERAL_EOF, // eof of stream
38 // player core related messages (cVideoPlayer.cpp)
39 PLAYER_SET_AUDIOSTREAM, //
40 PLAYER_SET_VIDEOSTREAM, //
41 PLAYER_SET_SUBTITLESTREAM, //
42 PLAYER_SET_SUBTITLESTREAM_VISIBLE, //
43 PLAYER_SET_STATE, // restore the VideoPlayer to a certain state
44 PLAYER_SET_PROGRAM,
45 PLAYER_SET_UPDATE_STREAM_DETAILS, // player should update file item stream details with its current streams
46 PLAYER_SEEK, //
47 PLAYER_SEEK_CHAPTER, //
48 PLAYER_SETSPEED, // set the playback speed
49 PLAYER_REQUEST_STATE,
50 PLAYER_OPENFILE,
51 PLAYER_STARTED, // sent whenever a sub player has finished it's first frame after open
52 PLAYER_AVCHANGE, // signal a change in audio, video or subtitle parameters
53 PLAYER_ABORT,
54 PLAYER_REPORT_STATE,
55 PLAYER_FRAME_ADVANCE,
56 PLAYER_DISPLAY_RESET, // report display reset event
58 // demuxer related messages
59 DEMUXER_PACKET, // data packet
60 DEMUXER_RESET, // reset the demuxer
62 // video related messages
63 VIDEO_SET_ASPECT, // set aspectratio of video
64 VIDEO_DRAIN, // wait for decoder to output last frame
66 // subtitle related messages
67 SUBTITLE_CLUTCHANGE,
68 SUBTITLE_ADDFILE
70 // clang-format on
72 explicit CDVDMsg(Message msg)
74 m_message = msg;
77 virtual ~CDVDMsg() = default;
79 /**
80 * checks for message type
82 inline bool IsType(Message msg)
84 return (m_message == msg);
87 inline Message GetMessageType()
89 return m_message;
92 private:
93 Message m_message;
96 ////////////////////////////////////////////////////////////////////////////////
97 //////
98 ////// GENERAL_ Messages
99 //////
100 ////////////////////////////////////////////////////////////////////////////////
102 #define SYNCSOURCE_AUDIO 0x01
103 #define SYNCSOURCE_VIDEO 0x02
104 #define SYNCSOURCE_PLAYER 0x04
105 #define SYNCSOURCE_ANY 0x08
107 class CDVDMsgGeneralSynchronizePriv;
108 class CDVDMsgGeneralSynchronize : public CDVDMsg
110 public:
111 CDVDMsgGeneralSynchronize(std::chrono::milliseconds timeout, unsigned int sources);
112 ~CDVDMsgGeneralSynchronize() override;
114 // waits until all threads waiting, released the object
115 // if abort is set somehow
116 bool Wait(std::chrono::milliseconds ms, unsigned int source);
117 void Wait(std::atomic<bool>& abort, unsigned int source);
119 private:
120 class CDVDMsgGeneralSynchronizePriv* m_p;
123 template <typename T>
124 class CDVDMsgType : public CDVDMsg
126 public:
127 CDVDMsgType(Message type, const T &value)
128 : CDVDMsg(type)
129 , m_value(value)
132 ~CDVDMsgType() override = default;
134 operator T() { return m_value; }
135 T m_value;
138 typedef CDVDMsgType<bool> CDVDMsgBool;
139 typedef CDVDMsgType<int> CDVDMsgInt;
140 typedef CDVDMsgType<double> CDVDMsgDouble;
142 ////////////////////////////////////////////////////////////////////////////////
143 //////
144 ////// PLAYER_ Messages
145 //////
146 ////////////////////////////////////////////////////////////////////////////////
148 class CDVDMsgPlayerSetAudioStream : public CDVDMsg
150 public:
151 explicit CDVDMsgPlayerSetAudioStream(int streamId) : CDVDMsg(PLAYER_SET_AUDIOSTREAM) { m_streamId = streamId; }
152 ~CDVDMsgPlayerSetAudioStream() override = default;
154 int GetStreamId() { return m_streamId; }
155 private:
156 int m_streamId;
159 class CDVDMsgPlayerSetVideoStream : public CDVDMsg
161 public:
162 explicit CDVDMsgPlayerSetVideoStream(int streamId) : CDVDMsg(PLAYER_SET_VIDEOSTREAM) { m_streamId = streamId; }
163 ~CDVDMsgPlayerSetVideoStream() override = default;
165 int GetStreamId() const { return m_streamId; }
166 private:
167 int m_streamId;
170 class CDVDMsgPlayerSetSubtitleStream : public CDVDMsg
172 public:
173 explicit CDVDMsgPlayerSetSubtitleStream(int streamId) : CDVDMsg(PLAYER_SET_SUBTITLESTREAM) { m_streamId = streamId; }
174 ~CDVDMsgPlayerSetSubtitleStream() override = default;
176 int GetStreamId() { return m_streamId; }
177 private:
178 int m_streamId;
181 class CDVDMsgPlayerSetState : public CDVDMsg
183 public:
184 explicit CDVDMsgPlayerSetState(const std::string& state) : CDVDMsg(PLAYER_SET_STATE), m_state(state) {}
185 ~CDVDMsgPlayerSetState() override = default;
187 std::string GetState() { return m_state; }
188 private:
189 std::string m_state;
192 class CDVDMsgPlayerSeek : public CDVDMsg
194 public:
195 struct CMode
197 double time = 0;
198 bool relative = false;
199 bool backward = false;
200 bool accurate = true;
201 bool sync = true;
202 bool restore = true;
203 bool trickplay = false;
206 explicit CDVDMsgPlayerSeek(CDVDMsgPlayerSeek::CMode mode) : CDVDMsg(PLAYER_SEEK),
207 m_mode(mode)
209 ~CDVDMsgPlayerSeek() override = default;
211 double GetTime() { return m_mode.time; }
212 bool GetRelative() { return m_mode.relative; }
213 bool GetBackward() { return m_mode.backward; }
214 bool GetAccurate() { return m_mode.accurate; }
215 bool GetRestore() { return m_mode.restore; }
216 bool GetTrickPlay() { return m_mode.trickplay; }
217 bool GetSync() { return m_mode.sync; }
219 private:
220 CMode m_mode;
223 class CDVDMsgPlayerSeekChapter : public CDVDMsg
225 public:
226 explicit CDVDMsgPlayerSeekChapter(int iChapter)
227 : CDVDMsg(PLAYER_SEEK_CHAPTER)
228 , m_iChapter(iChapter)
230 ~CDVDMsgPlayerSeekChapter() override = default;
232 int GetChapter() const { return m_iChapter; }
234 private:
236 int m_iChapter;
239 class CDVDMsgPlayerSetSpeed : public CDVDMsg
241 public:
242 struct SpeedParams
244 int m_speed;
245 bool m_isTempo;
248 explicit CDVDMsgPlayerSetSpeed(SpeedParams params)
249 : CDVDMsg(PLAYER_SETSPEED)
250 , m_params(params)
252 ~CDVDMsgPlayerSetSpeed() override = default;
254 int GetSpeed() const { return m_params.m_speed; }
255 bool IsTempo() const { return m_params.m_isTempo; }
257 private:
259 SpeedParams m_params;
263 class CDVDMsgOpenFile : public CDVDMsg
265 public:
266 struct FileParams
268 CFileItem m_item;
269 CPlayerOptions m_options;
272 explicit CDVDMsgOpenFile(const FileParams &params)
273 : CDVDMsg(PLAYER_OPENFILE)
274 , m_params(params)
276 ~CDVDMsgOpenFile() override = default;
278 CFileItem& GetItem() { return m_params.m_item; }
279 CPlayerOptions& GetOptions() { return m_params.m_options; }
281 private:
283 FileParams m_params;
286 ////////////////////////////////////////////////////////////////////////////////
287 //////
288 ////// DEMUXER_ Messages
289 //////
290 ////////////////////////////////////////////////////////////////////////////////
292 class CDVDMsgDemuxerPacket : public CDVDMsg
294 public:
295 CDVDMsgDemuxerPacket(DemuxPacket* packet, bool drop = false);
296 ~CDVDMsgDemuxerPacket() override;
297 DemuxPacket* GetPacket() { return m_packet; }
298 unsigned int GetPacketSize();
299 bool GetPacketDrop() { return m_drop; }
300 DemuxPacket* m_packet;
301 bool m_drop;
304 class CDVDMsgDemuxerReset : public CDVDMsg
306 public:
307 CDVDMsgDemuxerReset() : CDVDMsg(DEMUXER_RESET) {}
308 ~CDVDMsgDemuxerReset() override = default;
313 ////////////////////////////////////////////////////////////////////////////////
314 //////
315 ////// VIDEO_ Messages
316 //////
317 ////////////////////////////////////////////////////////////////////////////////
320 ////////////////////////////////////////////////////////////////////////////////
321 //////
322 ////// SUBTITLE_ Messages
323 //////
324 ////////////////////////////////////////////////////////////////////////////////
326 class CDVDMsgSubtitleClutChange : public CDVDMsg
328 public:
329 explicit CDVDMsgSubtitleClutChange(uint8_t* data) : CDVDMsg(SUBTITLE_CLUTCHANGE) { memcpy(m_data, data, 16*4); }
330 ~CDVDMsgSubtitleClutChange() override = default;
332 uint8_t m_data[16][4];