1 #ifndef frame_HEADER_GUARD
2 #define frame_HEADER_GUARD
40 #include "threadsignal.h"
128 virtual void print(std::ostream &os)
const;
133 virtual void reset();
148 inline std::ostream &operator<<(std::ostream &os,
const Frame &f)
181 virtual void print(std::ostream &os)
const;
184 virtual void reset();
188 void reserve(std::size_t n_bytes);
189 void resize(std::size_t n_bytes);
229 virtual void print(std::ostream& os)
const;
232 virtual void reset();
243 void reserve(std::size_t n_bytes);
244 void resize(std::size_t n_bytes);
257 enum class SetupFrameType
293 virtual void print(std::ostream &os)
const;
294 virtual void reset();
337 virtual void print(std::ostream &os)
const;
338 virtual void reset();
378 virtual void print(std::ostream &os)
const;
379 virtual void reset();
383 virtual void reserve(
int width,
int height);
446 virtual void reserve(
int width,
int height);
450 virtual void print(std::ostream &os)
const;
528 virtual void print(std::ostream &os)
const;
529 virtual void reset();
545 RGBFrame(
int max_width,
int max_height);
551 int max_width, max_height;
556 virtual void print(std::ostream &os)
const;
557 virtual void reset();
563 typedef std::vector<Frame *> Reservoir;
564 typedef std::deque<Frame *> Stack;
565 typedef std::deque<Frame *> Fifo;
566 typedef std::deque<Frame *> Cache;
568 typedef std::vector<YUVFrame *> YUVReservoir;
569 typedef std::deque<YUVFrame *> YUVStack;
570 typedef std::vector<RGBFrame *> RGBReservoir;
571 typedef std::deque<RGBFrame *> RGBStack;
617 virtual void reset();
632 virtual void print(std::ostream &os)
const;
633 virtual void reset();
List of common ffmpeg/libav header files. Definition of some functions to call FFmpeg API directly fr...
Decoded YUV/RGB frame in FFMpeg format.
Definition: frame.h:361
virtual std::string dumpPayload()
Dumps internal payload data.
Definition: frame.cpp:440
uint8_t * y_payload
shortcut to AVMediaFrame::av_frame->data[0]
Definition: frame.h:388
AVBitmapFrame()
Default ctor.
Definition: frame.cpp:429
virtual void print(std::ostream &os) const
How to print this frame to output stream.
Definition: frame.cpp:477
uint8_t * u_payload
shortcut to AVMediaFrame::av_frame->data[1]
Definition: frame.h:389
virtual void reserve(int width, int height)
Reserves space for underlying av_frame.
Definition: frame.cpp:555
uint8_t * v_payload
shortcut to AVMediaFrame::av_frame->data[2]
Definition: frame.h:390
AVPixelFormat av_pixel_format
From AVCodecContext .. this class implies YUV420P so this is not really required ....
Definition: frame.h:386
virtual void updateAux()
Uses AVBitmapFrame::av_frame width and height and AVBitmapFrame::av_pixel_format to calculate AVBitma...
Definition: frame.cpp:487
BitmapPars bmpars
Calculated bitmap plane dimensions, data sizes, etc.
Definition: frame.h:387
virtual ~AVBitmapFrame()
Default virtual dtor.
Definition: frame.cpp:433
virtual void update()
Update helper points (call always)
Definition: frame.cpp:528
virtual void reset()
Reset the internal data.
Definition: frame.cpp:467
Decoded YUV frame in a non-planar format (thus "NP")
Definition: frame.h:437
virtual void reserve(int width, int height)
Reserve RGB image with width & height.
Definition: frame.cpp:586
virtual std::string dumpPayload()
Dumps internal payload data.
Definition: frame.cpp:599
virtual void print(std::ostream &os) const
How to print this frame to output stream.
Definition: frame.cpp:622
Custom payload Frame.
Definition: frame.h:166
void copyFromAVPacket(AVPacket *avpkt)
Copy data from AVPacket structure.
Definition: frame.cpp:202
void fillAVPacket(AVPacket *avpkt)
Copy payload to AVPacket structure.
Definition: frame.cpp:178
H264Pars h264_pars
H264 parameters, extracted from the payload.
Definition: frame.h:197
void resize(std::size_t n_bytes)
Init space for internal payload.
Definition: frame.cpp:159
virtual void dumpPayloadToFile(std::ofstream &fout)
Dumps internal payload data into a file.
Definition: frame.cpp:116
virtual void reset()
Reset the internal data.
Definition: frame.cpp:121
void filterFromAVPacket(AVPacket *avpkt, AVCodecContext *codec_ctx, AVBitStreamFilterContext *filter)
Copy data from AVPacket structure.
Definition: frame.cpp:212
virtual bool isSeekable()
for H264 true if sps, other codecs, always true
Definition: frame.cpp:128
IdNumber read(RawReader &raw_reader)
Read the frame from filestream. Returns device id.
Definition: frame.cpp:266
void fillPars()
Fill codec-dependent parameters based on the payload.
Definition: frame.cpp:164
AVCodecID codec_id
AVCodeCID of the media.
Definition: frame.h:194
virtual std::string dumpPayload()
Dumps internal payload data.
Definition: frame.cpp:107
std::size_t calcSize()
How much this frame occupies in bytes when serialized.
Definition: frame.cpp:235
virtual ~BasicFrame()
Default virtual dtor.
Definition: frame.cpp:93
bool dump(IdNumber device_id, RaWriter &raw_writer)
Write the frame to filestream with a certain device id.
Definition: frame.cpp:247
AVMediaType media_type
Type of the media (video/audio)
Definition: frame.h:193
void reserve(std::size_t n_bytes)
Reserve space for internal payload.
Definition: frame.cpp:154
void fillH264Pars()
Inspects payload and fills BasicFrame::h264_pars;.
Definition: frame.cpp:171
virtual void print(std::ostream &os) const
How to print this frame to output stream.
Definition: frame.cpp:98
std::vector< uint8_t > payload
Raw payload data (use .data() to get the pointer from std::vector)
Definition: frame.h:192
BasicFrame()
Default ctor.
Definition: frame.cpp:89
Frame: An abstract queueable class.
Definition: frame.h:112
virtual void updateAux()
Update internal auxiliary state variables.
Definition: frame.cpp:79
virtual std::string dumpPayload()
Dumps internal payload data.
Definition: frame.cpp:58
virtual void update()
Update helper points (call always)
Definition: frame.cpp:84
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
virtual void dumpPayloadToFile(std::ofstream &fout)
Dumps internal payload data into a file.
Definition: frame.cpp:63
void copyMetaFrom(Frame *f)
Copy metadata (slot, subsession index, timestamp) to this frame.
Definition: frame.cpp:51
int subsession_index
Media subsession index.
Definition: frame.h:144
virtual void reset()
Reset the internal data.
Definition: frame.cpp:67
FrameClass frameclass
Declares frametype for correct typecast. Used by Frame::getFrameClass()
Definition: frame.h:140
virtual ~Frame()
Default virtual dtor.
Definition: frame.cpp:42
Frame()
Default ctor.
Definition: frame.cpp:38
virtual void print(std::ostream &os) const
Produces frame output.
Definition: frame.cpp:46
long int mstimestamp
Presentation time stamp (PTS) in milliseconds.
Definition: frame.h:145
SlotNumber n_slot
Slot number identifying the media source.
Definition: frame.h:143
virtual void reset()
Reset the internal data.
Definition: frame.cpp:935
MarkerFrame()
Default ctor.
Definition: frame.cpp:910
virtual void print(std::ostream &os) const
How to print this frame to output stream.
Definition: frame.cpp:917
virtual ~MarkerFrame()
Default virtual dtor.
Definition: frame.cpp:913
bool fs_end
Filesystem start / end // this controlled better at the python level.
Definition: frame.h:636
bool tm_end
Transmission start / end.
Definition: frame.h:637
A muxed packet (in some container format)
Definition: frame.h:220
MuxMetaType meta_type
Mux type that mandates how meta_blob is casted.
Definition: frame.h:253
void resize(std::size_t n_bytes)
Init space for internal payload.
Definition: frame.cpp:358
virtual void dumpPayloadToFile(std::ofstream &fout)
Dumps internal payload data into a file.
Definition: frame.cpp:339
std::vector< uint8_t > payload
Raw payload data (use .data() to get the pointer from std::vector)
Definition: frame.h:247
void reserve(std::size_t n_bytes)
Reserve space for internal payload.
Definition: frame.cpp:352
std::vector< uint8_t > meta_blob
Byte blob that is casted to correct metadata struct.
Definition: frame.h:252
AVCodecID codec_id
AVCodeCID of the underlying elementary stream.
Definition: frame.h:249
virtual void print(std::ostream &os) const
Produces frame output.
Definition: frame.cpp:323
virtual ~MuxFrame()
Default virtual dtor.
Definition: frame.cpp:319
virtual void reset()
Reset the internal data.
Definition: frame.cpp:344
AVMediaType media_type
Type of the media (video/audio) of the underlying elementary stream.
Definition: frame.h:248
virtual std::string dumpPayload()
Dumps internal payload data.
Definition: frame.cpp:330
MuxFrame()
Default ctor.
Definition: frame.cpp:312
Our own RGB24 structure.
Definition: frame.h:542
std::vector< uint8_t > payload
RGB24 data as continuous bytes. 3 bytes per pixel.
Definition: frame.h:550
virtual void reset()
Reset the internal data.
Definition: frame.cpp:873
void fromAVRGBFrame(AVRGBFrame *f)
Copies data from (temporary) AVRGBFrame .. set the width & height members.
Definition: frame.cpp:880
virtual std::string dumpPayload()
Dumps internal payload data.
Definition: frame.cpp:853
virtual void print(std::ostream &os) const
How to print this frame to output stream.
Definition: frame.cpp:865
Setup frame.
Definition: frame.h:277
AVCodecID codec_id
For subtype stream_init.
Definition: frame.h:300
virtual void print(std::ostream &os) const
How to print this frame to output stream.
Definition: frame.cpp:374
virtual ~SetupFrame()
Default virtual dtor.
Definition: frame.cpp:369
SetupFrame()
Default ctor.
Definition: frame.cpp:364
SetupFrameType sub_type
Type of the SetupFrame.
Definition: frame.h:297
virtual void reset()
Reset the internal data.
Definition: frame.cpp:386
AbstractFileState stream_state
For subtype stream_state.
Definition: frame.h:302
AVMediaType media_type
For subtype stream_init.
Definition: frame.h:299
A frame, signaling internal thread commands, states of recorded video, etc.
Definition: frame.h:589
ValkkaFSReaderSignalContext valkkafsreader_signal_ctx
Thread commands to ValkkaFSReaderThread.
Definition: frame.h:604
virtual void reset()
Reset the internal data.
Definition: frame.cpp:901
OpenGLSignalContext opengl_signal_ctx
< For making correct typecast of custom_ctx_buf. See also threadsignal.h
Definition: frame.h:601
std::vector< uint8_t > signal_ctx_buf
A byte-buffer where the signal context is serialized.
Definition: frame.h:607
AVSignalContext av_signal_ctx
Thread commands to AVThread.
Definition: frame.h:602
ValkkaFSWriterSignalContext valkkafswriter_signal_ctx
Thread commands to ValkkFSWriterThread.
Definition: frame.h:603
SignalFrame()
Default ctor.
Definition: frame.cpp:897
virtual ~SignalFrame()
Default virtual dtor.
Definition: frame.cpp:906
A GPU YUV frame.
Definition: frame.h:492
GLubyte * y_payload
direct memory access memory address, returned by GPU
Definition: frame.h:522
void release()
Releases data on the GPU. Used by the destructor only.
Definition: frame.cpp:710
void fromAVBitmapFrame(AVBitmapFrame *f)
Copies data to the GPU from AVBitmapFrame.
Definition: frame.cpp:719
GLuint u_index
internal OpenGL/GPU index
Definition: frame.h:518
virtual ~YUVFrame()
Default virtual dtor.
Definition: frame.cpp:677
virtual void print(std::ostream &os) const
How to print this frame to output stream.
Definition: frame.cpp:830
GLuint y_index
internal OpenGL/GPU index
Definition: frame.h:517
virtual void reset()
Reset the internal data.
Definition: frame.cpp:837
GLuint v_index
internal OpenGL/GPU index
Definition: frame.h:519
GLubyte * v_payload
direct memory access memory address, returned by GPU
Definition: frame.h:524
virtual std::string dumpPayload()
Dumps internal payload data.
Definition: frame.cpp:804
void reserve()
Reserve data on the GPU. Used by the constructor only.
Definition: frame.cpp:684
YUVFrame(BitmapPars bmpars)
Default ctor.
Definition: frame.cpp:672
GLubyte * u_payload
direct memory access memory address, returned by GPU
Definition: frame.h:523
Codec definitions (slightly outdated)
List of common header files.
Constant/default values, version numbers.
TimeCorrectionType
Methods to correct frame timestamps.
Definition: frame.h:87
AbstractFileState
Describes the state of a stream.
Definition: threadsignal.h:43
FrameClass
Enumeration of Frame classes used by Valkka.
Definition: frame.h:53
@ avmedia
data at ffmpeg av_frame and ffmpeg av_codec_context
@ avbitmap
child of avmedia: video
@ signal
signal to AVThread or OpenGLThread. Also custom signals to custom Threads
@ avpkt
data at ffmpeg avpkt
@ avaudio
child of avmedia: audio
@ marker
Used when sending blocks of frames: mark filesystem and block start and end.
@ avrgb
rgb interpolated from yuv
@ rgb
our own RGB24 data structure
@ mux
Muxed streams, for example, MP4 or matroska.
OpenGL calls for reserving PBOs and TEXtures, plus some auxiliary routines.
Write directly to files and devices with POSIX O_DIRECT.
Redefinition of characteristic signal contexts (info that goes with the signal) for AVThread thread.
Definition: threadsignal.h:94
For AVBitmapFrames, linesizes are the widths + padding bytes.
Definition: constant.h:132
Encapsulates data sent by the signal.
Definition: threadsignal.h:149
Encapsulate data sent in the ValkkaFSReaderSignal.
Definition: threadsignal.h:220
Encapsulate data sent in the ValkkaFSWriterSignal.
Definition: threadsignal.h:185
@ none
undefined (initial value)
Definition: usbthread.h:143