Ejemplo n.º 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
}
Ejemplo n.º 2
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();
}