1 #ifndef openglthread_HEADER_GUARD 2 #define openglthread_HEADER_GUARD 38 #include "openglframefifo.h" 42 #include "threadsignal.h" 46 typedef void ( *PFNGLXSWAPINTERVALEXTPROC) (Display *dpy, GLXDrawable drawable,
int interval);
95 bool isUsed()
const {
return ref_count>0;}
97 bool isDead()
const {
return is_dead;}
100 void inc_ref_count() {ref_count++;}
101 void dec_ref_count() {ref_count--;}
102 void loadFlag(
bool val);
103 void keepFlag(
bool val);
128 const unsigned int z;
141 long int render_mstime, render_mstime_old;
144 std::list<OverlayObject*> overlays;
160 void addRectangle(
float left,
float right,
float top,
float bottom);
163 void renderTexture();
164 void renderObjects();
166 void render(XWindowAttributes x_window_attr);
171 void bindVertexArray();
193 RenderGroup(Display *display_id,
const GLXContext &glc, Window window_id, Window child_id,
bool doublebuffer_flag=
true);
206 Window getWindowId()
const {
return window_id;}
207 const std::list<RenderContext*>& getRenderContexes()
const {
return render_contexes;}
210 std::list<RenderContext*>::iterator getContext(
int id);
229 const static unsigned none =0;
230 const static unsigned ext =1;
231 const static unsigned mesa =2;
232 const static unsigned sgi =3;
280 bool doublebuffer_flag;
285 GLXFBConfig* fbConfigs;
298 PFNGLXSWAPINTERVALEXTPROC pglXSwapIntervalEXT;
299 PFNGLXGETSWAPINTERVALMESAPROC pglXGetSwapIntervalMESA;
300 PFNGLXSWAPINTERVALMESAPROC pglXSwapIntervalMESA;
303 unsigned swap_flavor;
305 unsigned getSwapInterval(GLXDrawable drawable=0);
306 void setSwapInterval(
unsigned i, GLXDrawable drawable=0);
318 bool hasRenderGroup(Window window_id);
320 bool newRenderGroup(Window window_id);
321 bool delRenderGroup(Window window_id);
325 void newRenderContext(SlotNumber slot, Window window_id,
int id,
unsigned int z);
326 bool delRenderContext(
int id);
329 bool contextAddRectangle(
int id,
float left,
float right,
float top,
float bottom);
330 bool contextClearObjects(
int id);
334 void render(SlotNumber n_slot);
335 void checkSlots(
long int mstime);
338 Display* getDisplayId() {
return display_id;}
339 const GLXContext& getGlc() {
return glc;}
340 const Window& getRootId() {
return root_id;}
343 bool slotUsed (SlotNumber i);
344 void activateSlot (SlotNumber i,
YUVFrame *yuvframe);
345 void activateSlotIf (SlotNumber i,
YUVFrame *yuvframe);
346 bool manageSlotTimer(SlotNumber i,
long int mstime);
349 void debugOn() {debug=
true;}
350 void debugOff() {debug=
false;}
360 void handleSignals();
367 void loadExtensions();
369 int hasCompositor(
int screen);
372 void reserveFrames();
373 void releaseFrames();
378 void resetCallTime();
379 void reportCallTime(
unsigned i);
380 long unsigned insertFifo(
Frame* f);
381 void readStaticTex();
387 long unsigned handleFifo();
388 void delRenderContexes();
392 void reportRenderGroups();
393 void reportRenderList();
403 Window createWindow(
bool map=
true,
bool show=
false);
404 void makeCurrent(
const Window window_id);
405 unsigned getVsyncAtStartup();
406 void reConfigWindow(Window window_id);
407 Window getChildWindow(Window parent_id);
411 void setStaticTexFile(
const char* fname);
415 void requestStopCall();
424 bool newRenderGroupCall (Window window_id);
429 bool delRenderGroupCall (Window window_id);
440 int newRenderContextCall (SlotNumber slot, Window window_id,
unsigned int z);
446 bool delRenderContextCall(
int id);
453 void addRectangleCall(
int id,
float left,
float right,
float top,
float bottom);
459 void clearObjectsCall(
int id);
int id
A unique id identifying this render context.
Definition: openglthread.h:130
Window window_id
X window id: render group id.
Definition: openglthread.h:199
std::map< int, RenderContext * > render_contexes
Shortcut to render contexes.
Definition: openglthread.h:293
Group of bitmaps that are rendered into the same X-window.
Definition: openglthread.h:182
std::list< Frame * > presfifo
Double-linked list of buffered frames about to be presented.
Definition: openglthread.h:311
GLuint EBO
id of the element buffer object
Definition: openglthread.h:135
unsigned msbuftime
Buffering time in milliseconds.
Definition: openglthread.h:309
virtual void recycle(Frame *f)
Like FrameFifo::recycle_ but with mutex protection.
Definition: framefifo.cpp:202
A class encapsulating information about an OpenGL texture set for a YUV pixmap (sizes, OpenGL reference ids, etc.)
Definition: tex.h:77
Window child_id
X window id: rendering target.
Definition: openglthread.h:200
virtual void dumpFifo()
Dump frames in the fifo.
Definition: framefifo.cpp:241
YUVFrame * dummyframe
A PBO membuf which we reserve from the GPU as the first membuf, but is never used.
Definition: openglthread.h:287
const GLXContext & glc
GLX Context.
Definition: openglthread.h:198
std::string static_texture_file
Name of the file where statictex is.
Definition: openglthread.h:276
YUVTEX * getTEX()
Returns the relevant texture set (static or live)
Definition: openglthread.cpp:145
std::array< GLuint, 6 > indices
data of the element buffer object
Definition: openglthread.h:138
A GPU YUV frame.
Definition: frame.h:485
Encapsulates data sent by the signal.
Definition: threadsignal.h:130
void checkIfDead(long int mstime)
Compares SlotContext::lastmstime to mstime and changes the state of SlotContext::is_dead.
Definition: openglthread.cpp:119
GLuint VBO
id of the vertex buffer object
Definition: openglthread.h:134
A FrameFifo managed and used by OpenGLThread.
Definition: openglframefifo.h:69
bool isActive() const
Check if active.
Definition: openglthread.h:96
Constant/default values, version numbers.
For AVBitmapFrames, linesizes are the widths + padding bytes.
Definition: constant.h:129
bool load_flag
This flag is cleared when a new frame is loaded.
Definition: openglthread.h:78
long int prev_mstimestamp
for debugging: check if frames are fed in correct timestamp order
Definition: openglthread.h:82
std::array< GLfloat, 16 > transform
data of the transformation matrix
Definition: openglthread.h:136
FifoFrameFilter infilter
A FrameFilter for writing incoming frames.
Definition: openglthread.h:262
RGBShader * rgb_shader
Initialized by OpenGLThread::makeShaders.
Definition: openglthread.h:272
void dumpInFifo()
Incoming fifo: here we have all kinds of frames, including YUVFrame(s)
Definition: openglthread.h:397
Encapsulates data for rendering a single bitmap: vertex array object (VAO), vertex buffer object (VBO...
Definition: openglthread.h:112
const unsigned int z
Stacking order.
Definition: openglthread.h:128
bool is_dead
Has received frames or not for a while ?
Definition: openglthread.h:76
void YUVdiagnosis()
Brief resumen of the state of the YUV Frame stack.
Definition: openglthread.h:396
std::string x_connection
X-server connection string (i.e. ":0.0", ":0.1", etc.
Definition: openglthread.h:263
void dumpYUVStacks()
State of the YUV Frame stack.
Definition: openglthread.h:395
std::vector< SlotContext * > slots_
index => SlotContext mapping (based on vector indices) // WARNING: not they're pointers ...
Definition: openglthread.h:289
void dumpYUVStacks()
Dump frames in OpenGLFrameFifo::yuv_stacks.
Definition: openglframefifo.cpp:223
bool keep_flag
Should we keep on showing the previous frame, even if the slot is_dead?
Definition: openglthread.h:79
Base class for multithreading.
std::array< GLfloat, 20 > vertices
data of the vertex buffer object
Definition: openglthread.h:137
unsigned swap_interval_at_startup
The value of swap interval when this thread was started.
Definition: openglthread.h:304
std::vector< std::list< RenderGroup * > > render_lists
Each vector element corresponds to a slot. Each list inside a vector element has pointers to RenderGr...
Definition: openglthread.h:292
SlotContext(YUVTEX *statictex, YUVShader *shader)
Default constructor.
Definition: openglthread.cpp:51
YUVTEX * yuvtex
This could be a base class for different kinds of textures (now only YUVTEX)
Definition: openglthread.h:67
bool active
Is activated or not. Active = has received a setup frame.
Definition: openglthread.h:75
bool isPending(long int mstime)
Compares SlotContext::lastmstime to mstime and returns true of a treshold is met (if last frame was r...
Definition: openglthread.cpp:130
void recycle(Frame *f)
Recycle a frame back to OpenGLFrameFifo.
Definition: openglthread.h:400
YUVTEX * statictex
Texture to be shown when there is no stream.
Definition: openglthread.h:275
Display * display_id
X display id.
Definition: openglthread.h:197
~SlotContext()
Default destructor.
Definition: openglthread.cpp:55
std::map< Window, RenderGroup > render_groups
window_id => RenderGroup mapping. RenderGroup objects are warehoused here.
Definition: openglthread.h:291
XWindowAttributes x_window_attr
X window size, etc.
Definition: openglthread.h:150
long int callswaptime
Debugging: when handleFifo was last called?
Definition: openglthread.h:312
void YUVdiagnosis()
Brief resumen of OpenGLFrameFifo::yuv_stacks.
Definition: openglframefifo.cpp:239
std::deque< OpenGLSignalContext > signal_fifo
Redefinition of signal fifo. Signal fifo of Thread::SignalContext(s) is now hidden.
Definition: openglthread.h:353
YUVTEX * statictex
A static texture to be shown on the screen if no video is received.
Definition: openglthread.h:68
std::list< RenderContext * > render_contexes
RenderContext instances in ascending z order. User created rendercontexes are warehoused here...
Definition: openglthread.h:202
GLX extensions for controlling the vertical sync / framerate issue are a mess.
Definition: openglthread.h:228
GLuint VAO
id of the vertex array object
Definition: openglthread.h:133
YUVShader * shader
Base class for the chosen Shader for this slot. Now always YUVShader.
Definition: openglthread.h:69
bool manageTimer(long int mstime)
Updates SlotContext::lastmstime. Returns false if too little time has passed since receiving the last...
Definition: openglthread.cpp:105
A class for multithreading with a signaling system.
Definition: thread.h:90
bool doublebuffer_flag
Double buffer rendering or not?
Definition: openglthread.h:201
Frame: An abstract queueable class.
Definition: frame.h:108
Passes frames to a FrameFifo.
Definition: framefilter.h:560
Describes the stack structure and fifo behaviour for an OpenGLFrameFifo.
Definition: openglframefifo.h:45
long int lastmstime
Last millisecond timestamp when this slot received a frame.
Definition: openglthread.h:71
unsigned future_ms_tolerance
If frame is this much in the future, it will be discarded. See OpenGLThread::OpenGLThread for its val...
Definition: openglthread.h:310
void deActivate()
Deallocate textures.
Definition: openglthread.cpp:76
void activate(BitmapPars bmpars)
Allocate SlotContext::yuvtex (for a frame of certain size)
Definition: openglthread.cpp:61
XWindowAttributes x_window_attr
X window attributes.
Definition: openglthread.h:203
AVCodecID codec_id
FFmpeg codec id.
Definition: openglthread.h:77
Handling OpenGL textures.
OpenGLFrameFifo * infifo
This thread reads from this communication fifo.
Definition: openglthread.h:261
This class does a lot of things:
Definition: openglthread.h:247
int getId() const
Returns the unique id of this render context.
Definition: openglthread.h:153
SlotContext * slot_context
Knows relevant Shader and YUVTEX.
Definition: openglthread.h:127
void loadYUVFrame(YUVFrame *yuvframe)
Load bitmap from YUVFrame to SlotContext::yuvtex.
Definition: openglthread.cpp:88
Each Frame carries information about it's slot number in Frame::slot.
Definition: openglthread.h:58
YUVShader * yuv_shader
Initialized by OpenGLThread::makeShaders.
Definition: openglthread.h:271
OpenGL objects, i.e. stuff that can be drawn on the OpenGL canvas on top the textures (boxes...