1
0
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:
initramfs 2016-08-06 22:12:32 +08:00
parent 5b31b5db72
commit 3e7d55e833
No known key found for this signature in database
GPG Key ID: 78B8BDF87E9EF0AF
4 changed files with 26 additions and 4 deletions

View File

@ -362,7 +362,7 @@ void CoreAV::sendCallVideo(uint32_t callId, std::shared_ptr<VideoFrame> vframe)
ToxYUVFrame frame = vframe->toToxYUVFrame(); ToxYUVFrame frame = vframe->toToxYUVFrame();
if(frame.width == 0 || frame.height == 0) if(!frame)
{ {
return; return;
} }

View File

@ -356,7 +356,6 @@ QImage VideoFrame::toQImage(QSize frameSize)
* *
* @param frameSize the given frame size of ToxAVFrame to generate. Defaults to source frame size * @param frameSize the given frame size of ToxAVFrame to generate. Defaults to source frame size
* if frameSize is invalid. * if frameSize is invalid.
* to source frame size.
* @return a ToxAVFrame structure that represents this VideoFrame, sharing it's buffers or an * @return a ToxAVFrame structure that represents this VideoFrame, sharing it's buffers or an
* empty structure if this VideoFrame is no longer valid. * empty structure if this VideoFrame is no longer valid.
*/ */
@ -785,3 +784,23 @@ template QImage VideoFrame::toGenericObject<QImage>(const QSize& dimensions, con
const std::function<QImage(AVFrame* const)> objectConstructor, const QImage& nullObject); const std::function<QImage(AVFrame* const)> objectConstructor, const QImage& nullObject);
template ToxYUVFrame VideoFrame::toGenericObject<ToxYUVFrame>(const QSize& dimensions, const int pixelFormat, const bool requireAligned, 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();
}

View File

@ -39,6 +39,9 @@ extern "C"{
struct ToxYUVFrame struct ToxYUVFrame
{ {
public: public:
bool isValid() const;
explicit operator bool() const;
const std::uint16_t width; const std::uint16_t width;
const std::uint16_t height; const std::uint16_t height;