void S60VideoPlayerSession::setVideoRenderer(QObject *videoOutput)
{
    DP0("S60VideoPlayerSession::setVideoRenderer +++");
    if (videoOutput != m_videoOutputControl) {
        if (m_videoOutputDisplay) {
            disconnect(m_videoOutputDisplay);
            m_videoOutputDisplay->disconnect(this);
            m_videoOutputDisplay = 0;
        }
        if (videoOutput) {
            if (S60VideoWidgetControl *control = qobject_cast<S60VideoWidgetControl *>(videoOutput))
                m_videoOutputDisplay = control->display();
            if (!m_videoOutputDisplay)
                return;
            m_videoOutputDisplay->setNativeSize(m_nativeSize);
            connect(this, SIGNAL(nativeSizeChanged(QSize)), m_videoOutputDisplay, SLOT(setNativeSize(QSize)));
            connect(m_videoOutputDisplay, SIGNAL(windowHandleChanged(RWindow *)), this, SLOT(windowHandleChanged()));
            connect(m_videoOutputDisplay, SIGNAL(displayRectChanged(QRect, QRect)), this, SLOT(displayRectChanged()));
            connect(m_videoOutputDisplay, SIGNAL(aspectRatioModeChanged(Qt::AspectRatioMode)), this, SLOT(aspectRatioChanged()));
            connect(m_videoOutputDisplay, SIGNAL(rotationChanged(qreal)), this, SLOT(rotationChanged()));
#ifndef VIDEOOUTPUT_GRAPHICS_SURFACES
            connect(m_videoOutputDisplay, SIGNAL(beginVideoWindowNativePaint()), this, SLOT(suspendDirectScreenAccess()));
            connect(m_videoOutputDisplay, SIGNAL(endVideoWindowNativePaint()), this, SLOT(resumeDirectScreenAccess()));
#endif
        }
        m_videoOutputControl = videoOutput;
        windowHandleChanged();
    }

    DP0("S60VideoPlayerSession::setVideoRenderer ---");
}
Beispiel #2
0
VideoItem::VideoItem(QString fileName, QObject *parent)
{
    this->setParent(parent);

    _fileName = fileName;
    //_videoData = new XMPMetadata(fileName);

    _emitShowTimeEnded = false;

    _player = new QMediaPlayer (this);
    _player->setVideoOutput(this);

    createPanel();

    connect (_player, SIGNAL(positionChanged(qint64)),
             this, SLOT(on_positionChanged(qint64)));
    connect (_player, SIGNAL(mediaStatusChanged(QMediaPlayer::MediaStatus)),
             this, SLOT(on_mediaStatusChanged(QMediaPlayer::MediaStatus)));
    connect (this, SIGNAL(nativeSizeChanged(QSizeF)),
             this, SLOT(on_nativeSizeChanged(QSizeF)));
    connect (_player, SIGNAL(stateChanged(QMediaPlayer::State)),
             this, SLOT(on_stateChanged(QMediaPlayer::State)));
    connect (_player, SIGNAL(volumeChanged(int)),
             this, SLOT(on_volumeChanged(int)));
}
void S60VideoDisplay::setNativeSize(const QSize &size)
{
    if (m_nativeSize != size) {
        m_nativeSize = size;
        emit nativeSizeChanged(m_nativeSize);
    }
}
void BbVideoWindowControl::setMetaData(const BbMetaData &metaData)
{
    m_metaData = metaData;
    emit nativeSizeChanged();

    // To handle the updated source size data
    updateVideoPosition();
}
Beispiel #5
0
void QEvrVideoOverlay::openStateChanged(long state)
{
    if (state == wmposMediaOpen) {
        setDisplayRect(m_displayRect);

        emit nativeSizeChanged();
    }
};
Beispiel #6
0
QDeclarativeVideo::QDeclarativeVideo(QDeclarativeItem *parent)
    : QDeclarativeItem(parent)
    , m_graphicsItem(0)

{
    m_graphicsItem = new QGraphicsVideoItem(this);
    connect(m_graphicsItem, SIGNAL(nativeSizeChanged(QSizeF)),
            this, SLOT(_q_nativeSizeChanged(QSizeF)));
}
void S60VideoEglRendererControl::setNativeSize(QSize size)
{
    if (size != m_nativeSize) {
        TRACE("S60VideoEglRendererControl::setNativeSize" << qtThisPtr()
              << "size" << size);
        m_nativeSize = size;
        emit nativeSizeChanged();
    }
}
S60VideoDisplay::S60VideoDisplay(QObject *parent)
:   QObject(parent)
,   m_fullScreen(false)
,   m_visible(true)
,   m_aspectRatioMode(Qt::KeepAspectRatio)
,   m_paintingEnabled(false)
,   m_rotation(0.0f)
{
    connect(this, SIGNAL(displayRectChanged(QRect, QRect)),
            this, SLOT(updateContentRect()));
    connect(this, SIGNAL(nativeSizeChanged(QSize)),
            this, SLOT(updateContentRect()));
}
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;
    }
}
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;
}
void QGstreamerGLTextureRenderer::stopRenderer()
{
#ifdef GL_TEXTURE_SINK_DEBUG
    qDebug() << Q_FUNC_INFO;
#endif

    if (m_surface && m_surface->isActive())
        m_surface->stop();

    if (!m_nativeSize.isEmpty()) {
        m_nativeSize = QSize();
        emit nativeSizeChanged();
    }
}
Beispiel #12
0
void QDeclarativeVideo::classBegin()
{
    m_graphicsItem = new QGraphicsVideoItem(this);
    connect(m_graphicsItem, SIGNAL(nativeSizeChanged(QSizeF)),
            this, SLOT(_q_nativeSizeChanged(QSizeF)));

    setObject(this);

    if (m_mediaService) {
        connect(m_playerControl, SIGNAL(audioAvailableChanged(bool)),
                this, SIGNAL(hasAudioChanged()));
        connect(m_playerControl, SIGNAL(videoAvailableChanged(bool)),
                this, SIGNAL(hasVideoChanged()));

        m_mediaObject->bind(m_graphicsItem);
    }
}
Beispiel #13
0
/*
  \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;
}
Beispiel #14
0
void QGstreamerVideoWindow::updateNativeVideoSize()
{
    const QSize oldSize = m_nativeSize;
    m_nativeSize = QSize();

    if (m_videoSink) {
        //find video native size to update video widget size hint
        GstPad *pad = gst_element_get_static_pad(m_videoSink,"sink");
        GstCaps *caps = gst_pad_get_negotiated_caps(pad);

        if (caps) {
            m_nativeSize = QGstUtils::capsCorrectedResolution(caps);
            gst_caps_unref(caps);
        }
    }

    if (m_nativeSize != oldSize)
        emit nativeSizeChanged();
}
void S60VideoPlayerSession::MvpuoPrepareComplete(TInt aError)
{
    DP0("S60VideoPlayerSession::MvpuoPrepareComplete +++");

    DP1("S60VideoPlayerSession::MvpuoPrepareComplete - aError:", aError);

    if (KErrNone == aError && m_stream) {
        emit accessPointChanged(m_accessPointId);
    }
    if (KErrCouldNotConnect == aError && !(m_networkAccessControl->isLastAccessPoint())) {
        load(m_UrlPath);
        return;
    }
    TInt error = aError;
    if (KErrNone == error || KErrMMPartialPlayback == error) {
        TSize originalSize;
        TRAP(error, m_player->VideoFrameSizeL(originalSize));
        if (KErrNone == error) {
            m_nativeSize = QSize(originalSize.iWidth, originalSize.iHeight);
            emit nativeSizeChanged(m_nativeSize);
            m_pendingChanges |= ScaleFactors;
#ifdef HAS_AUDIOROUTING_IN_VIDEOPLAYER
            Q_ASSERT(!m_audioOutput);
            TRAP(error, m_audioOutput = CAudioOutput::NewL(*m_player));
            if (KErrNone == error) {
                TRAP(error, m_audioOutput->RegisterObserverL(*this));
                if (KErrNone == error)
                    setActiveEndpoint(m_audioEndpoint);
            }
#endif
        }
        if (KErrNone == error) {
            applyPendingChanges(true); // force apply even though state is not Loaded
            if (KErrNone == this->error()) // applyPendingChanges() can call setError()
                loaded();
        }
    } else {
        setError(error);
    }

    DP0("S60VideoPlayerSession::MvpuoPrepareComplete ---");
}
AMCrosshairOverlayVideoWidget::AMCrosshairOverlayVideoWidget(QWidget *parent, bool useOpenGlViewport) :
	AMOverlayVideoWidget(parent, useOpenGlViewport)
{
	crosshairX_ = 0.5;
	crosshairY_ = 0.5;

	QPen pen(Qt::red);

	crosshairXLine_ = scene()->addLine(0.5,0,0.5,1,pen);
	crosshairYLine_ = scene()->addLine(0,0.5,0,1,pen);

	crosshairXLine_->setVisible(false);
	crosshairYLine_->setVisible(false);

	reviewCrosshairLinePositions();

	doubleClickInProgress_ = false;

	connect(videoItem_, SIGNAL(nativeSizeChanged(QSizeF)), this, SLOT(reviewCrosshairLinePositions()));
}
Beispiel #17
0
void QGstreamerGLTextureRenderer::updateNativeVideoSize()
{
    const QSize oldSize = m_nativeSize;

    if (m_videoSink) {
        //find video native size to update video widget size hint
        GstPad *pad = gst_element_get_static_pad(m_videoSink,"sink");
        GstCaps *caps = gst_pad_get_negotiated_caps(pad);

        if (caps) {
            m_nativeSize = QGstUtils::capsCorrectedResolution(caps);
            gst_caps_unref(caps);
        }
    } else {
        m_nativeSize = QSize();
    }
#ifdef GL_TEXTURE_SINK_DEBUG
    qDebug() << Q_FUNC_INFO << oldSize << m_nativeSize << m_videoSink;
#endif

    if (m_nativeSize != oldSize)
        emit nativeSizeChanged();
}
Beispiel #18
0
void QGstreamerGLTextureRenderer::stopRenderer()
{
#ifdef GL_TEXTURE_SINK_DEBUG
    qDebug() << Q_FUNC_INFO;
#endif

    if (m_surface && m_surface->isActive())
        m_surface->stop();

    if (m_fallbackImage.isNull()) {
        if (!m_nativeSize.isEmpty()) {
            m_nativeSize = QSize();
            emit nativeSizeChanged();
        }
    } else {
        if (m_surface) {
            QVideoSurfaceFormat format(m_fallbackImage.size(), QVideoFrame::Format_RGB32);
            format.setPixelAspectRatio(m_nativeSize.width(), m_fallbackImage.width());

            if (m_surface->start(format))
                m_surface->present(QVideoFrame(m_fallbackImage));
        }
    }
}
Beispiel #19
0
void QGstreamerGLTextureRenderer::renderGLFrame(int frame)
{
#if defined(GL_TEXTURE_SINK_DEBUG) && GL_TEXTURE_SINK_DEBUG > 1
    qDebug() << Q_FUNC_INFO << "frame:" << frame << "surface active:" << m_surface->isActive();
#endif
    QMutexLocker locker(&m_mutex);

    if (!m_surface || !m_glEnabled) {
        m_renderCondition.wakeAll();
        return;
    }

    MeegoGstVideoTexture *textureSink = MEEGO_GST_VIDEO_TEXTURE(m_videoSink);

    if (m_context)
        m_context->makeCurrent();

    //don't try to render the frame if state is changed to NULL or READY
    GstState pendingState = GST_STATE_NULL;
    GstState newState = GST_STATE_NULL;
    GstStateChangeReturn res = gst_element_get_state(m_videoSink,
                                                     &newState,
                                                     &pendingState,
                                                     0);//don't block and return immediately

    if (res == GST_STATE_CHANGE_FAILURE ||
            newState == GST_STATE_NULL ||
            pendingState == GST_STATE_NULL) {
        stopRenderer();
        m_renderCondition.wakeAll();
        return;
    }

    if (m_surface->isActive() && m_surface->surfaceFormat().handleType() != EGLImageTextureHandle)
        m_surface->stop();

    if (!m_surface->isActive()) {
        //find the native video size
        GstPad *pad = gst_element_get_static_pad(m_videoSink,"sink");
        GstCaps *caps = gst_pad_get_negotiated_caps(pad);

        if (caps) {
            QSize newNativeSize = QGstUtils::capsCorrectedResolution(caps);
            if (m_nativeSize != newNativeSize) {
                m_nativeSize = newNativeSize;
                emit nativeSizeChanged();
            }
            gst_caps_unref(caps);
        }

        //start the surface...
        QVideoSurfaceFormat format(m_nativeSize, QVideoFrame::Format_RGB32, EGLImageTextureHandle);
        if (!m_surface->start(format)) {
            qWarning() << Q_FUNC_INFO << "failed to start video surface" << format;
            m_renderCondition.wakeAll();
            return;
        }
    }

    QGStreamerGLTextureBuffer *buffer = new QGStreamerGLTextureBuffer(textureSink, frame);
    QVideoFrame videoFrame(buffer,
                           m_surface->surfaceFormat().frameSize(),
                           m_surface->surfaceFormat().pixelFormat());
    m_surface->present(videoFrame);
    m_renderCondition.wakeAll();
}
void QGstreamerVideoOverlay::surfaceFormatChanged()
{
    setScaledDisplayRect();

    emit nativeSizeChanged();
}