camerasurface.cpp 697 Bytes
#include "camerasurface.h"

QList<QVideoFrame::PixelFormat> CameraSurface::supportedPixelFormats(QAbstractVideoBuffer::HandleType handleType) const
{
    return QList<QVideoFrame::PixelFormat>() << QVideoFrame::Format_RGB32;
}

bool CameraSurface::present(const QVideoFrame &frame)
{
    if (frame.isValid()) {
        QVideoFrame cloneFrame(frame);
                    cloneFrame.map(QAbstractVideoBuffer::ReadOnly);

        QByteArray ba;
                   ba.append( (char*)cloneFrame.bits(), cloneFrame.bytesPerLine() * cloneFrame.height() );

        emit novoFrame( ba, cloneFrame.width(), cloneFrame.height() );

        cloneFrame.unmap();
        return true;
    }
    return false;
}