qTox
Version: nightly | Commit: bc751c8e1cac455f9690654fcfe0f560d2d7dfdd
|
Go to the documentation of this file.
24 #include <QReadWriteLock>
29 #pragma GCC diagnostic push
30 #pragma GCC diagnostic ignored "-Wold-style-cast"
31 #include <libavcodec/avcodec.h>
32 #pragma GCC diagnostic pop
39 #include <unordered_map>
45 explicit operator bool()
const;
85 const AVFrame*
getAVFrame(QSize frameSize,
const int pixelFormat,
const bool requireAligned);
86 QImage
toQImage(QSize frameSize = {});
100 FrameBufferKey(
const int width,
const int height,
const int pixFmt,
const bool lineAligned);
128 const bool frameAligned);
130 AVFrame*
retrieveAVFrame(
const QSize& dimensions,
const int pixelFormat,
const bool requireAligned);
131 AVFrame*
generateAVFrame(
const QSize& dimensions,
const int pixelFormat,
const bool requireAligned);
132 AVFrame*
storeAVFrame(AVFrame* frame,
const QSize& dimensions,
const int pixelFormat);
136 template <
typename T>
137 T
toGenericObject(
const QSize& dimensions,
const int pixelFormat,
const bool requireAligned,
138 const std::function<T(AVFrame*
const)>& objectConstructor,
const T& nullObject);
158 static std::unordered_map<IDType, QMutex>
mutexMap;
159 static std::unordered_map<IDType, std::unordered_map<IDType, std::weak_ptr<VideoFrame>>>
refsMap;
static std::unordered_map< IDType, QMutex > mutexMap
static QReadWriteLock refsLock
static std::unordered_map< IDType, std::unordered_map< IDType, std::weak_ptr< VideoFrame > > > refsMap
~VideoFrame()
Destructor for VideoFrame.
AVFrame * retrieveAVFrame(const QSize &dimensions, const int pixelFormat, const bool requireAligned)
Retrieves an AVFrame derived from the source based on the given parameters without obtaining a lock.
ToxYUVFrame toToxYUVFrame(QSize frameSize={})
Converts this VideoFrame to a ToxAVFrame that shares this VideoFrame's buffer.
std::uint_fast64_t IDType
bool isValid() const
Returns whether the given ToxYUVFrame represents a valid frame or not.
const FrameBufferKey sourceFrameKey
const bool freeSourceFrame
int getSourcePixelFormat() const
Retrieves a copy of the source VideoFormat's pixel format.
QRect getSourceDimensions() const
Retrieves a copy of the source VideoFrame's dimensions.
const FrameBufferKey & operator=(const FrameBufferKey &)=delete
bool operator==(const FrameBufferKey &other) const
Comparison operator for FrameBufferKey.
IDType getFrameID() const
Returns the ID for the given frame.
static AtomicIDType frameIDs
VideoFrame(IDType sourceID, AVFrame *sourceFrame, QRect dimensions, int pixFmt, bool freeSourceFrame=false)
Constructs a new instance of a VideoFrame, sourced by a given AVFrame pointer.
std::shared_ptr< VideoFrame > trackFrame()
Causes the VideoFrame class to maintain an internal reference for the frame.
static FrameBufferKey getFrameKey(const QSize &frameSize, const int pixFmt, const int linesize)
Generates a key object based on given parameters.
void deleteFrameBuffer()
Releases all frames within the frame buffer.
AVFrame * generateAVFrame(const QSize &dimensions, const int pixelFormat, const bool requireAligned)
Generates an AVFrame based on the given specifications.
const std::uint16_t height
std::unordered_map< FrameBufferKey, AVFrame *, std::function< decltype(FrameBufferKey::hash)> > frameBuffer
~FrameBufferKey()=default
bool isValid()
Returns the validity of this VideoFrame.
const std::uint16_t width
void releaseFrame()
Releases all frames managed by this VideoFrame and invalidates it.
const VideoFrame & operator=(const VideoFrame &other)=delete
static size_t hash(const FrameBufferKey &key)
Hash function for FrameBufferKey.
An ownernship and management class for AVFrames.
const bool linesizeAligned
const QRect sourceDimensions
FrameBufferKey(const int width, const int height, const int pixFmt, const bool lineAligned)
Constructs a new FrameBufferKey with the given attributes.
const AVFrame * getAVFrame(QSize frameSize, const int pixelFormat, const bool requireAligned)
Retrieves an AVFrame derived from the source based on the given parameters.
QImage toQImage(QSize frameSize={})
Converts this VideoFrame to a QImage that shares this VideoFrame's buffer.
T toGenericObject(const QSize &dimensions, const int pixelFormat, const bool requireAligned, const std::function< T(AVFrame *const)> &objectConstructor, const T &nullObject)
Converts this VideoFrame to a generic type T based on the given parameters and supplied converter fun...
static constexpr int dataAlignment
Data alignment parameter used to populate AVFrame buffers.
A simple structure to represent a ToxYUV video frame (corresponds to a frame encoded under format: AV...
std::atomic_uint_fast64_t AtomicIDType
IDType getSourceID() const
Returns the ID for the VideoSource which created this frame.
static void untrackFrames(const IDType &sourceID, bool releaseFrames=false)
Untracks all the frames for the given VideoSource, releasing them if specified.
AVFrame * storeAVFrame(AVFrame *frame, const QSize &dimensions, const int pixelFormat)
Stores a given AVFrame within the frameBuffer map.
bool operator!=(const FrameBufferKey &other) const
Not equal to operator for FrameBufferKey.