rtplay.h 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. ////////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright 2016 RWS Inc, All Rights Reserved
  4. //
  5. // This program is free software; you can redistribute it and/or modify
  6. // it under the terms of version 2 of the GNU General Public License as published by
  7. // the Free Software Foundation
  8. //
  9. // This program is distributed in the hope that it will be useful,
  10. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. // GNU General Public License for more details.
  13. //
  14. // You should have received a copy of the GNU General Public License along
  15. // with this program; if not, write to the Free Software Foundation, Inc.,
  16. // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  17. //
  18. #ifndef RTPLAY_H
  19. #define RTPLAY_H
  20. //////////////////////////////////////////////////////////////////////////////
  21. // Headers.
  22. //////////////////////////////////////////////////////////////////////////////
  23. #include "filewin.h"
  24. #include "filter.h"
  25. #include "dispatch.h"
  26. #include "res.h"
  27. #include "rttime.h"
  28. #include "task.h"
  29. //////////////////////////////////////////////////////////////////////////////
  30. // Macros.
  31. //////////////////////////////////////////////////////////////////////////////
  32. // Values for m_usState.
  33. #define RT_STATE_STOPPED 0x0000 // Currently no file is being streamed.
  34. #define RT_STATE_STARTING 0x0001 // Preparing to stream (building up enough
  35. // input that we could attain stream data
  36. // usage).
  37. #define RT_STATE_BEGIN 0x0002 // Internal use only!!
  38. #define RT_STATE_PLAYING 0x0003 // Streaming.
  39. #define RT_STATE_PAUSE 0x0004 // Streaming is temporarily suspended.
  40. #define RT_STATE_ABORTING 0x0005 // Terminating stream early.
  41. #define RT_STATE_ENDING 0x0006 // Ending due to end of stream data.
  42. // Values for messages passed to handlers.
  43. #define RT_MSG_STOPPED 0x0000 // The last thing a message handler will
  44. // receive from a stream session, indicat-
  45. // ing that streaming is done completely.
  46. #define RT_MSG_STARTING 0x0001 // The first thing a message handler will
  47. // receive indicating we are preparing to
  48. // stream.
  49. #define RT_MSG_BEGIN 0x0002 // This let's the handler know it's time
  50. // to open the flood-gates. An audio
  51. // handler might use this as an
  52. // opportunity to actually start playing
  53. // data.
  54. #define RT_MSG_PLAYING 0x0003 // Streaming.
  55. #define RT_MSG_PAUSE 0x0004 // Streaming is paused.
  56. #define RT_MSG_ABORTING 0x0005 // Prematurely ending streaming.
  57. #define RT_MSG_ENDING 0x0006 // Ending streaming due to end of data.
  58. //////////////////////////////////////////////////////////////////////////////
  59. // Typedefs.
  60. //////////////////////////////////////////////////////////////////////////////
  61. class CRtPlay
  62. {
  63. public: // Construction/Destruction.
  64. // Default constructor.
  65. CRtPlay();
  66. // Destructor.
  67. ~CRtPlay();
  68. public: // Methods.
  69. // Opens a stream file for play.
  70. // Returns 0 on success.
  71. short Open(char* pszFileName);
  72. // Closes an open stream file.
  73. // Returns 0 on success.
  74. short Close(void);
  75. // Starts play.
  76. // Returns 0 on success.
  77. short Play(void);
  78. // Aborts current play.
  79. // Returns 0 on success.
  80. short Abort(void);
  81. // Pauses play.
  82. // Returns 0 on success.
  83. short Pause(void);
  84. // Resumes play (after Pause()).
  85. // Returns 0 on success.
  86. short Resume(void);
  87. // Sets the time handler function in our CRtTime.
  88. void SetTimeFunc(RTTIMEFUNC fnTime)
  89. { m_rttime.SetTimeFunc(fnTime); }
  90. // Sets the channels to play.
  91. void SetChannels(USHORT usFilter)
  92. { m_filter.SetFilter(usFilter); }
  93. // Sets the window and panes sizes for the file window (which is set
  94. // imeediately after opening).
  95. void SetSizes( long lWindowSize, long lInputPaneSize,
  96. long lFilterPaneSize)
  97. {
  98. m_lWindowSize = lWindowSize;
  99. m_lInputPaneSize = lInputPaneSize;
  100. m_lFilterPaneSize = lFilterPaneSize;
  101. }
  102. public: // Querries.
  103. // Get current status.
  104. USHORT GetState(void)
  105. { return m_usState; }
  106. protected: // Internal methods.
  107. // Sets members w/o regard for current value.
  108. void Set(void);
  109. // Resets members. Deallocates memory if necessary.
  110. void Reset(void);
  111. // Sets the state to the new state. Generates messages if a state change
  112. // occurs.
  113. // Returns 0 on success.
  114. short SetState(USHORT usState);
  115. // Adds an RT_TYPE_RTFINFO chunk to the dispatcher with the specified command
  116. // and parameters.
  117. // Returns 0 on success.
  118. short CreateCmd(USHORT usCmd, long lTime, long lParm1, long lParm2);
  119. // Handles data callbacks from dispatch.
  120. // Returns RET_FREE if puc should be freed and RET_DONTFREE, otherwise.
  121. short RtInfoCall( UCHAR* puc, long lSize, USHORT usType, UCHAR ucFlags,
  122. long lTime);
  123. // Callback dispatcher (calls the implied this version).
  124. // Returns RET_FREE if puc should be freed and RET_DONTFREE, otherwise.
  125. static short RtInfoCallStatic(UCHAR* puc, long lSize, USHORT usType,
  126. UCHAR ucFlags, long lTime, long l_pRtPlay);
  127. // Handles current state. Called by Blue's critical handler list.
  128. void Critical(void);
  129. // Static version of above.
  130. static void CriticalStatic(ULONG ul_pRtPlay)
  131. { ((CRtPlay*)ul_pRtPlay)->Critical(); }
  132. public: // Members.
  133. CDispatch m_dispatch; // Dispatches types to handlers.
  134. CFilter m_filter; // Filters channels and builds
  135. // contiguous buffers.
  136. CFileWin m_filewin; // Window into stream file.
  137. CRes m_res; // Stores types to be requested.
  138. CRtTime m_rttime; // Keeps time for us in a nice,
  139. // pausable/resumable fashion.
  140. protected: // Members.
  141. USHORT m_usState; // Current state of class.
  142. ULONG m_ulChannelsDone; // Masks of channels that have
  143. // completed.
  144. long m_lWindowSize; // Size for file window.
  145. long m_lInputPaneSize; // Size for input pane of file window.
  146. long m_lFilterPaneSize; // Size for filter pane of file window.
  147. };
  148. #endif // RTPLAY_H
  149. //////////////////////////////////////////////////////////////////////////////
  150. // EOF
  151. //////////////////////////////////////////////////////////////////////////////