rtvidc.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  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 RTVIDC_H
  19. #define RTVIDC_H
  20. //////////////////////////////////////////////////////////////////////////////
  21. // Headers.
  22. //////////////////////////////////////////////////////////////////////////////
  23. #include "dispatch.h"
  24. #include "Image.h"
  25. #include "win.h"
  26. #include <vfw.h>
  27. //////////////////////////////////////////////////////////////////////////////
  28. // Macros.
  29. //////////////////////////////////////////////////////////////////////////////
  30. // This value can be from 0 to 64K - 1.
  31. // The overhead per channel is sizeof(VIDC_RT_HDR) bytes.
  32. #define MAX_VID_CHANNELS 25
  33. //////////////////////////////////////////////////////////////////////////////
  34. // Typedefs.
  35. //////////////////////////////////////////////////////////////////////////////
  36. // Forward declare classes for RTVIDC_CALL definition.
  37. class CRtVidc;
  38. class VIDC_RT_HDR;
  39. typedef VIDC_RT_HDR* PVIDC_RT_HDR;
  40. typedef void (*RTVIDC_CALL)(CRtVidc* prtvidc, PVIDC_RT_HDR pvidchdr);
  41. class VIDC_RT_HDR
  42. {
  43. public:
  44. // Header info from stream.
  45. short sNumFrames; // Number of frames. Max 4000.
  46. short sWidth; // Width in pixels (always 320 in FLI)
  47. short sHeight; // Height in pixels (always 200 in FLI)
  48. short sDepth; // Bits per pixel (always 8)
  49. long lMilliPerFrame; // Milliseconds between frames.
  50. short sNoDelta; // TRUE if no deltas, FALSE otherwise.
  51. short sTransparent; // Blt with transparency if TRUE.
  52. short sX; // Intended position in x direction.
  53. short sY; // Intended position in y direction.
  54. ULONG ulFCCHandler; // FCC of Windows' VIDC handler.
  55. // Header info for our use.
  56. CImage* pImage; // Where to blt.
  57. short sCurFrame; // Current frame number (0 origin).
  58. short sColorsModified; // TRUE if colors were modified last
  59. // decompression.
  60. long lMaxLag; // Maximum lag before skipping frames.
  61. RTVIDC_CALL callbackHeader; // Callback on header receipt.
  62. RTVIDC_CALL callbackBefore; // Callback before decompression.
  63. RTVIDC_CALL callbackAfter; // Callback after decompression.
  64. HIC hic; // Handle to the image compressor/de-
  65. // compressor.
  66. };
  67. class CRtVidc
  68. {
  69. public: // Construction/Destruction.
  70. // Default constructor.
  71. CRtVidc();
  72. // Destructor.
  73. ~CRtVidc();
  74. public: // Methods.
  75. // Sets the dispatcher.
  76. void SetDispatcher(CDispatch* pdispatch);
  77. // Sets callback(s) called on channel header receipt.
  78. void SetCallbackHeader(RTVIDC_CALL callback);
  79. void SetCallbackHeader(RTVIDC_CALL callback, short sChannel);
  80. // Sets callback(s) called before decompression.
  81. void SetCallbackBefore(RTVIDC_CALL callback);
  82. void SetCallbackBefore(RTVIDC_CALL callback, short sChannel);
  83. // Sets callback(s) called after decompression.
  84. void SetCallbackAfter(RTVIDC_CALL callback);
  85. void SetCallbackAfter(RTVIDC_CALL callback, short sChannel);
  86. protected: // Internal typedefs.
  87. typedef struct
  88. {
  89. BITMAPINFOHEADER bmiHeader;
  90. RGBQUAD bmiColors[256];
  91. } BMI, *PBMI;
  92. protected: // Internal methods.
  93. // Sets variables w/o regard to current values.
  94. void Set();
  95. // Resets variables. Performs deallocation if necessary.
  96. void Reset();
  97. // Decompresses a VIDC frame using the opened decompressor.
  98. // Returns 0 on success.
  99. short DecompressFrame( PVIDC_RT_HDR pvidchdr, CNFile* pfile,
  100. ULONG ulFlags, PBMI pbmiIn, PBMI pbmiOut);
  101. // Use handler for RtVidc buffers.
  102. // Returns RET_FREE if done with data on return, RET_DONTFREE otherwise.
  103. short Use( UCHAR* puc, long lSize, USHORT usType, UCHAR ucFlags,
  104. long lTime);
  105. // Static entry point for above.
  106. static short UseStatic( UCHAR* puc, long lSize, USHORT usType,
  107. UCHAR ucFlags, long lTime, long l_pRtVidc);
  108. protected: // Internal typedefs.
  109. public: // Members.
  110. protected: // Members.
  111. VIDC_RT_HDR m_avidchdrs[MAX_VID_CHANNELS];// Info for each channel.
  112. USHORT m_usState; // The current state of this CRtVidc.
  113. CDispatch* m_pdispatch; // The dispatcher for this CRtVidc.
  114. };
  115. #endif // RTVIDC_H
  116. //////////////////////////////////////////////////////////////////////////////
  117. // EOF
  118. //////////////////////////////////////////////////////////////////////////////