mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
feat(video): add a isValid() function to ToxTUVFrame
This commit is contained in:
parent
5b31b5db72
commit
3e7d55e833
|
@ -362,7 +362,7 @@ void CoreAV::sendCallVideo(uint32_t callId, std::shared_ptr<VideoFrame> vframe)
|
|||
|
||||
ToxYUVFrame frame = vframe->toToxYUVFrame();
|
||||
|
||||
if(frame.width == 0 || frame.height == 0)
|
||||
if(!frame)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -356,7 +356,6 @@ QImage VideoFrame::toQImage(QSize frameSize)
|
|||
*
|
||||
* @param frameSize the given frame size of ToxAVFrame to generate. Defaults to source frame size
|
||||
* if frameSize is invalid.
|
||||
* to source frame size.
|
||||
* @return a ToxAVFrame structure that represents this VideoFrame, sharing it's buffers or an
|
||||
* empty structure if this VideoFrame is no longer valid.
|
||||
*/
|
||||
|
@ -784,4 +783,24 @@ T VideoFrame::toGenericObject(const QSize& dimensions, const int pixelFormat, co
|
|||
template QImage VideoFrame::toGenericObject<QImage>(const QSize& dimensions, const int pixelFormat, const bool requireAligned,
|
||||
const std::function<QImage(AVFrame* const)> objectConstructor, const QImage& nullObject);
|
||||
template ToxYUVFrame VideoFrame::toGenericObject<ToxYUVFrame>(const QSize& dimensions, const int pixelFormat, const bool requireAligned,
|
||||
const std::function<ToxYUVFrame(AVFrame* const)> objectConstructor, const ToxYUVFrame& nullObject);
|
||||
const std::function<ToxYUVFrame(AVFrame* const)> objectConstructor, const ToxYUVFrame& nullObject);
|
||||
|
||||
/**
|
||||
* @brief Returns whether the given ToxYUVFrame represents a valid frame or not.
|
||||
*
|
||||
* Valid frames are frames in which both width and height are greater than zero.
|
||||
*
|
||||
* @return true if the frame is valid, false otherwise.
|
||||
*/
|
||||
bool ToxYUVFrame::isValid() const
|
||||
{
|
||||
return width > 0 && height > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Checks if the given ToxYUVFrame is valid or not, delegates to isValid().
|
||||
*/
|
||||
ToxYUVFrame::operator bool() const
|
||||
{
|
||||
return isValid();
|
||||
}
|
||||
|
|
|
@ -39,6 +39,9 @@ extern "C"{
|
|||
struct ToxYUVFrame
|
||||
{
|
||||
public:
|
||||
bool isValid() const;
|
||||
explicit operator bool() const;
|
||||
|
||||
const std::uint16_t width;
|
||||
const std::uint16_t height;
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ public:
|
|||
/**
|
||||
* @brief If subscribe sucessfully opens the source, it will start emitting frameAvailable signals.
|
||||
*/
|
||||
virtual bool subscribe() = 0;
|
||||
virtual bool subscribe() = 0;
|
||||
/**
|
||||
* @brief Stop emitting frameAvailable signals, and free associated resources if necessary.
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue
Block a user