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