Exemplo n.º 1
0
void BbMediaPlayerControl::emitMmError(const QString &msg)
{
    int errorCode = MMR_ERROR_NONE;
    const QString errorMessage = mmErrorMessage(msg, m_context, &errorCode);
    qBbMediaDebug() << errorMessage;
    emit error(errorCode, errorMessage);
}
void BbVideoWindowControl::attachDisplay(mmr_context_t *context)
{
    if (m_videoId != -1) {
        qDebug() << "BbVideoWindowControl: Video output already attached!";
        return;
    }

    if (!context) {
        qDebug() << "BbVideoWindowControl: No media player context!";
        return;
    }

    if (!m_widget) {
        qDebug() << "BbVideoWindowControl: No video widget!";
        return;
    }

    QPlatformNativeInterface * const nativeInterface = QApplication::platformNativeInterface();
    if (!nativeInterface) {
        qDebug() << "BbVideoWindowControl: Unable to get platform native interface. Qt too old?";
        return;
    }

    const char * const groupNameData = static_cast<const char *>(
        nativeInterface->nativeResourceForWidget("windowGroup", m_widget));
    if (!groupNameData) {
        qDebug() << "BbVideoWindowControl: Unable to find window group for widget" << m_widget;
        return;
    }

    const QString groupName = QString::fromAscii(groupNameData);
    m_windowName = QString("BbVideoWindowControl_%1_%2").arg(winIdCounter++)
                                                        .arg(QCoreApplication::applicationPid());
    // Start with an invisible window. If it would be visible right away, it would be at the wrong
    // position, and we can only change the position once we get the window handle.
    const QString videoDeviceUrl =
            QString("screen:?winid=%1&wingrp=%2&initflags=invisible&nodstviewport=1").arg(m_windowName).arg(groupName);

    m_videoId = mmr_output_attach(context, videoDeviceUrl.toAscii(), "video");
    if (m_videoId == -1) {
        qDebug() << mmErrorMessage("mmr_output_attach() for video failed", context);
        return;
    }

    m_context = context;
    updateVideoPosition();
    updateHue();
    updateContrast();
    updateBrightness();
    updateSaturation();
}