Ejemplo n.º 1
0
void WebMediaSessionManager::removePlaybackTargetPickerClient(WebMediaSessionManagerClient& client, uint64_t contextId)
{
    size_t index = find(&client, contextId);
    ASSERT(index != notFound);
    if (index == notFound)
        return;

    m_clientState.remove(index);
    configurePlaybackTargetMonitoring();

    if (m_playbackTarget && m_clientState.size() == 1 && m_playbackTarget->hasActiveRoute())
        m_clientState[0]->client->setShouldPlayToPlaybackTarget(m_clientState[0]->contextId, true);
}
Ejemplo n.º 2
0
void WebMediaSessionManager::taskTimerFired()
{
    LOG(Media, "WebMediaSessionManager::taskTimerFired - tasks = %s", toString(m_taskFlags).utf8().data());

    if (m_taskFlags & InitialConfigurationTask)
        configureNewClients();
    if (m_taskFlags & TargetClientsConfigurationTask)
        configurePlaybackTargetClients();
    if (m_taskFlags & TargetMonitoringConfigurationTask)
        configurePlaybackTargetMonitoring();

    m_taskFlags = NoTask;
}
Ejemplo n.º 3
0
void WebMediaSessionManager::clientStateDidChange(WebMediaSessionManagerClient& client, uint64_t contextId, MediaProducer::MediaStateFlags newFlags)
{
    size_t index = find(&client, contextId);
    ASSERT(index != notFound);
    if (index == notFound)
        return;

    auto& changedClientState = m_clientState[index];
    MediaProducer::MediaStateFlags oldFlags = changedClientState->flags;
    if (newFlags == oldFlags)
        return;

    changedClientState->flags = newFlags;
    if (!flagsAreSet(oldFlags, MediaProducer::RequiresPlaybackTargetMonitoring) && flagsAreSet(newFlags, MediaProducer::RequiresPlaybackTargetMonitoring))
        configurePlaybackTargetMonitoring();

    if (!flagsAreSet(newFlags, MediaProducer::IsPlayingVideo))
        return;

    // Do not interrupt another element already playing to a device.
    for (auto& state : m_clientState) {
        if (state->contextId == contextId && state->client == &client)
            continue;

        if (flagsAreSet(state->flags, MediaProducer::IsPlayingVideo) && flagsAreSet(state->flags, MediaProducer::IsPlayingToExternalDevice))
            return;
    }

    if (m_playbackTarget && m_playbackTarget->hasActiveRoute()) {

        for (auto& state : m_clientState) {
            if (state->contextId == contextId && state->client == &client)
                continue;
            state->client->setShouldPlayToPlaybackTarget(state->contextId, false);
        }

        changedClientState->client->setShouldPlayToPlaybackTarget(changedClientState->contextId, true);
    }

    if (index && m_clientState.size() > 1)
        std::swap(m_clientState.at(index), m_clientState.at(0));
}