void QGraphicsVideoItemPrivate::clearService() { if (windowControl) { QObject::disconnect(windowControl, SIGNAL(nativeSizeChanged()), q_ptr, SLOT(_q_updateNativeSize())); service->releaseControl(windowControl); windowControl = 0; } if (service) { QObject::disconnect(service, SIGNAL(destroyed()), q_ptr, SLOT(_q_serviceDestroyed())); service = 0; } }
/* Constructs a graphics item that displays video. The \a parent is passed to QGraphicsItem. */ QGraphicsVideoItem::QGraphicsVideoItem(QGraphicsItem *parent) : QGraphicsObject(parent) , d_ptr(new QGraphicsVideoItemPrivate) { d_ptr->q_ptr = this; d_ptr->surface = new QEglImageTextureSurface(this); qRegisterMetaType<QVideoSurfaceFormat>(); connect(d_ptr->surface, SIGNAL(frameChanged()), this, SLOT(_q_present())); connect(d_ptr->surface, SIGNAL(surfaceFormatChanged(QVideoSurfaceFormat)), this, SLOT(_q_updateNativeSize()), Qt::QueuedConnection); }
bool QDeclarativeVideoWindowBackend::init(QMediaService *service) { if (QMediaControl *control = service->requestControl(QVideoWindowControl_iid)) { if ((m_videoWindowControl = qobject_cast<QVideoWindowControl *>(control))) { if (q->window()) m_videoWindowControl->setWinId(q->window()->winId()); m_service = service; QObject::connect(m_videoWindowControl.data(), SIGNAL(nativeSizeChanged()), q, SLOT(_q_updateNativeSize())); return true; } } return false; }
/* \internal */ bool QGraphicsVideoItem::setMediaObject(QMediaObject *object) { Q_D(QGraphicsVideoItem); if (object == d->mediaObject) return true; d->clearService(); d->mediaObject = object; if (d->mediaObject) { d->service = d->mediaObject->service(); if (d->service) { QMediaControl *control = d->service->requestControl(QVideoRendererControl_iid); if (control) { d->rendererControl = qobject_cast<QVideoRendererControl *>(control); if (d->rendererControl) { connect(d->rendererControl, SIGNAL(nativeSizeChanged()), this, SLOT(_q_updateNativeSize()), Qt::QueuedConnection); d->_q_updateNativeSize(); //don't set the surface untill the item is painted //at least once and the surface is configured if (!d->updatePaintDevice) d->rendererControl->setSurface(d->surface); else update(boundingRect()); connect(d->service, SIGNAL(destroyed()), this, SLOT(_q_serviceDestroyed())); return true; } if (control) d->service->releaseControl(control); } } } d->mediaObject = 0; return false; }
QDeclarativeVideoRendererBackend::QDeclarativeVideoRendererBackend(QDeclarativeVideoOutput *parent) : QDeclarativeVideoBackend(parent), m_glContext(0), m_frameChanged(false) { m_surface = new QSGVideoItemSurface(this); QObject::connect(m_surface, SIGNAL(surfaceFormatChanged(QVideoSurfaceFormat)), q, SLOT(_q_updateNativeSize()), Qt::QueuedConnection); // Prioritize the plugin requested by the environment QString requestedVideoNode = QString::fromLatin1(qgetenv("QT_VIDEONODE")); foreach (const QString &key, videoNodeFactoryLoader()->keys()) { QObject *instance = videoNodeFactoryLoader()->instance(key); QSGVideoNodeFactoryInterface* plugin = qobject_cast<QSGVideoNodeFactoryInterface*>(instance); if (plugin) { if (key == requestedVideoNode) m_videoNodeFactories.prepend(plugin); else m_videoNodeFactories.append(plugin); qCDebug(qLcVideo) << "found videonode plugin" << key << plugin; } }