VIDEO.H 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  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 CVIDEO_H
  19. #define CVIDEO_H
  20. //////////////////////////////////////////////////////////////////////////////
  21. // Constants
  22. //////////////////////////////////////////////////////////////////////////////
  23. // Error codes.
  24. #define VIDEO_SUCCESS ((short)0)
  25. #define VIDEO_ERR_GENERIC ((short)1)
  26. #define VIDEO_ERR_VIDEO_UNSUPPORTED ((short)2)
  27. #define VIDEO_ERR_CREATE ((short)3)
  28. #define VIDEO_ERR_OPEN ((short)4)
  29. #define VIDEO_ERR_PLAY ((short)5)
  30. #define VIDEO_ERR_PAUSE ((short)6)
  31. #define VIDEO_ERR_RESUME ((short)7)
  32. #define VIDEO_ERR_STOP ((short)8)
  33. #define VIDEO_ERR_CLOSE ((short)9)
  34. #define VIDEO_ERR_ALREADY_CREATED ((short)10)
  35. #define VIDEO_ERR_GETTING_WRECT ((short)11)
  36. #define VIDEO_ERR_RESIZE_FAIL ((short)12)
  37. #define VIDEO_ERR_SET_FRAMES ((short)13)
  38. #define VIDEO_ERR_SET_TIME ((short)14)
  39. // Clipping modes.
  40. #define MODE_NORMAL ((short)0) // no clipping
  41. #define MODE_CLIP ((short)1) // clip
  42. #define MODE_STRETCH ((short)2) // stretch/shrink to fit
  43. // Play modes.
  44. #define PLAY_ALL ((short)0) // Play the entire video from begin to end
  45. #define PLAY_SELECTION_TIME ((short)1) // Play a selection specified in milliseconds
  46. #define PLAY_SELECTION_FRAME ((short)2) // Play a selection specified in frames
  47. class CVideo
  48. {
  49. // Constructor/Destructor
  50. public:
  51. // Default constructor.
  52. CVideo(void);
  53. // Extended constructor which also creates the playback window.
  54. CVideo(char* szFilename, // filename of the video
  55. long x, // left edge of playback window
  56. long y, // top of the playback window
  57. long w, // width of the playback window
  58. long h, // height of the playback window
  59. short sClip); // clipping flag
  60. // Default destructor.
  61. ~CVideo(void);
  62. // Implementation
  63. public:
  64. // Create a window which requests the digital video device.
  65. short Create(void);
  66. // Destroy the window and free the digital video device.
  67. void Destroy(void);
  68. // Open a video file and create the playback window.
  69. short Open(char* szFileName, // name of the video file
  70. long x, // left edge of the playback window
  71. long y, // top of the playback window
  72. long w, // width of the playback window
  73. long h, // height of the playback window
  74. short sClip); // clipping flag, use following values:
  75. // 0: no clipping, window will be resized to
  76. // actual video's size.
  77. // 1: video will be clipped to the size supplied.
  78. // 2: video will not be clipped, video will be
  79. // stretched/shrinked to the window's size.
  80. // Close a video file. Will abort the current video file, if playing.
  81. short Close(void);
  82. // Play the current video. Currently, when this function is called, the video will be played
  83. // from begin to end. Possible future functionality may include setting from/to selections,
  84. // repeat characteristics, etc. For now, just plain play the darn video.
  85. // The next day: I realize that we need additional functionality for playing segments within
  86. // the video. This could be accomplished with 3 parameters, all of which could be left out
  87. // for default operation.
  88. // sMode: 0 - default operation, lStart/lEnd ignored
  89. // 1 - lStart and lEnd specified as time (milliseconds)
  90. // 2 - lStart and lEnd specified as number of frames.
  91. short Play(short sMode = 0, long lStart = 0, long lEnd = 0);
  92. // Pause the current video. This function must be used if you wish to pause the video. Stop
  93. // is not the same as this function.
  94. short Pause(void);
  95. // Resume the current video. The video must have been previously paused.
  96. short Resume(void);
  97. // Stop the current video. This, in effective, will reset the position to the beginning of the
  98. // video.
  99. short Stop(void);
  100. // Get the current frame number of the video.
  101. long GetFrame(void);
  102. // Get the current position of the video (in milliseconds).
  103. long GetPosition(void);
  104. // The following few functions return status/progress information about the current video.
  105. // If the status requested is valid, TRUE will be returned - FALSE otherwise.
  106. short IsOpened(void); // TRUE if a video is currently opened.
  107. short IsPlaying(void); // TRUE if the current video is playing.
  108. short IsPaused(void); // TRUE if the current video was paused.
  109. short IsStopped(void); // TRUE if the current video was stopped but not paused.
  110. private:
  111. void Init(void);
  112. long TraceMCIError(char* szErrOrigin);
  113. // Data
  114. private:
  115. ULONG m_ulDeviceID;
  116. long m_lhwnd;
  117. };
  118. #endif