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.
12 #include "cores/IPlayer.h"
28 // messages used in the whole system
30 GENERAL_FLUSH
, // flush all buffers
31 GENERAL_RESET
, // reset codecs for new data
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
45 PLAYER_SET_UPDATE_STREAM_DETAILS
, // player should update file item stream details with its current streams
47 PLAYER_SEEK_CHAPTER
, //
48 PLAYER_SETSPEED
, // set the playback speed
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
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
72 explicit CDVDMsg(Message msg
)
77 virtual ~CDVDMsg() = default;
80 * checks for message type
82 inline bool IsType(Message msg
)
84 return (m_message
== msg
);
87 inline Message
GetMessageType()
96 ////////////////////////////////////////////////////////////////////////////////
98 ////// GENERAL_ Messages
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
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
);
120 class CDVDMsgGeneralSynchronizePriv
* m_p
;
123 template <typename T
>
124 class CDVDMsgType
: public CDVDMsg
127 CDVDMsgType(Message type
, const T
&value
)
132 ~CDVDMsgType() override
= default;
134 operator T() { return m_value
; }
138 typedef CDVDMsgType
<bool> CDVDMsgBool
;
139 typedef CDVDMsgType
<int> CDVDMsgInt
;
140 typedef CDVDMsgType
<double> CDVDMsgDouble
;
142 ////////////////////////////////////////////////////////////////////////////////
144 ////// PLAYER_ Messages
146 ////////////////////////////////////////////////////////////////////////////////
148 class CDVDMsgPlayerSetAudioStream
: public CDVDMsg
151 explicit CDVDMsgPlayerSetAudioStream(int streamId
) : CDVDMsg(PLAYER_SET_AUDIOSTREAM
) { m_streamId
= streamId
; }
152 ~CDVDMsgPlayerSetAudioStream() override
= default;
154 int GetStreamId() { return m_streamId
; }
159 class CDVDMsgPlayerSetVideoStream
: public CDVDMsg
162 explicit CDVDMsgPlayerSetVideoStream(int streamId
) : CDVDMsg(PLAYER_SET_VIDEOSTREAM
) { m_streamId
= streamId
; }
163 ~CDVDMsgPlayerSetVideoStream() override
= default;
165 int GetStreamId() const { return m_streamId
; }
170 class CDVDMsgPlayerSetSubtitleStream
: public CDVDMsg
173 explicit CDVDMsgPlayerSetSubtitleStream(int streamId
) : CDVDMsg(PLAYER_SET_SUBTITLESTREAM
) { m_streamId
= streamId
; }
174 ~CDVDMsgPlayerSetSubtitleStream() override
= default;
176 int GetStreamId() { return m_streamId
; }
181 class CDVDMsgPlayerSetState
: public CDVDMsg
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
; }
192 class CDVDMsgPlayerSeek
: public CDVDMsg
198 bool relative
= false;
199 bool backward
= false;
200 bool accurate
= true;
203 bool trickplay
= false;
206 explicit CDVDMsgPlayerSeek(CDVDMsgPlayerSeek::CMode mode
) : CDVDMsg(PLAYER_SEEK
),
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
; }
223 class CDVDMsgPlayerSeekChapter
: public CDVDMsg
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
; }
239 class CDVDMsgPlayerSetSpeed
: public CDVDMsg
248 explicit CDVDMsgPlayerSetSpeed(SpeedParams params
)
249 : CDVDMsg(PLAYER_SETSPEED
)
252 ~CDVDMsgPlayerSetSpeed() override
= default;
254 int GetSpeed() const { return m_params
.m_speed
; }
255 bool IsTempo() const { return m_params
.m_isTempo
; }
259 SpeedParams m_params
;
263 class CDVDMsgOpenFile
: public CDVDMsg
269 CPlayerOptions m_options
;
272 explicit CDVDMsgOpenFile(const FileParams
¶ms
)
273 : CDVDMsg(PLAYER_OPENFILE
)
276 ~CDVDMsgOpenFile() override
= default;
278 CFileItem
& GetItem() { return m_params
.m_item
; }
279 CPlayerOptions
& GetOptions() { return m_params
.m_options
; }
286 ////////////////////////////////////////////////////////////////////////////////
288 ////// DEMUXER_ Messages
290 ////////////////////////////////////////////////////////////////////////////////
292 class CDVDMsgDemuxerPacket
: public CDVDMsg
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
;
304 class CDVDMsgDemuxerReset
: public CDVDMsg
307 CDVDMsgDemuxerReset() : CDVDMsg(DEMUXER_RESET
) {}
308 ~CDVDMsgDemuxerReset() override
= default;
313 ////////////////////////////////////////////////////////////////////////////////
315 ////// VIDEO_ Messages
317 ////////////////////////////////////////////////////////////////////////////////
320 ////////////////////////////////////////////////////////////////////////////////
322 ////// SUBTITLE_ Messages
324 ////////////////////////////////////////////////////////////////////////////////
326 class CDVDMsgSubtitleClutChange
: public CDVDMsg
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];