Пример #1
0
PlayerResourcePolicy::PlayerResourcePolicy(QObject *parent) :
    QObject(parent),
    m_videoEnabled(true),
    m_resourceSet(0),
    m_status(PlayerResourcePolicy::Initial)
{
#ifdef HAVE_RESOURCE_POLICY
    m_resourceSet = new ResourcePolicy::ResourceSet("player", this);
    m_resourceSet->setAlwaysReply();

    ResourcePolicy::AudioResource *audioResource = new ResourcePolicy::AudioResource("player");
    audioResource->setProcessID(QCoreApplication::applicationPid());
    audioResource->setStreamTag("media.name", "*");
    m_resourceSet->addResourceObject(audioResource);

    m_resourceSet->addResource(ResourcePolicy::VideoPlaybackType);
    m_resourceSet->update();

    connect(m_resourceSet, SIGNAL(resourcesGranted(const QList<ResourcePolicy::ResourceType>)),
            this, SLOT(handleResourcesGranted()));
    connect(m_resourceSet, SIGNAL(resourcesDenied()),
            this, SLOT(handleResourcesDenied()));
    connect(m_resourceSet, SIGNAL(lostResources()),
            this, SLOT(handleResourcesLost()));
    connect(m_resourceSet, SIGNAL(resourcesReleasedByManager()),
            this, SLOT(handleResourcesLost()));
#endif
}
Пример #2
0
QT_BEGIN_NAMESPACE

//#define CAMEABIN_DEBUG 1
#define ENUM_NAME(c,e,v) (c::staticMetaObject.enumerator(c::staticMetaObject.indexOfEnumerator(e)).valueToKey((v)))

CameraBinControl::CameraBinControl(CameraBinSession *session)
    :QCameraControl(session),
    m_session(session),
    m_state(QCamera::UnloadedState),
    m_status(QCamera::UnloadedStatus),
    m_reloadPending(false)
{
    connect(m_session, SIGNAL(stateChanged(QCamera::State)),
            this, SLOT(updateStatus()));

    connect(m_session, SIGNAL(viewfinderChanged()),
            SLOT(reloadLater()));
    connect(m_session, SIGNAL(readyChanged(bool)),
            SLOT(reloadLater()));
    connect(m_session, SIGNAL(error(int,QString)),
            SLOT(handleCameraError(int,QString)));

    m_resourcePolicy = new CamerabinResourcePolicy(this);
    connect(m_resourcePolicy, SIGNAL(resourcesGranted()),
            SLOT(handleResourcesGranted()));
    connect(m_resourcePolicy, SIGNAL(resourcesDenied()),
            SLOT(handleResourcesLost()));
    connect(m_resourcePolicy, SIGNAL(resourcesLost()),
            SLOT(handleResourcesLost()));

    connect(m_session, SIGNAL(busyChanged(bool)),
            SLOT(handleBusyChanged(bool)));
}
Пример #3
0
ResourceManager::ResourceManager()
    : QObject(),
      m_resources(0),
      m_result(false),
      m_waiting(false)
{
    qRegisterMetaType<ResourcePolicy::ResourceSet*>("ResourcePolicy::ResourceSet*");
    qRegisterMetaType<ResourcePolicy::ResourceType>("ResourcePolicy::ResourceType");
    qRegisterMetaType<QList<ResourcePolicy::ResourceType> >("QList<ResourcePolicy::ResourceType>");

    m_resources = new ResourcePolicy::ResourceSet(QString::fromAscii("camera"),
                                                this);
    m_resources->setAlwaysReply();

    m_resources->addResource(ResourcePolicy::VideoPlaybackType);
    m_resources->addResource(ResourcePolicy::VideoRecorderType);

    QObject::connect(m_resources, SIGNAL(resourcesDenied()),
                     this, SLOT(denied()));
    QObject::connect(m_resources, SIGNAL(lostResources()),
                     this, SLOT(lost()));
    QObject::connect(m_resources,
                     SIGNAL(resourcesGranted(QList<ResourcePolicy::ResourceType>)),
                     this, SLOT(granted()));
}
Пример #4
0
void PlayerResourcePolicy::handleResourcesDenied()
{
    m_status = Initial;
#ifdef DEBUG_RESOURCE_POLICY
    qDebug() << Q_FUNC_INFO << "Resource denied";
#endif
    emit resourcesDenied();
}
QT_BEGIN_NAMESPACE

QGstreamerPlayerControl::QGstreamerPlayerControl(QGstreamerPlayerSession *session, QObject *parent)
    : QMediaPlayerControl(parent)
    , m_ownStream(false)
    , m_session(session)
    , m_userRequestedState(QMediaPlayer::StoppedState)
    , m_currentState(QMediaPlayer::StoppedState)
    , m_mediaStatus(QMediaPlayer::NoMedia)
    , m_bufferProgress(-1)
    , m_pendingSeekPosition(-1)
    , m_setMediaPending(false)
    , m_stream(0)
{
    m_resources = QMediaResourcePolicy::createResourceSet<QMediaPlayerResourceSetInterface>();
    Q_ASSERT(m_resources);

    connect(m_session, SIGNAL(positionChanged(qint64)),
            this, SIGNAL(positionChanged(qint64)));
    connect(m_session, SIGNAL(durationChanged(qint64)),
            this, SIGNAL(durationChanged(qint64)));
    connect(m_session, SIGNAL(mutedStateChanged(bool)),
            this, SIGNAL(mutedChanged(bool)));
    connect(m_session, SIGNAL(volumeChanged(int)),
            this, SIGNAL(volumeChanged(int)));
    connect(m_session, SIGNAL(stateChanged(QMediaPlayer::State)),
            this, SLOT(updateSessionState(QMediaPlayer::State)));
    connect(m_session,SIGNAL(bufferingProgressChanged(int)),
            this, SLOT(setBufferProgress(int)));
    connect(m_session, SIGNAL(playbackFinished()),
            this, SLOT(processEOS()));
    connect(m_session, SIGNAL(audioAvailableChanged(bool)),
            this, SIGNAL(audioAvailableChanged(bool)));
    connect(m_session, SIGNAL(videoAvailableChanged(bool)),
            this, SIGNAL(videoAvailableChanged(bool)));
    connect(m_session, SIGNAL(seekableChanged(bool)),
            this, SIGNAL(seekableChanged(bool)));
    connect(m_session, SIGNAL(error(int,QString)),
            this, SIGNAL(error(int,QString)));
    connect(m_session, SIGNAL(invalidMedia()),
            this, SLOT(handleInvalidMedia()));
    connect(m_session, SIGNAL(playbackRateChanged(qreal)),
            this, SIGNAL(playbackRateChanged(qreal)));

    connect(m_resources, SIGNAL(resourcesGranted()), SLOT(handleResourcesGranted()));
    //denied signal should be queued to have correct state update process,
    //since in playOrPause, when acquire is call on resource set, it may trigger a resourcesDenied signal immediately,
    //so handleResourcesDenied should be processed later, otherwise it will be overwritten by state update later in playOrPause.
    connect(m_resources, SIGNAL(resourcesDenied()), this, SLOT(handleResourcesDenied()), Qt::QueuedConnection);
    connect(m_resources, SIGNAL(resourcesLost()), SLOT(handleResourcesLost()));
}
Пример #6
0
ResourcePolicyInt::ResourcePolicyInt(QObject *parent)
    : QObject(parent)
    , m_acquired(0)
    , m_status(Initial)
    , m_video(0)
    , m_available(false)
    , m_resourceSet(0)
{
    const char *resourceClass = "player";

    QByteArray envVar = qgetenv("NEMO_RESOURCE_CLASS_OVERRIDE");
    if (!envVar.isEmpty()) {
        QString data(envVar);
        // Only allow few resource classes
        if (data == "navigator" ||
            data == "call"      ||
            data == "camera"    ||
            data == "game"      ||
            data == "player"    ||
            data == "event")
            resourceClass = envVar.constData();
    }

#ifdef RESOURCE_DEBUG
    qDebug() << "##### Using resource class " << resourceClass;
#endif

    m_resourceSet = new ResourcePolicy::ResourceSet(resourceClass, this);
    m_resourceSet->setAlwaysReply();

    connect(m_resourceSet, SIGNAL(resourcesGranted(QList<ResourcePolicy::ResourceType>)),
            this, SLOT(handleResourcesGranted()));
    connect(m_resourceSet, SIGNAL(resourcesDenied()),
            this, SLOT(handleResourcesDenied()));
    connect(m_resourceSet, SIGNAL(resourcesReleased()),
            this, SLOT(handleResourcesReleased()));
    connect(m_resourceSet, SIGNAL(lostResources()),
            this, SLOT(handleResourcesLost()));
    connect(m_resourceSet, SIGNAL(resourcesReleasedByManager()),
            this, SLOT(handleResourcesReleasedByManager()));

    connect(m_resourceSet, SIGNAL(resourcesBecameAvailable(const QList<ResourcePolicy::ResourceType>)),
            this, SLOT(handleResourcesBecameAvailable(const QList<ResourcePolicy::ResourceType>)));

    ResourcePolicy::AudioResource *audioResource = new ResourcePolicy::AudioResource(resourceClass);

    audioResource->setProcessID(QCoreApplication::applicationPid());
    audioResource->setStreamTag("media.name", "*");
    m_resourceSet->addResourceObject(audioResource);
    m_resourceSet->update();
}