void QGstreamerVideoRenderer::setSurface(QAbstractVideoSurface *surface)
{
    if (m_surface != surface) {
        //qDebug() << Q_FUNC_INFO << surface;
        if (m_videoSink)
            gst_object_unref(GST_OBJECT(m_videoSink));

        m_videoSink = 0;

        if (m_surface) {
            disconnect(m_surface, SIGNAL(supportedFormatsChanged()),
                       this, SLOT(handleFormatChange()));
        }
        
        m_surface = surface;

        if (surface && !m_surface)
            emit readyChanged(true);

        if (!surface && m_surface)
            emit readyChanged(false);

        if (m_surface) {
            connect(m_surface, SIGNAL(supportedFormatsChanged()),
                    this, SLOT(handleFormatChange()));
        }

        emit sinkChanged();
    }
}
예제 #2
0
void QGstreamerGLTextureRenderer::setSurface(QAbstractVideoSurface *surface)
{
    if (m_surface != surface) {
#ifdef GL_TEXTURE_SINK_DEBUG
        qDebug() << Q_FUNC_INFO << surface;
#endif

        bool oldReady = isReady();

        m_context = m_glEnabled ? const_cast<QGLContext*>(QGLContext::currentContext()) : NULL;

        if (m_videoSink)
            gst_object_unref(GST_OBJECT(m_videoSink));

        m_videoSink = 0;

        if (m_surface) {
            disconnect(m_surface, SIGNAL(supportedFormatsChanged()),
                       this, SLOT(handleFormatChange()));
        }

        m_surface = surface;

        if (oldReady != isReady())
            emit readyChanged(!oldReady);

        if (m_surface) {
            connect(m_surface, SIGNAL(supportedFormatsChanged()),
                    this, SLOT(handleFormatChange()));
        }

        emit sinkChanged();
    }
}
void QGstreamerVideoRenderer::setSurface(QAbstractVideoSurface *surface)
{
    if (m_surface != surface) {
        //qDebug() << Q_FUNC_INFO << surface;
        if (m_videoSink)
            gst_object_unref(GST_OBJECT(m_videoSink));

        m_videoSink = 0;

        if (m_surface) {
            disconnect(m_surface.data(), SIGNAL(supportedFormatsChanged()),
                       this, SLOT(handleFormatChange()));
        }

        bool wasReady = isReady();

        m_surface = surface;

        if (m_surface) {
            connect(m_surface.data(), SIGNAL(supportedFormatsChanged()),
                    this, SLOT(handleFormatChange()));
        }

        if (wasReady != isReady())
            emit readyChanged(isReady());

        emit sinkChanged();
    }
}
VideoSurfaceFilter::VideoSurfaceFilter(
        QAbstractVideoSurface *surface, DirectShowEventLoop *loop, QObject *parent)
    : QObject(parent)
    , m_ref(1)
    , m_state(State_Stopped)
    , m_surface(surface)
    , m_loop(loop)
    , m_graph(0)
    , m_peerPin(0)
    , m_bytesPerLine(0)
    , m_startResult(S_OK)
    , m_pinId(QString::fromLatin1("reference"))
    , m_sampleScheduler(static_cast<IPin *>(this))
{
    connect(surface, SIGNAL(supportedFormatsChanged()), this, SLOT(supportedFormatsChanged()));
    connect(&m_sampleScheduler, SIGNAL(sampleReady()), this, SLOT(sampleReady()));
}
예제 #5
0
/*!
    \since 1.2
*/
bool QEglImageTextureSurface::start(const QVideoSurfaceFormat &format)
{
#ifdef DEBUG_OMAPFB_SURFACE
    qDebug() << Q_FUNC_INFO << format;
#endif

    m_fallbackSurfaceActive = false;
    if (format.handleType() != EGLImageTextureHandle) {
        qWarning() << Q_FUNC_INFO << "Non EGLImageTextureHandle based format requested, fallback to QPainterVideoSurface";
        connect(m_fallbackSurface, SIGNAL(activeChanged(bool)),
                this, SIGNAL(activeChanged(bool)));
        connect(m_fallbackSurface, SIGNAL(surfaceFormatChanged(QVideoSurfaceFormat)),
                this, SIGNAL(surfaceFormatChanged(QVideoSurfaceFormat)));
        connect(m_fallbackSurface, SIGNAL(supportedFormatsChanged()),
                this, SIGNAL(supportedFormatsChanged()));
        connect(m_fallbackSurface, SIGNAL(nativeResolutionChanged(QSize)),
                this, SIGNAL(nativeResolutionChanged(QSize)));
        connect(m_fallbackSurface, SIGNAL(frameChanged()),
                this, SIGNAL(frameChanged()));

        if (m_fallbackSurface->start(format)) {
            m_fallbackSurfaceActive = true;
            QAbstractVideoSurface::start(format);
        } else {
            qWarning() << Q_FUNC_INFO << "failed to start video surface:" << m_fallbackSurface->error();
            setError(m_fallbackSurface->error());

            disconnect(m_fallbackSurface, SIGNAL(activeChanged(bool)),
                       this, SIGNAL(activeChanged(bool)));
            disconnect(m_fallbackSurface, SIGNAL(surfaceFormatChanged(QVideoSurfaceFormat)),
                       this, SIGNAL(surfaceFormatChanged(QVideoSurfaceFormat)));
            disconnect(m_fallbackSurface, SIGNAL(supportedFormatsChanged()),
                       this, SIGNAL(supportedFormatsChanged()));
            disconnect(m_fallbackSurface, SIGNAL(nativeResolutionChanged(QSize)),
                       this, SIGNAL(nativeResolutionChanged(QSize)));
            disconnect(m_fallbackSurface, SIGNAL(frameChanged()),
                       this, SIGNAL(frameChanged()));
        }

        return m_fallbackSurfaceActive;
    }
예제 #6
0
void QX11VideoSurface::setWinId(WId id)
{
    //qDebug() << "setWinID:" << id;

    if (id == m_winId)
        return;

    if (m_image)
        XFree(m_image);

    if (m_gc) {
        XFreeGC(QX11Info::display(), m_gc);
        m_gc = 0;
    }

    if (m_portId != 0)
        XvUngrabPort(QX11Info::display(), m_portId, 0);

    m_supportedPixelFormats.clear();
    m_formatIds.clear();

    m_winId = id;

    if (m_winId && findPort()) {
        querySupportedFormats();

        m_gc = XCreateGC(QX11Info::display(), m_winId, 0, 0);

        if (m_image) {
            m_image = 0;

            if (!start(surfaceFormat())) {
                QAbstractVideoSurface::stop();
                qWarning() << "Failed to start video surface with format" << surfaceFormat();
            }
        }
    } else {
        qWarning() << "Failed to find XVideo port";
        if (m_image) {
            m_image = 0;

            QAbstractVideoSurface::stop();
        }
    }

    emit supportedFormatsChanged();
}
예제 #7
0
QVideoSurfaceGstDelegate::QVideoSurfaceGstDelegate(
    QAbstractVideoSurface *surface)
    : m_surface(surface)
    , m_pool(0)
    , m_renderReturn(GST_FLOW_ERROR)
    , m_lastPrerolledBuffer(0)
    , m_bytesPerLine(0)
    , m_startCanceled(false)
{
    if (m_surface) {
        foreach (QObject *instance, bufferPoolLoader()->instances(QGstBufferPoolPluginKey)) {
            QGstBufferPoolInterface* plugin = qobject_cast<QGstBufferPoolInterface*>(instance);
            if (plugin) {
                m_pools.append(plugin);
            }
        }
        updateSupportedFormats();
        connect(m_surface, SIGNAL(supportedFormatsChanged()), this, SLOT(updateSupportedFormats()));
    }