-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathofxThreadedVideo.h
More file actions
180 lines (134 loc) · 3.8 KB
/
ofxThreadedVideo.h
File metadata and controls
180 lines (134 loc) · 3.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
/*
* ofxThreadedVideo.h
* emptyExample
*
* Created by gameover on 2/02/12.
* Copyright 2012 trace media. All rights reserved.
*
*/
#ifndef _H_OFXTHREADEDVIDEO
#define _H_OFXTHREADEDVIDEO
#include <set>
#include <queue>
#include "ofLog.h"
#include "ofConstants.h"
#include "ofPixels.h"
#include "ofTexture.h"
#include "ofThread.h"
#include "ofEvents.h"
#include "ofVideoPlayer.h"
#include "ofAppRunner.h"
enum ofxThreadedVideoEventType{
VIDEO_EVENT_LOAD_OK = 0,
VIDEO_EVENT_LOAD_FAIL,
VIDEO_EVENT_LOAD_BLOCKED,
VIDEO_EVENT_LOAD_THREADBLOCKED
};
class ofxThreadedVideoEvent;
class ofxThreadedVideo : public ofThread {
public:
ofxThreadedVideo();
~ofxThreadedVideo();
void setPlayer(ofPtr<ofBaseVideoPlayer> newPlayer);
ofPtr<ofBaseVideoPlayer> getPlayer();
void setUseAutoPlay(bool b);
bool getUseAutoPlay();
void setUseQueue(bool b);
bool getUseQueue();
bool loadMovie(string name);
void setPixelFormat(ofPixelFormat pixelFormat);
void closeMovie();
void close();
void update();
void play();
void stop();
bool isFrameNew();
unsigned char * getPixels();
ofPixelsRef getPixelsRef();
float getPosition();
float getSpeed();
float getDuration();
bool getIsMovieDone();
void setPosition(float pct);
void setVolume(int volume);
int getVolume();
void setBalance(float balance);
float getBalance();
void setLoopState(ofLoopType state);
int getLoopState();
void setSpeed(float speed);
void setFrame(int frame);
void setUseTexture(bool bUse);
ofTexture & getTextureReference();
void draw(float x, float y, float w, float h);
void draw(float x, float y);
void draw(const ofPoint & p);
void draw(const ofRectangle & r);
void draw();
void setAnchorPercent(float xPct, float yPct);
void setAnchorPoint(float x, float y);
void resetAnchor();
void setPaused(bool bPause);
int getCurrentFrame();
int getTotalNumFrames();
void firstFrame();
void nextFrame();
void previousFrame();
float getHeight();
float getWidth();
bool isPaused();
bool isLoaded();
bool isPlaying();
//float width, height;
string getName();
string getPath();
double getFrameRate();
ofEvent<ofxThreadedVideoEvent> threadedVideoEvent;
string getEventTypeAsString(ofxThreadedVideoEventType eventType);
protected:
void threadedFunction();
private:
static const int VIDEO_NONE = -1;
static const int VIDEO_FLIP = 0;
static const int VIDEO_FLOP = 1;
void updatePixels(int videoID);
void updateTexture(int videoID);
void updateVideo(int videoID);
int getNextLoadID();
int loadVideoID;
int currentVideoID;
string loadPath;
float newPosition[2];
int newFrame[2];
int volume[2];
float balance[2];
bool bPaused[2];
float newSpeed[2];
int newLoopType[2];
int frame[2];
bool bUseAutoPlay;
bool bUseQueue;
bool bUseTexture;
queue<string> pathsToLoad;
string paths[2];
string names[2];
bool bFrameNew[2];
ofPixels * pixels[2];
ofTexture textures[2];
ofVideoPlayer videos[2];
ofPixelFormat internalPixelFormat;
double prevMillis, lastFrameTime, timeNow, timeThen, fps, frameRate;
// block copy ctor and assignment operator
ofxThreadedVideo(const ofxThreadedVideo& other);
ofxThreadedVideo& operator=(const ofxThreadedVideo&);
};
class ofxThreadedVideoEvent{
public:
ofxThreadedVideoEvent(string _path, ofxThreadedVideoEventType _eventType, ofxThreadedVideo * _video)
: path(_path), eventType(_eventType), video(_video){eventTypeAsString = _video->getEventTypeAsString(_eventType);};
string path;
string eventTypeAsString;
ofxThreadedVideoEventType eventType;
ofxThreadedVideo * video;
};
#endif