Valkka  0.17.0
OpenSource Video Management
openglframefifo.h
1 #ifndef openglframefifo_HEADER_GUARD
2 #define openglframefifo_HEADER_GUARD
3 /*
4  * openglframefifo.h : FrameFifo for OpenGLThread: stack of YUV frames and uploading to GPU
5  *
6  * Copyright 2017, 2018 Valkka Security Ltd. and Sampsa Riikonen.
7  *
8  * Authors: Sampsa Riikonen <sampsa.riikonen@iki.fi>
9  *
10  * This file is part of the Valkka library.
11  *
12  * Valkka is free software: you can redistribute it and/or modify
13  * it under the terms of the GNU Affero General Public License as
14  * published by the Free Software Foundation, either version 3 of the
15  * License, or (at your option) any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU Affero General Public License for more details.
21  *
22  * You should have received a copy of the GNU Affero General Public License
23  * along with this program. If not, see <https://www.gnu.org/licenses/>
24  *
25  */
26 
37 #include "opengl.h"
38 #include "framefilter.h"
39 
45 struct OpenGLFrameFifoContext { // <pyapi>
46  OpenGLFrameFifoContext() : n_720p(20), n_1080p(20), n_1440p(20), n_4K(20), n_setup(20), n_signal(20), flush_when_full(DEFAULT_OPENGLFRAMEFIFO_FLUSH_WHEN_FULL) {}; // <pyapi>
47  int n_720p; // <pyapi>
48  int n_1080p; // <pyapi>
49  int n_1440p; // <pyapi>
50  int n_4K; // <pyapi>
51  int n_setup;
52  int n_signal;
54 }; // <pyapi>
55 
56 
57 std::ostream& operator<< (std::ostream& os, const OpenGLFrameFifoContext& ctx) {
58  return os << "720p: " << ctx.n_720p <<" / 1080p: " << ctx.n_1080p << " / 1440p: " << ctx.n_1440p << " / 4K: " << ctx.n_4K << " / n_setup: " << ctx.n_setup << " / n_signal: " << ctx.n_signal << " / flush_when_full: " << int(ctx.flush_when_full);
59 }
60 
61 
69 class OpenGLFrameFifo : public FrameFifo {
70 
71 friend class OpenGLThread; // can manipulate reservoirs, stacks, etc.
72 
73 public:
80  ~OpenGLFrameFifo();
81 
82 protected:
84  std::map<BitmapType,YUVReservoir> yuv_reservoirs;
85  std::map<BitmapType,YUVStack> yuv_stacks;
86  // note: we still have "reservoirs" and "stacks" inherited from FrameFifo
87 
88 protected:
89  YUVFrame* prepareAVBitmapFrame(AVBitmapFrame* frame);
90 
91 public: // redefined virtual
92  virtual bool writeCopy(Frame* f, bool wait=false);
93  virtual void recycle_(Frame* f);
94 
95 public:
96  void allocateYUV();
97  void deallocateYUV();
98  void dumpYUVStacks();
99  void YUVdiagnosis();
100 
101 public: // setters
102  void debugOn() {debug=true;}
103  void debugOff(){debug=false;}
104 
105 private:
106  bool debug;
107 };
108 
109 #endif
int n_signal
signals OpenGLThread // <pyapi>
Definition: openglframefifo.h:52
A GPU YUV frame.
Definition: frame.h:485
int n_setup
setup data // <pyapi>
Definition: openglframefifo.h:51
A FrameFifo managed and used by OpenGLThread.
Definition: openglframefifo.h:69
std::map< BitmapType, YUVReservoir > yuv_reservoirs
Instances of YUVFrame s.
Definition: openglframefifo.h:84
A thread-safe combination of a fifo (first-in-first-out) queue and an associated stack.
Definition: framefifo.h:72
OpenGL calls for reserving PBOs and TEXtures, plus some auxiliary routines.
void YUVdiagnosis()
Brief resumen of the state of the YUV Frame stack.
Definition: openglthread.h:396
void dumpYUVStacks()
State of the YUV Frame stack.
Definition: openglthread.h:395
std::map< BitmapType, YUVStack > yuv_stacks
Pointers to Frames s in the reservoirs.
Definition: openglframefifo.h:85
Definition of FrameFilter and derived classes for various purposes.
Decoded YUV/RGB frame in FFMpeg format.
Definition: frame.h:354
Frame: An abstract queueable class.
Definition: frame.h:108
OpenGLFrameFifoContext gl_ctx
Stack profile and overflow behaviour.
Definition: openglframefifo.h:83
Describes the stack structure and fifo behaviour for an OpenGLFrameFifo.
Definition: openglframefifo.h:45
This class does a lot of things:
Definition: openglthread.h:247
bool flush_when_full
Flush when filled // <pyapi>
Definition: openglframefifo.h:53