Ejemplo n.º 1
0
    // Overridden from QAbstractVideoSurface
    virtual bool start( const QVideoSurfaceFormat &format )
    {
        m_mutex.lock();

        m_flipped = ( format.scanLineDirection() == QVideoSurfaceFormat::BottomToTop );
        m_frameFormat = QVideoFrame::imageFormatFromPixelFormat( format.pixelFormat() );
        m_viewport = format.viewport();
        m_valid = 1;

        // We want to unlock it before calling the parent function, which may call present() and deadlock
        m_mutex.unlock();

        return QAbstractVideoSurface::start( format );
    }
QDebug operator<<(QDebug dbg, const QVideoSurfaceFormat &f)
{
    dbg.nospace() << "QVideoSurfaceFormat(" << f.pixelFormat();
    dbg.nospace() << ", " << f.frameSize();
    dbg.nospace() << ", viewport=" << f.viewport();
    dbg.nospace() << ", pixelAspectRatio=" << f.pixelAspectRatio();
    dbg.nospace() << ", handleType=" << f.handleType();
    dbg.nospace() << ", yCbCrColorSpace=" << f.yCbCrColorSpace();
    dbg.nospace() << ")";

    foreach(const QByteArray& propertyName, f.propertyNames())
        dbg << "\n    " << propertyName.data() << " = " << f.property(propertyName.data());

    return dbg.space();
}
Ejemplo n.º 3
0
void tst_QVideoSurfaceFormat::constructNull()
{
    QVideoSurfaceFormat format;

    QVERIFY(!format.isValid());
    QCOMPARE(format.handleType(), QAbstractVideoBuffer::NoHandle);
    QCOMPARE(format.pixelFormat(), QVideoFrame::Format_Invalid);
    QCOMPARE(format.frameSize(), QSize());
    QCOMPARE(format.frameWidth(), -1);
    QCOMPARE(format.frameHeight(), -1);
    QCOMPARE(format.viewport(), QRect());
    QCOMPARE(format.scanLineDirection(), QVideoSurfaceFormat::TopToBottom);
    QCOMPARE(format.frameRate(), 0.0);
    QCOMPARE(format.pixelAspectRatio(), QSize(1, 1));
    QCOMPARE(format.yCbCrColorSpace(), QVideoSurfaceFormat::YCbCr_Undefined);
}
Ejemplo n.º 4
0
bool QX11VideoSurface::start(const QVideoSurfaceFormat &format)
{
    if (m_image)
        XFree(m_image);

    int xvFormatId = 0;
    for (int i = 0; i < m_supportedPixelFormats.count(); ++i) {
        if (m_supportedPixelFormats.at(i) == format.pixelFormat()) {
            xvFormatId = m_formatIds.at(i);
            break;
        }
    }

    if (xvFormatId == 0) {
        setError(UnsupportedFormatError);
    } else {
        XvImage *image = XvCreateImage(
                QX11Info::display(),
                m_portId,
                xvFormatId,
                0,
                format.frameWidth(),
                format.frameHeight());

        if (!image) {
            setError(ResourceError);
        } else {
            m_viewport = format.viewport();
            m_image = image;

            QVideoSurfaceFormat newFormat = format;
            newFormat.setProperty("portId", QVariant(quint64(m_portId)));
            newFormat.setProperty("xvFormatId", xvFormatId);
            newFormat.setProperty("dataSize", image->data_size);

            return QAbstractVideoSurface::start(newFormat);
        }
    }

    if (m_image) {
        m_image = 0;

        QAbstractVideoSurface::stop();
    }

    return false;
}
bool AndroidVideoSurface::start(const QVideoSurfaceFormat &format)
{
    const QImage::Format m_imageFormat = QVideoFrame::imageFormatFromPixelFormat(format.pixelFormat());
    const QSize size = format.frameSize();

    if (m_imageFormat != QImage::Format_Invalid && !size.isEmpty()) {
        this->m_imageFormat = m_imageFormat;
        m_imageSize = size;
        m_sourceRect = format.viewport();
        emit(surfaceStarted(format));
        m_widget->updateGeometry();
        updateVideoRect();
        return true;
    } else {
        return false;
    }
}
Ejemplo n.º 6
0
bool AVL_QT_DLL_EXPORT WidgetSurface::start(const QVideoSurfaceFormat & format){
	const QSize size = format.frameSize();

	if (size.isEmpty()==false) {
		imageSize.set(size.width(),size.height());
		sourceRect = format.viewport();

		QAbstractVideoSurface::start(format);

		widget->updateGeometry();
		updateVideoRect();

		return true;
	}else{
		return false;
	}
}
Ejemplo n.º 7
0
//! [2]
bool VideoWidgetSurface::start(const QVideoSurfaceFormat &format)
{
    const QImage::Format imageFormat = QVideoFrame::imageFormatFromPixelFormat(format.pixelFormat());
    const QSize size = format.frameSize();

    if (imageFormat != QImage::Format_Invalid && !size.isEmpty()) {
        this->imageFormat = imageFormat;
        imageSize = size;
        sourceRect = format.viewport();

        QAbstractVideoSurface::start(format);

        widget->updateGeometry();
        updateVideoRect();

        return true;
    } else {
        return false;
    }
}
Ejemplo n.º 8
0
QDebug operator<<(QDebug dbg, const QVideoSurfaceFormat &f)
{
    QString typeName;
    switch (f.pixelFormat()) {
    case QVideoFrame::Format_Invalid:
        typeName = QLatin1String("Format_Invalid");
        break;
    case QVideoFrame::Format_ARGB32:
        typeName = QLatin1String("Format_ARGB32");
        break;
    case QVideoFrame::Format_ARGB32_Premultiplied:
        typeName = QLatin1String("Format_ARGB32_Premultiplied");
        break;
    case QVideoFrame::Format_RGB32:
        typeName = QLatin1String("Format_RGB32");
        break;
    case QVideoFrame::Format_RGB24:
        typeName = QLatin1String("Format_RGB24");
        break;
    case QVideoFrame::Format_RGB565:
        typeName = QLatin1String("Format_RGB565");
        break;
    case QVideoFrame::Format_RGB555:
        typeName = QLatin1String("Format_RGB555");
        break;
    case QVideoFrame::Format_ARGB8565_Premultiplied:
        typeName = QLatin1String("Format_ARGB8565_Premultiplied");
        break;
    case QVideoFrame::Format_BGRA32:
        typeName = QLatin1String("Format_BGRA32");
        break;
    case QVideoFrame::Format_BGRA32_Premultiplied:
        typeName = QLatin1String("Format_BGRA32_Premultiplied");
        break;
    case QVideoFrame::Format_BGR32:
        typeName = QLatin1String("Format_BGR32");
        break;
    case QVideoFrame::Format_BGR24:
        typeName = QLatin1String("Format_BGR24");
        break;
    case QVideoFrame::Format_BGR565:
        typeName = QLatin1String("Format_BGR565");
        break;
    case QVideoFrame::Format_BGR555:
        typeName = QLatin1String("Format_BGR555");
        break;
    case QVideoFrame::Format_BGRA5658_Premultiplied:
        typeName = QLatin1String("Format_BGRA5658_Premultiplied");
        break;
    case QVideoFrame::Format_AYUV444:
        typeName = QLatin1String("Format_AYUV444");
        break;
    case QVideoFrame::Format_AYUV444_Premultiplied:
        typeName = QLatin1String("Format_AYUV444_Premultiplied");
        break;
    case QVideoFrame::Format_YUV444:
        typeName = QLatin1String("Format_YUV444");
        break;
    case QVideoFrame::Format_YUV420P:
        typeName = QLatin1String("Format_YUV420P");
        break;
    case QVideoFrame::Format_YV12:
        typeName = QLatin1String("Format_YV12");
        break;
    case QVideoFrame::Format_UYVY:
        typeName = QLatin1String("Format_UYVY");
        break;
    case QVideoFrame::Format_YUYV:
        typeName = QLatin1String("Format_YUYV");
        break;
    case QVideoFrame::Format_NV12:
        typeName = QLatin1String("Format_NV12");
        break;
    case QVideoFrame::Format_NV21:
        typeName = QLatin1String("Format_NV21");
        break;
    case QVideoFrame::Format_IMC1:
        typeName = QLatin1String("Format_IMC1");
        break;
    case QVideoFrame::Format_IMC2:
        typeName = QLatin1String("Format_IMC2");
        break;
    case QVideoFrame::Format_IMC3:
        typeName = QLatin1String("Format_IMC3");
        break;
    case QVideoFrame::Format_IMC4:
        typeName = QLatin1String("Format_IMC4");
        break;
    case QVideoFrame::Format_Y8:
        typeName = QLatin1String("Format_Y8");
        break;
    case QVideoFrame::Format_Y16:
        typeName = QLatin1String("Format_Y16");
    default:
        typeName = QString(QLatin1String("UserType(%1)" )).arg(int(f.pixelFormat()));
    }

    dbg.nospace() << "QVideoSurfaceFormat(" << typeName;
    dbg.nospace() << ", " << f.frameSize();
    dbg.nospace() << ", viewport=" << f.viewport();
    dbg.nospace() << ", pixelAspectRatio=" << f.pixelAspectRatio();
    dbg.nospace() << ")";

    foreach(const QByteArray& propertyName, f.propertyNames())
        dbg << "\n    " << propertyName.data() << " = " << f.property(propertyName.data());

    return dbg.space();
}