Valkka  1.6.1
OpenSource Video Management
frame.h
Go to the documentation of this file.
1 #ifndef frame_HEADER_GUARD
2 #define frame_HEADER_GUARD
3 
4 /*
5  * frame.h : Frame classes
6  *
7  * Copyright 2017-2020 Valkka Security Ltd. and Sampsa Riikonen
8  *
9  * Authors: Sampsa Riikonen <sampsa.riikonen@iki.fi>
10  *
11  * This file is part of the Valkka library.
12  *
13  * Valkka is free software: you can redistribute it and/or modify
14  * it under the terms of the GNU Lesser General Public License as
15  * published by the Free Software Foundation, either version 3 of the
16  * License, or (at your option) any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU Lesser General Public License for more details.
22  *
23  * You should have received a copy of the GNU Lesser General Public License
24  * along with this program. If not, see <https://www.gnu.org/licenses/>
25  *
26  */
27 
37 #include "common.h"
38 #include "codec.h"
39 #include "metadata.h"
40 #include "threadsignal.h"
41 #include "constant.h"
42 #include "avdep.h"
43 #include "opengl.h"
44 #include "tools.h"
45 #include "macro.h"
46 #include "rawrite.h"
47 
52 enum class FrameClass
53 {
54  none,
55 
56  basic,
57 
58  avpkt,
59 
60  avmedia,
61  avbitmap,
62  // avbitmap_np, ///< child of avmedia: video, non-planar
63 
64  avaudio,
65 
66  avrgb,
67 
68  yuv,
69 
70  rgb,
71 
72  setup,
73  signal,
74 
75  marker,
76 
77  mux,
78 
79  First = none,
80  Last = mux
81 };
82 
86 enum class TimeCorrectionType // <pyapi>
87 { // <pyapi>
88  none, // <pyapi>
89  smart, // <pyapi>
90  dummy // <pyapi>
91 }; // <pyapi>
92 
111 class Frame
112 {
113 
114 public:
115  Frame();
116  virtual ~Frame();
117  frame_essentials(FrameClass::none, Frame);
118  frame_clone(FrameClass::none, Frame);
119  /*Frame(const Frame &f); ///< Default copy ctor
120 
121 
122 public: // frame essentials : must be defined for each frame subclass
123  virtual FrameClass getFrameClass(); ///< Returns the subclass frame type. See Frame::frameclass
124  virtual void copyFrom(Frame *f); ///< Copies data to this frame from a frame of the same type (also metadata)
125  */
126 
127 public: // redefined virtual
128  virtual void print(std::ostream &os) const;
129  virtual std::string dumpPayload();
130  virtual void dumpPayloadToFile(std::ofstream &fout);
131  virtual void updateAux();
132  virtual void update();
133  virtual void reset();
134  virtual bool isSeekable();
135 
136 public:
137  void copyMetaFrom(Frame *f);
138 
139 protected:
141 
142 public: // public metadata
143  SlotNumber n_slot;
145  long int mstimestamp;
146 };
147 
148 inline std::ostream &operator<<(std::ostream &os, const Frame &f)
149 {
150  // https://stackoverflow.com/questions/4571611/making-operator-virtual
151  f.print(os);
152  return os;
153 }
154 
165 class BasicFrame : public Frame
166 {
167 
168 public:
169  BasicFrame();
170  virtual ~BasicFrame();
171  frame_essentials(FrameClass::basic, BasicFrame);
172  frame_clone(FrameClass::basic, BasicFrame);
173  /*BasicFrame(const BasicFrame &f); ///< Default copy ctor
174 
175 public: // frame essentials
176  virtual FrameClass getFrameClass(); ///< Returns the subclass frame type. See Frame::frameclass
177  virtual void copyFrom(Frame *f); ///< Copies data to this frame from a frame of the same type
178  */
179 
180 public: // redefined virtual
181  virtual void print(std::ostream &os) const;
182  virtual std::string dumpPayload();
183  virtual void dumpPayloadToFile(std::ofstream &fout);
184  virtual void reset();
185  virtual bool isSeekable();
186 
187 public: // payload handling
188  void reserve(std::size_t n_bytes);
189  void resize(std::size_t n_bytes);
190 
191 public: // frame variables
192  std::vector<uint8_t> payload;
193  AVMediaType media_type;
194  AVCodecID codec_id;
195 
196 public: // codec-dependent parameters
198 
199 public: // codec-dependent functions
200  void fillPars();
201  void fillH264Pars();
202 
203 public:
204  void fillAVPacket(AVPacket *avpkt);
205  void copyFromAVPacket(AVPacket *avpkt);
206  void filterFromAVPacket(AVPacket *avpkt, AVCodecContext *codec_ctx, AVBitStreamFilterContext *filter);
207 
208 public: // frame serialization
209  std::size_t calcSize();
210  bool dump(IdNumber device_id, RaWriter &raw_writer);
211  IdNumber read(RawReader &raw_reader);
212 };
213 
220 class MuxFrame : public Frame {
221 
222 public:
223  MuxFrame();
224  virtual ~MuxFrame();
225  frame_essentials(FrameClass::mux, MuxFrame);
226  frame_clone(FrameClass::mux, MuxFrame);
227 
228 public: // redefined virtual
229  virtual void print(std::ostream& os) const;
230  virtual std::string dumpPayload();
231  virtual void dumpPayloadToFile(std::ofstream& fout);
232  virtual void reset();
233  //virtual bool isSeekable(); ///< Can we seek to this frame?
234 
235 /*
236 public:
237  virtual bool isInit(); ///< for frag-MP4: ftyp, moov
238  virtual bool isMeta(); ///< for frag-MP4: moof
240 */
241 
242 public: // payload handling
243  void reserve(std::size_t n_bytes);
244  void resize(std::size_t n_bytes);
245 
246 public:
247  std::vector<uint8_t> payload;
248  AVMediaType media_type;
249  AVCodecID codec_id;
250 
251 public:
252  std::vector<uint8_t> meta_blob;
254 };
255 
256 
257 enum class SetupFrameType
258 {
259  none,
260  stream_init,
261  stream_state
262 };
263 
276 class SetupFrame : public Frame
277 {
278 
279 public:
280  SetupFrame();
281  virtual ~SetupFrame();
282  frame_essentials(FrameClass::setup, SetupFrame);
283  frame_clone(FrameClass::setup, SetupFrame);
284  /*
285  SetupFrame(const SetupFrame &f); ///< Default copy ctor
286 
287 public: // frame essentials
288  virtual FrameClass getFrameClass(); ///< Returns the subclass frame type. See Frame::frameclass
289  virtual void copyFrom(Frame *f); ///< Copies data to this frame from a frame of the same type
290  */
291 
292 public: // redefined virtual
293  virtual void print(std::ostream &os) const;
294  virtual void reset();
295 
296 public: // managed objects
297  SetupFrameType sub_type;
298 
299  AVMediaType media_type;
300  AVCodecID codec_id;
301 
303 };
304 
314 class AVMediaFrame : public Frame
315 {
316 
317 public:
318  AVMediaFrame();
319  virtual ~AVMediaFrame();
320  //frame_essentials(FrameClass::avmedia,AVMediaFrame); // now this is a virtual class ..
321  //frame_clone(FrameClass::avmedia,AVMediaFrame);
322  /*AVMediaFrame(const AVMediaFrame &f); ///< Default copy ctor
323 
324  public: // frame essentials
325  virtual FrameClass getFrameClass(); ///< Returns the subclass frame type. See Frame::frameclass
326  virtual void copyFrom(Frame *f); ///< Copies data to this frame from a frame of the same type
327  */
328 
329 /*
330 public:
331  virtual void updateAux() = 0; ///< update any helper objects
332  virtual void update() = 0;
333 */
334 
335 public: // redefined virtual
336  virtual std::string dumpPayload();
337  virtual void print(std::ostream &os) const;
338  virtual void reset();
339 
340 public: // helper objects : values should correspond to member av_frame
341  AVMediaType media_type;
342  AVCodecID codec_id;
343 
344 public: // managed objects
345  AVFrame *av_frame;
346 };
347 
361 {
362 
363 public:
364  AVBitmapFrame();
365  virtual ~AVBitmapFrame();
366  frame_essentials(FrameClass::avbitmap, AVBitmapFrame);
367  frame_clone(FrameClass::avbitmap, AVBitmapFrame); // TODO: think about this!
368  /*
369  AVBitmapFrame(const AVBitmapFrame &f); ///< Default copy ctor
370 
371 public: // frame essentials
372  virtual FrameClass getFrameClass(); ///< Returns the subclass frame type. See Frame::frameclass
373  virtual void copyFrom(Frame *f); ///< Copies data to this frame from a frame of the same type
374  */
375 
376 public: // redefined virtual
377  virtual std::string dumpPayload();
378  virtual void print(std::ostream &os) const;
379  virtual void reset();
380  virtual void copyPayloadFrom(AVBitmapFrame *frame);
381  virtual void updateAux();
382  virtual void update();
383  virtual void reserve(int width, int height);
384 
385 public: // helper objects
386  AVPixelFormat av_pixel_format;
388  uint8_t *y_payload;
389  uint8_t *u_payload;
390  uint8_t *v_payload;
391 };
392 
436 class AVRGBFrame : public AVBitmapFrame
437 {
438 
439 public:
440  AVRGBFrame();
441  virtual ~AVRGBFrame();
442  frame_essentials(FrameClass::avrgb, AVRGBFrame);
443  frame_clone(FrameClass::avrgb, AVRGBFrame); // TODO: think about this!
444 
445 public:
446  virtual void reserve(int width, int height);
447 
448 public: // redefined virtual
449  virtual std::string dumpPayload();
450  virtual void print(std::ostream &os) const;
451 };
452 
453 /*
454 class AVAudioFrame : public AVMediaFrame {
455 
456 public:
457  AVAudioFrame();
458  virtual ~AVAudioFrame();
459 
460 public: // frame essentials
461  virtual FrameClass getFrameClass(); ///< Returns the subclass frame type. See Frame::frameclass
462  virtual void copyFrom(Frame *f); ///< Copies data to this frame from a frame of the same type
463  virtual std::string dumpPayload();
464  virtual void print(std::ostream& os) const; ///< How to print this frame to output stream
465 
466 public:
467  virtual void getParametersDecoder(const AVCodecContext *ctx); ///< Extract sample rate
468 
469 public: // ffmpeg media parameters
470  AVSampleFormat av_sample_fmt;
471 };
472 */
473 
474 // Decoder gives AVBitmapFrame => OpenGLThread internal FrameFilter => OpenGLThread FrameFifo::writeCopy(Frame *f) => .. returns once a copy has been made
475 
491 class YUVFrame : public Frame
492 {
493 
494 public:
495  YUVFrame(BitmapPars bmpars);
496  virtual ~YUVFrame();
497  frame_essentials(FrameClass::yuv, YUVFrame);
498  // TODO: frame_clone
499  /*
500  YUVFrame(const YUVFrame &f); ///< Default copy ctor
501 
502 public: // frame essentials
503  virtual FrameClass getFrameClass(); ///< Returns the subclass frame type. See Frame::frameclass
504  virtual void copyFrom(Frame *f); ///< Copies data to this frame from a frame of the same type
505 
506  */
507 
508 public: // variables filled at constructor time
509  BitmapPars bmpars; // the maximum, pre-reserved size
510  BitmapPars source_bmpars; // the actual size of the image
511 
512 private:
513  void reserve();
514  void release();
515 
516 public: // variables used/filled by reserve
517  GLuint y_index;
518  GLuint u_index;
519  GLuint v_index;
520 
521 private:
522  GLubyte *y_payload;
523  GLubyte *u_payload;
524  GLubyte *v_payload;
525 
526 public: // redefined virtual
527  virtual std::string dumpPayload();
528  virtual void print(std::ostream &os) const;
529  virtual void reset();
530 
531 public:
533 };
534 
541 class RGBFrame : public Frame
542 {
543 
544 public:
545  RGBFrame(int max_width, int max_height);
546  virtual ~RGBFrame();
547  frame_essentials(FrameClass::rgb, RGBFrame);
548 
549 private:
550  std::vector<uint8_t> payload;
551  int max_width, max_height;
552  int width, height;
553 
554 public: // redefined virtual
555  virtual std::string dumpPayload();
556  virtual void print(std::ostream &os) const;
557  virtual void reset();
558 
559 public:
560  void fromAVRGBFrame(AVRGBFrame *f);
561 };
562 
563 typedef std::vector<Frame *> Reservoir;
564 typedef std::deque<Frame *> Stack;
565 typedef std::deque<Frame *> Fifo;
566 typedef std::deque<Frame *> Cache;
567 
568 typedef std::vector<YUVFrame *> YUVReservoir;
569 typedef std::deque<YUVFrame *> YUVStack;
570 typedef std::vector<RGBFrame *> RGBReservoir;
571 typedef std::deque<RGBFrame *> RGBStack;
572 
573 
588 class SignalFrame : public Frame
589 {
590 
591 public:
592  SignalFrame();
593  virtual ~SignalFrame();
594  frame_essentials(FrameClass::signal, SignalFrame);
595  frame_clone(FrameClass::signal, SignalFrame);
596 
597 public:
598  unsigned signaltype;
599 
600 public:
605  // TODO: those ctxes should be written with the new technique:
606  // this generalizes & is copyable
607  std::vector<uint8_t> signal_ctx_buf;
608  /* example of the (revised) signal handling
609  if (signalframe->signaltype==SignalType::offline) {
610  OfflineSignalContext ctx = OfflineSignalContext();
611  get_signal_context(signalframe, ctx);
612  # that's a macro: take a look at macro.h
613  }
614  */
615 
616 public:
617  virtual void reset();
618 
619 };
620 
621 class MarkerFrame : public Frame
622 {
623 
624 public:
625  MarkerFrame();
626  virtual ~MarkerFrame();
627  frame_essentials(FrameClass::marker, MarkerFrame);
628  frame_clone(FrameClass::marker, MarkerFrame);
629 
630 public: // redefined virtual
631  // virtual std::string dumpPayload();
632  virtual void print(std::ostream &os) const;
633  virtual void reset();
634 
635 public:
636  bool fs_start, fs_end;
637  bool tm_start, tm_end;
638 };
639 
640 #endif
FrameClass::avpkt
@ avpkt
data at ffmpeg avpkt
YUVFrame::u_payload
GLubyte * u_payload
direct memory access memory address, returned by GPU
Definition: frame.h:523
SetupFrame::reset
virtual void reset()
Reset the internal data.
Definition: frame.cpp:386
RGBFrame::dumpPayload
virtual std::string dumpPayload()
Dumps internal payload data.
Definition: frame.cpp:853
constant.h
Constant/default values, version numbers.
ValkkaFSWriterSignalContext
Encapsulate data sent in the ValkkaFSWriterSignal.
Definition: threadsignal.h:184
TimeCorrectionType
TimeCorrectionType
Methods to correct frame timestamps.
Definition: frame.h:86
AVBitmapFrame::bmpars
BitmapPars bmpars
Calculated bitmap plane dimensions, data sizes, etc.
Definition: frame.h:387
BasicFrame::fillPars
void fillPars()
Fill codec-dependent parameters based on the payload.
Definition: frame.cpp:164
MuxFrame::meta_blob
std::vector< uint8_t > meta_blob
Byte blob that is casted to correct metadata struct.
Definition: frame.h:252
YUVFrame::v_index
GLuint v_index
internal OpenGL/GPU index
Definition: frame.h:519
BasicFrame::BasicFrame
BasicFrame()
Default ctor.
Definition: frame.cpp:89
MarkerFrame::print
virtual void print(std::ostream &os) const
How to print this frame to output stream.
Definition: frame.cpp:917
Frame::dumpPayloadToFile
virtual void dumpPayloadToFile(std::ofstream &fout)
Dumps internal payload data into a file.
Definition: frame.cpp:63
AVRGBFrame::print
virtual void print(std::ostream &os) const
How to print this frame to output stream.
Definition: frame.cpp:622
Frame::frameclass
FrameClass frameclass
Declares frametype for correct typecast. Used by Frame::getFrameClass()
Definition: frame.h:140
MuxMetaType
MuxMetaType
Definition: metadata.h:46
RawReader
Definition: rawrite.h:96
SignalFrame::av_signal_ctx
AVSignalContext av_signal_ctx
Thread commands to AVThread.
Definition: frame.h:602
MuxFrame::print
virtual void print(std::ostream &os) const
Produces frame output.
Definition: frame.cpp:323
FrameClass::rgb
@ rgb
our own RGB24 data structure
ValkkaFSReaderSignalContext
Encapsulate data sent in the ValkkaFSReaderSignal.
Definition: threadsignal.h:219
BasicFrame::isSeekable
virtual bool isSeekable()
for H264 true if sps, other codecs, always true
Definition: frame.cpp:128
AVBitmapFrame::print
virtual void print(std::ostream &os) const
How to print this frame to output stream.
Definition: frame.cpp:477
RGBFrame::payload
std::vector< uint8_t > payload
RGB24 data as continuous bytes. 3 bytes per pixel.
Definition: frame.h:550
YUVFrame::print
virtual void print(std::ostream &os) const
How to print this frame to output stream.
Definition: frame.cpp:830
Frame::isSeekable
virtual bool isSeekable()
Can we seek to this frame? (e.g. is it a key-frame .. for H264 sps packets are used as seek markers)
Definition: frame.cpp:73
FrameClass::yuv
@ yuv
data at the GPU
rawrite.h
Write directly to files and devices with POSIX O_DIRECT.
BasicFrame::resize
void resize(std::size_t n_bytes)
Init space for internal payload.
Definition: frame.cpp:159
SetupFrame::SetupFrame
SetupFrame()
Default ctor.
Definition: frame.cpp:364
MuxFrame::~MuxFrame
virtual ~MuxFrame()
Default virtual dtor.
Definition: frame.cpp:319
AVMediaFrame::codec_id
AVCodecID codec_id
helper object: codec id
Definition: frame.h:342
AVBitmapFrame::y_payload
uint8_t * y_payload
shortcut to AVMediaFrame::av_frame->data[0]
Definition: frame.h:388
Frame::print
virtual void print(std::ostream &os) const
Produces frame output.
Definition: frame.cpp:46
SignalFrame::opengl_signal_ctx
OpenGLSignalContext opengl_signal_ctx
< For making correct typecast of custom_ctx_buf. See also threadsignal.h
Definition: frame.h:601
YUVFrame::v_payload
GLubyte * v_payload
direct memory access memory address, returned by GPU
Definition: frame.h:524
AVBitmapFrame
Decoded YUV/RGB frame in FFMpeg format.
Definition: frame.h:360
SetupFrame::stream_state
AbstractFileState stream_state
For subtype stream_state.
Definition: frame.h:302
MarkerFrame::~MarkerFrame
virtual ~MarkerFrame()
Default virtual dtor.
Definition: frame.cpp:913
SignalFrame
A frame, signaling internal thread commands, states of recorded video, etc.
Definition: frame.h:588
FrameClass::avaudio
@ avaudio
child of avmedia: audio
FrameClass::setup
@ setup
setup data
SignalFrame::signal_ctx_buf
std::vector< uint8_t > signal_ctx_buf
A byte-buffer where the signal context is serialized.
Definition: frame.h:607
AVRGBFrame::dumpPayload
virtual std::string dumpPayload()
Dumps internal payload data.
Definition: frame.cpp:599
BasicFrame::print
virtual void print(std::ostream &os) const
How to print this frame to output stream.
Definition: frame.cpp:98
BasicFrame::reset
virtual void reset()
Reset the internal data.
Definition: frame.cpp:121
BasicFrame::~BasicFrame
virtual ~BasicFrame()
Default virtual dtor.
Definition: frame.cpp:93
FrameClass::none
@ none
unknown
FrameClass::avbitmap
@ avbitmap
child of avmedia: video
codec.h
Codec definitions (slightly outdated)
SetupFrame::sub_type
SetupFrameType sub_type
Type of the SetupFrame.
Definition: frame.h:297
BasicFrame::filterFromAVPacket
void filterFromAVPacket(AVPacket *avpkt, AVCodecContext *codec_ctx, AVBitStreamFilterContext *filter)
Copy data from AVPacket structure.
Definition: frame.cpp:212
Frame
Frame: An abstract queueable class.
Definition: frame.h:111
YUVFrame::dumpPayload
virtual std::string dumpPayload()
Dumps internal payload data.
Definition: frame.cpp:804
AVBitmapFrame::~AVBitmapFrame
virtual ~AVBitmapFrame()
Default virtual dtor.
Definition: frame.cpp:433
BasicFrame::codec_id
AVCodecID codec_id
AVCodeCID of the media.
Definition: frame.h:194
Frame::copyMetaFrom
void copyMetaFrom(Frame *f)
Copy metadata (slot, subsession index, timestamp) to this frame.
Definition: frame.cpp:51
BasicFrame::reserve
void reserve(std::size_t n_bytes)
Reserve space for internal payload.
Definition: frame.cpp:154
YUVFrame::release
void release()
Releases data on the GPU. Used by the destructor only.
Definition: frame.cpp:710
MuxFrame::payload
std::vector< uint8_t > payload
Raw payload data (use .data() to get the pointer from std::vector)
Definition: frame.h:247
YUVFrame::fromAVBitmapFrame
void fromAVBitmapFrame(AVBitmapFrame *f)
Copies data to the GPU from AVBitmapFrame.
Definition: frame.cpp:719
FrameClass::avrgb
@ avrgb
rgb interpolated from yuv
BasicFrame
Custom payload Frame.
Definition: frame.h:165
Frame::dumpPayload
virtual std::string dumpPayload()
Dumps internal payload data.
Definition: frame.cpp:58
SetupFrame::codec_id
AVCodecID codec_id
For subtype stream_init.
Definition: frame.h:300
AVMediaFrame::~AVMediaFrame
virtual ~AVMediaFrame()
Default virtual dtor.
Definition: frame.cpp:398
RGBFrame
Our own RGB24 structure.
Definition: frame.h:541
RGBFrame::reset
virtual void reset()
Reset the internal data.
Definition: frame.cpp:873
BasicFrame::copyFromAVPacket
void copyFromAVPacket(AVPacket *avpkt)
Copy data from AVPacket structure.
Definition: frame.cpp:202
AVMediaFrame::media_type
AVMediaType media_type
helper object: media type
Definition: frame.h:341
AVBitmapFrame::reserve
virtual void reserve(int width, int height)
Reserves space for underlying av_frame.
Definition: frame.cpp:555
AbstractFileState
AbstractFileState
Describes the state of a stream.
Definition: threadsignal.h:42
AVMediaFrame
Decoded Frame in FFmpeg format.
Definition: frame.h:314
FrameClass
FrameClass
Enumeration of Frame classes used by Valkka.
Definition: frame.h:52
AVBitmapFrame::reset
virtual void reset()
Reset the internal data.
Definition: frame.cpp:467
BasicFrame::fillH264Pars
void fillH264Pars()
Inspects payload and fills BasicFrame::h264_pars;.
Definition: frame.cpp:171
AVBitmapFrame::v_payload
uint8_t * v_payload
shortcut to AVMediaFrame::av_frame->data[2]
Definition: frame.h:390
AVBitmapFrame::AVBitmapFrame
AVBitmapFrame()
Default ctor.
Definition: frame.cpp:429
SetupFrame::~SetupFrame
virtual ~SetupFrame()
Default virtual dtor.
Definition: frame.cpp:369
Frame::updateAux
virtual void updateAux()
Update internal auxiliary state variables.
Definition: frame.cpp:79
MarkerFrame::fs_end
bool fs_end
Filesystem start / end // this controlled better at the python level.
Definition: frame.h:636
SetupFrame
Setup frame.
Definition: frame.h:276
AVBitmapFrame::dumpPayload
virtual std::string dumpPayload()
Dumps internal payload data.
Definition: frame.cpp:440
MuxFrame::dumpPayloadToFile
virtual void dumpPayloadToFile(std::ofstream &fout)
Dumps internal payload data into a file.
Definition: frame.cpp:339
YUVFrame::y_payload
GLubyte * y_payload
direct memory access memory address, returned by GPU
Definition: frame.h:522
Frame::Frame
Frame()
Default ctor.
Definition: frame.cpp:38
MuxFrame::reserve
void reserve(std::size_t n_bytes)
Reserve space for internal payload.
Definition: frame.cpp:352
YUVFrame::YUVFrame
YUVFrame(BitmapPars bmpars)
Default ctor.
Definition: frame.cpp:672
BasicFrame::payload
std::vector< uint8_t > payload
Raw payload data (use .data() to get the pointer from std::vector)
Definition: frame.h:192
MuxFrame
A muxed packet (in some container format)
Definition: frame.h:220
YUVFrame
A GPU YUV frame.
Definition: frame.h:491
MuxFrame::media_type
AVMediaType media_type
Type of the media (video/audio) of the underlying elementary stream.
Definition: frame.h:248
AVSignalContext
Redefinition of characteristic signal contexts (info that goes with the signal) for AVThread thread.
Definition: threadsignal.h:93
MuxFrame::resize
void resize(std::size_t n_bytes)
Init space for internal payload.
Definition: frame.cpp:358
SignalFrame::~SignalFrame
virtual ~SignalFrame()
Default virtual dtor.
Definition: frame.cpp:906
RGBFrame::fromAVRGBFrame
void fromAVRGBFrame(AVRGBFrame *f)
Copies data from (temporary) AVRGBFrame .. set the width & height members.
Definition: frame.cpp:880
BasicFrame::dump
bool dump(IdNumber device_id, RaWriter &raw_writer)
Write the frame to filestream with a certain device id.
Definition: frame.cpp:247
YUVFrame::reset
virtual void reset()
Reset the internal data.
Definition: frame.cpp:837
SetupFrame::print
virtual void print(std::ostream &os) const
How to print this frame to output stream.
Definition: frame.cpp:374
Frame::subsession_index
int subsession_index
Media subsession index.
Definition: frame.h:144
BasicFrame::dumpPayload
virtual std::string dumpPayload()
Dumps internal payload data.
Definition: frame.cpp:107
YUVFrame::~YUVFrame
virtual ~YUVFrame()
Default virtual dtor.
Definition: frame.cpp:677
none
@ none
undefined (initial value)
Definition: usbthread.h:143
MuxFrame::reset
virtual void reset()
Reset the internal data.
Definition: frame.cpp:344
common.h
List of common header files.
AVBitmapFrame::av_pixel_format
AVPixelFormat av_pixel_format
From AVCodecContext .. this class implies YUV420P so this is not really required ....
Definition: frame.h:386
Frame::reset
virtual void reset()
Reset the internal data.
Definition: frame.cpp:67
MarkerFrame::tm_end
bool tm_end
Transmission start / end.
Definition: frame.h:637
macro.h
avdep.h
List of common ffmpeg/libav header files. Definition of some functions to call FFmpeg API directly fr...
MarkerFrame::MarkerFrame
MarkerFrame()
Default ctor.
Definition: frame.cpp:910
MarkerFrame
Definition: frame.h:621
AVMediaFrame::print
virtual void print(std::ostream &os) const
How to print this frame to output stream.
Definition: frame.cpp:407
OpenGLSignalContext
Encapsulates data sent by the signal.
Definition: threadsignal.h:148
MuxFrame::dumpPayload
virtual std::string dumpPayload()
Dumps internal payload data.
Definition: frame.cpp:330
YUVFrame::u_index
GLuint u_index
internal OpenGL/GPU index
Definition: frame.h:518
SetupFrame::media_type
AVMediaType media_type
For subtype stream_init.
Definition: frame.h:299
AVBitmapFrame::u_payload
uint8_t * u_payload
shortcut to AVMediaFrame::av_frame->data[1]
Definition: frame.h:389
RaWriter
Definition: rawrite.h:67
AVMediaFrame::av_frame
AVFrame * av_frame
The decoded frame.
Definition: frame.h:345
opengl.h
OpenGL calls for reserving PBOs and TEXtures, plus some auxiliary routines.
metadata.h
libValkka pre-reserves all frames, both byte payload and metadata payload. After memory reservation,...
YUVFrame::y_index
GLuint y_index
internal OpenGL/GPU index
Definition: frame.h:517
BasicFrame::calcSize
std::size_t calcSize()
How much this frame occupies in bytes when serialized.
Definition: frame.cpp:235
MarkerFrame::reset
virtual void reset()
Reset the internal data.
Definition: frame.cpp:935
BasicFrame::dumpPayloadToFile
virtual void dumpPayloadToFile(std::ofstream &fout)
Dumps internal payload data into a file.
Definition: frame.cpp:116
FrameClass::basic
@ basic
data at payload
AVMediaFrame::reset
virtual void reset()
Reset the internal data.
Definition: frame.cpp:420
SignalFrame::reset
virtual void reset()
Reset the internal data.
Definition: frame.cpp:901
AVMediaFrame::dumpPayload
virtual std::string dumpPayload()
Dumps internal payload data.
Definition: frame.cpp:414
MuxFrame::MuxFrame
MuxFrame()
Default ctor.
Definition: frame.cpp:312
Frame::mstimestamp
long int mstimestamp
Presentation time stamp (PTS) in milliseconds.
Definition: frame.h:145
MuxFrame::codec_id
AVCodecID codec_id
AVCodeCID of the underlying elementary stream.
Definition: frame.h:249
YUVFrame::reserve
void reserve()
Reserve data on the GPU. Used by the constructor only.
Definition: frame.cpp:684
Frame::~Frame
virtual ~Frame()
Default virtual dtor.
Definition: frame.cpp:42
AVBitmapFrame::updateAux
virtual void updateAux()
Uses AVBitmapFrame::av_frame width and height and AVBitmapFrame::av_pixel_format to calculate AVBitma...
Definition: frame.cpp:487
FrameClass::marker
@ marker
Used when sending blocks of frames: mark filesystem and block start and end.
RGBFrame::print
virtual void print(std::ostream &os) const
How to print this frame to output stream.
Definition: frame.cpp:865
tools.h
Auxiliary routines.
BasicFrame::read
IdNumber read(RawReader &raw_reader)
Read the frame from filestream. Returns device id.
Definition: frame.cpp:266
MuxFrame::meta_type
MuxMetaType meta_type
Mux type that mandates how meta_blob is casted.
Definition: frame.h:253
SignalFrame::valkkafswriter_signal_ctx
ValkkaFSWriterSignalContext valkkafswriter_signal_ctx
Thread commands to ValkkFSWriterThread.
Definition: frame.h:603
BasicFrame::media_type
AVMediaType media_type
Type of the media (video/audio)
Definition: frame.h:193
Frame::update
virtual void update()
Update helper points (call always)
Definition: frame.cpp:84
AVMediaFrame::AVMediaFrame
AVMediaFrame()
Default ctor.
Definition: frame.cpp:393
FrameClass::mux
@ mux
Muxed streams, for example, MP4 or matroska.
Frame::n_slot
SlotNumber n_slot
Slot number identifying the media source.
Definition: frame.h:143
FrameClass::signal
@ signal
signal to AVThread or OpenGLThread. Also custom signals to custom Threads
SignalFrame::valkkafsreader_signal_ctx
ValkkaFSReaderSignalContext valkkafsreader_signal_ctx
Thread commands to ValkkaFSReaderThread.
Definition: frame.h:604
AVRGBFrame::reserve
virtual void reserve(int width, int height)
Reserve RGB image with width & height.
Definition: frame.cpp:586
AVBitmapFrame::update
virtual void update()
Update helper points (call always)
Definition: frame.cpp:528
SignalFrame::SignalFrame
SignalFrame()
Default ctor.
Definition: frame.cpp:897
AVRGBFrame
Decoded YUV frame in a non-planar format (thus "NP")
Definition: frame.h:436
BitmapPars
For AVBitmapFrames, linesizes are the widths + padding bytes.
Definition: constant.h:132
BasicFrame::h264_pars
H264Pars h264_pars
H264 parameters, extracted from the payload.
Definition: frame.h:197
BasicFrame::fillAVPacket
void fillAVPacket(AVPacket *avpkt)
Copy payload to AVPacket structure.
Definition: frame.cpp:178
FrameClass::avmedia
@ avmedia
data at ffmpeg av_frame and ffmpeg av_codec_context
H264Pars
Definition: codec.h:71