/xbmc/cores/dvdplayer/DVDMessage.h

http://github.com/xbmc/xbmc · C Header · 307 lines · 196 code · 54 blank · 57 comment · 3 complexity · a69ed314c21e9ff7549a9c1f3ff23907 MD5 · raw file

  1. /*
  2. * Copyright (C) 2005-2013 Team XBMC
  3. * http://xbmc.org
  4. *
  5. * This Program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 2, or (at your option)
  8. * any later version.
  9. *
  10. * This Program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with XBMC; see the file COPYING. If not, see
  17. * <http://www.gnu.org/licenses/>.
  18. *
  19. */
  20. #pragma once
  21. #ifdef __GNUC__
  22. // under gcc, inline will only take place if optimizations are applied (-O). this will force inline even whith optimizations.
  23. #define XBMC_FORCE_INLINE __attribute__((always_inline))
  24. #else
  25. #define XBMC_FORCE_INLINE
  26. #endif
  27. // include as less is possible to prevent dependencies
  28. #include "system.h"
  29. #include "DVDDemuxers/DVDDemux.h"
  30. #include "DVDMessageTracker.h"
  31. #include "DVDResource.h"
  32. #include <assert.h>
  33. class CDVDMsg : public IDVDResourceCounted<CDVDMsg>
  34. {
  35. public:
  36. enum Message
  37. {
  38. NONE = 1000,
  39. // messages used in the whole system
  40. GENERAL_RESYNC, //
  41. GENERAL_FLUSH, // flush all buffers
  42. GENERAL_RESET, // reset codecs for new data
  43. GENERAL_STREAMCHANGE, //
  44. GENERAL_SYNCHRONIZE, //
  45. GENERAL_DELAY, //
  46. GENERAL_GUI_ACTION, // gui action of some sort
  47. GENERAL_EOF, // eof of stream
  48. // player core related messages (cdvdplayer.cpp)
  49. PLAYER_SET_AUDIOSTREAM, //
  50. PLAYER_SET_SUBTITLESTREAM, //
  51. PLAYER_SET_SUBTITLESTREAM_VISIBLE, //
  52. PLAYER_SET_STATE, // restore the dvdplayer to a certain state
  53. PLAYER_SET_RECORD, // set record state
  54. PLAYER_SEEK, //
  55. PLAYER_SEEK_CHAPTER, //
  56. PLAYER_SETSPEED, // set the playback speed
  57. PLAYER_CHANNEL_NEXT, // switches to next playback channel
  58. PLAYER_CHANNEL_PREV, // switches to previous playback channel
  59. PLAYER_CHANNEL_SELECT_NUMBER, // switches to the channel with the provided channel number
  60. PLAYER_CHANNEL_SELECT, // switches to the provided channel
  61. PLAYER_STARTED, // sent whenever a sub player has finished it's first frame after open
  62. PLAYER_DISPLAYTIME, // display time struct from av players
  63. // demuxer related messages
  64. DEMUXER_PACKET, // data packet
  65. DEMUXER_RESET, // reset the demuxer
  66. // video related messages
  67. VIDEO_NOSKIP, // next pictures is not to be skipped by the video renderer
  68. VIDEO_SET_ASPECT, // set aspectratio of video
  69. // audio related messages
  70. AUDIO_SILENCE,
  71. // subtitle related messages
  72. SUBTITLE_CLUTCHANGE
  73. };
  74. CDVDMsg(Message msg)
  75. {
  76. m_message = msg;
  77. #ifdef DVDDEBUG_MESSAGE_TRACKER
  78. g_dvdMessageTracker.Register(this);
  79. #endif
  80. }
  81. virtual ~CDVDMsg()
  82. {
  83. #ifdef DVDDEBUG_MESSAGE_TRACKER
  84. g_dvdMessageTracker.UnRegister(this);
  85. #endif
  86. }
  87. /**
  88. * checks for message type
  89. */
  90. inline bool IsType(Message msg) XBMC_FORCE_INLINE
  91. {
  92. return (m_message == msg);
  93. }
  94. inline Message GetMessageType() XBMC_FORCE_INLINE
  95. {
  96. return m_message;
  97. }
  98. long GetNrOfReferences()
  99. {
  100. return m_refs;
  101. }
  102. private:
  103. Message m_message;
  104. };
  105. ////////////////////////////////////////////////////////////////////////////////
  106. //////
  107. ////// GENERAL_ Messages
  108. //////
  109. ////////////////////////////////////////////////////////////////////////////////
  110. class CDVDMsgGeneralResync : public CDVDMsg
  111. {
  112. public:
  113. CDVDMsgGeneralResync(double timestamp, bool clock) : CDVDMsg(GENERAL_RESYNC) { m_timestamp = timestamp; m_clock = clock; }
  114. double m_timestamp;
  115. bool m_clock;
  116. };
  117. #define SYNCSOURCE_AUDIO 0x00000001
  118. #define SYNCSOURCE_VIDEO 0x00000002
  119. #define SYNCSOURCE_SUB 0x00000004
  120. #define SYNCSOURCE_OWNER 0x80000000 /* only allowed for the constructor of the object */
  121. #define SYNCSOURCE_ALL (SYNCSOURCE_AUDIO | SYNCSOURCE_VIDEO | SYNCSOURCE_SUB | SYNCSOURCE_OWNER)
  122. class CDVDMsgGeneralSynchronizePriv;
  123. class CDVDMsgGeneralSynchronize : public CDVDMsg
  124. {
  125. public:
  126. CDVDMsgGeneralSynchronize(unsigned int timeout, unsigned int sources);
  127. ~CDVDMsgGeneralSynchronize();
  128. virtual long Release();
  129. // waits until all threads waiting, released the object
  130. // if abort is set somehow
  131. bool Wait(unsigned int ms , unsigned int source);
  132. void Wait(volatile bool *abort, unsigned int source);
  133. private:
  134. class CDVDMsgGeneralSynchronizePriv* m_p;
  135. };
  136. template <typename T>
  137. class CDVDMsgType : public CDVDMsg
  138. {
  139. public:
  140. CDVDMsgType(Message type, T value)
  141. : CDVDMsg(type)
  142. , m_value(value)
  143. {}
  144. operator T() { return m_value; }
  145. T m_value;
  146. };
  147. typedef CDVDMsgType<bool> CDVDMsgBool;
  148. typedef CDVDMsgType<int> CDVDMsgInt;
  149. typedef CDVDMsgType<double> CDVDMsgDouble;
  150. ////////////////////////////////////////////////////////////////////////////////
  151. //////
  152. ////// PLAYER_ Messages
  153. //////
  154. ////////////////////////////////////////////////////////////////////////////////
  155. class CDVDMsgPlayerSetAudioStream : public CDVDMsg
  156. {
  157. public:
  158. CDVDMsgPlayerSetAudioStream(int streamId) : CDVDMsg(PLAYER_SET_AUDIOSTREAM) { m_streamId = streamId; }
  159. int GetStreamId() { return m_streamId; }
  160. private:
  161. int m_streamId;
  162. };
  163. class CDVDMsgPlayerSetSubtitleStream : public CDVDMsg
  164. {
  165. public:
  166. CDVDMsgPlayerSetSubtitleStream(int streamId) : CDVDMsg(PLAYER_SET_SUBTITLESTREAM) { m_streamId = streamId; }
  167. int GetStreamId() { return m_streamId; }
  168. private:
  169. int m_streamId;
  170. };
  171. class CDVDMsgPlayerSetState : public CDVDMsg
  172. {
  173. public:
  174. CDVDMsgPlayerSetState(std::string& state) : CDVDMsg(PLAYER_SET_STATE), m_state(state) {}
  175. std::string GetState() { return m_state; }
  176. private:
  177. std::string m_state;
  178. };
  179. class CDVDMsgPlayerSeek : public CDVDMsg
  180. {
  181. public:
  182. CDVDMsgPlayerSeek(int time, bool backward, bool flush = true, bool accurate = true, bool restore = true, bool trickplay = false)
  183. : CDVDMsg(PLAYER_SEEK)
  184. , m_time(time)
  185. , m_backward(backward)
  186. , m_flush(flush)
  187. , m_accurate(accurate)
  188. , m_restore(restore)
  189. , m_trickplay(trickplay)
  190. {}
  191. int GetTime() { return m_time; }
  192. bool GetBackward() { return m_backward; }
  193. bool GetFlush() { return m_flush; }
  194. bool GetAccurate() { return m_accurate; }
  195. bool GetRestore() { return m_restore; }
  196. bool GetTrickPlay() { return m_trickplay; }
  197. private:
  198. int m_time;
  199. bool m_backward;
  200. bool m_flush;
  201. bool m_accurate;
  202. bool m_restore; // whether to restore any EDL cut time
  203. bool m_trickplay;
  204. };
  205. class CDVDMsgPlayerSeekChapter : public CDVDMsg
  206. {
  207. public:
  208. CDVDMsgPlayerSeekChapter(int iChapter)
  209. : CDVDMsg(PLAYER_SEEK_CHAPTER)
  210. , m_iChapter(iChapter)
  211. {}
  212. int GetChapter() const { return m_iChapter; }
  213. private:
  214. int m_iChapter;
  215. };
  216. ////////////////////////////////////////////////////////////////////////////////
  217. //////
  218. ////// DEMUXER_ Messages
  219. //////
  220. ////////////////////////////////////////////////////////////////////////////////
  221. class CDVDMsgDemuxerPacket : public CDVDMsg
  222. {
  223. public:
  224. CDVDMsgDemuxerPacket(DemuxPacket* packet, bool drop = false);
  225. virtual ~CDVDMsgDemuxerPacket();
  226. DemuxPacket* GetPacket() { return m_packet; }
  227. unsigned int GetPacketSize() { if(m_packet) return m_packet->iSize; else return 0; }
  228. bool GetPacketDrop() { return m_drop; }
  229. DemuxPacket* m_packet;
  230. bool m_drop;
  231. };
  232. class CDVDMsgDemuxerReset : public CDVDMsg
  233. {
  234. public:
  235. CDVDMsgDemuxerReset() : CDVDMsg(DEMUXER_RESET) {}
  236. };
  237. ////////////////////////////////////////////////////////////////////////////////
  238. //////
  239. ////// VIDEO_ Messages
  240. //////
  241. ////////////////////////////////////////////////////////////////////////////////
  242. ////////////////////////////////////////////////////////////////////////////////
  243. //////
  244. ////// SUBTITLE_ Messages
  245. //////
  246. ////////////////////////////////////////////////////////////////////////////////
  247. class CDVDMsgSubtitleClutChange : public CDVDMsg
  248. {
  249. public:
  250. CDVDMsgSubtitleClutChange(uint8_t* data) : CDVDMsg(SUBTITLE_CLUTCHANGE) { memcpy(m_data, data, 16*4); }
  251. uint8_t m_data[16][4];
  252. private:
  253. };