Пример #1
0
void MediaSource::setReadyState(const String& state)
{
    ASSERT(state == openKeyword() || state == closedKeyword() || state == endedKeyword());
    if (m_readyState == state)
        return;

    String oldState = m_readyState;
    m_readyState = state;

    if (m_readyState == closedKeyword()) {
        m_sourceBuffers->clear();
        m_activeSourceBuffers->clear();
        m_player = 0;
        scheduleEvent(eventNames().webkitsourcecloseEvent);
        return;
    }

    if (oldState == openKeyword() && m_readyState == endedKeyword()) {
        scheduleEvent(eventNames().webkitsourceendedEvent);
        return;
    }

    if (m_readyState == openKeyword()) {
        scheduleEvent(eventNames().webkitsourceopenEvent);
        return;
    }
}
Пример #2
0
MediaSourceBase::MediaSourceBase(ScriptExecutionContext* context)
    : ActiveDOMObject(context)
    , m_readyState(closedKeyword())
    , m_asyncEventQueue(*this)
    , m_attached(false)
{
}
Пример #3
0
void MediaSource::stop()
{
    m_asyncEventQueue.close();
    if (!isClosed())
        setReadyState(closedKeyword());
    m_private = nullptr;
}
Пример #4
0
void MediaSourceBase::stop()
{
    m_asyncEventQueue->close();
    if (!isClosed())
        setReadyState(closedKeyword());
    m_private.clear();
}
Пример #5
0
MediaSourceBase::MediaSourceBase(ScriptExecutionContext* context)
    : ActiveDOMObject(context)
    , m_readyState(closedKeyword())
    , m_asyncEventQueue(GenericEventQueue::create(this))
    , m_attachedElement(0)
{
}
Пример #6
0
MediaSource::MediaSource(ScriptExecutionContext* context)
    : ActiveDOMObject(context)
    , m_readyState(closedKeyword())
    , m_asyncEventQueue(*this)
    , m_sourceBuffers(SourceBufferList::create(scriptExecutionContext(), m_asyncEventQueue))
    , m_activeSourceBuffers(SourceBufferList::create(scriptExecutionContext(), m_asyncEventQueue))
{
}
Пример #7
0
MediaSource::MediaSource(ScriptExecutionContext* context)
    : ActiveDOMObject(context)
    , m_readyState(closedKeyword())
    , m_asyncEventQueue(GenericEventQueue::create(this))
{
    m_sourceBuffers = SourceBufferList::create(scriptExecutionContext(), m_asyncEventQueue.get());
    m_activeSourceBuffers = SourceBufferList::create(scriptExecutionContext(), m_asyncEventQueue.get());
}
Пример #8
0
PassRefPtr<TimeRanges> MediaSource::buffered(const String& id, ExceptionCode& ec) const
{
    if (!m_player || m_readyState == closedKeyword()) {
        ec = INVALID_STATE_ERR;
        return 0;
    }

    return m_player->sourceBuffered(id);
}
Пример #9
0
MediaSource::MediaSource(ScriptExecutionContext& context)
    : ActiveDOMObject(&context)
    , m_mediaElement(0)
    , m_readyState(closedKeyword())
    , m_asyncEventQueue(*this)
{
    LOG(Media, "MediaSource::MediaSource %p", this);
    m_sourceBuffers = SourceBufferList::create(scriptExecutionContext());
    m_activeSourceBuffers = SourceBufferList::create(scriptExecutionContext());
}
Пример #10
0
void MediaSource::setReadyState(const AtomicString& state)
{
    ASSERT(state == openKeyword() || state == closedKeyword() || state == endedKeyword());

    AtomicString oldState = readyState();
    LOG(Media, "MediaSource::setReadyState() %p : %s -> %s", this, oldState.string().ascii().data(), state.string().ascii().data());

    if (state == closedKeyword()) {
        m_private.clear();
        m_mediaElement = 0;
    }

    if (oldState == state)
        return;

    m_readyState = state;

    onReadyStateChange(oldState, state);
}
Пример #11
0
void MediaSource::setReadyState(const AtomicString& state)
{
    ASSERT(state == openKeyword() || state == closedKeyword() || state == endedKeyword());

    AtomicString oldState = readyState();
    LOG(MediaSource, "MediaSource::setReadyState(%p) : %s -> %s", this, oldState.string().ascii().data(), state.string().ascii().data());

    if (state == closedKeyword()) {
        m_private = nullptr;
        m_mediaElement = nullptr;
        m_duration = MediaTime::invalidTime();
    }

    if (oldState == state)
        return;

    m_readyState = state;

    onReadyStateChange(oldState, state);
}
Пример #12
0
MediaSource::MediaSource(ScriptExecutionContext& context)
    : ActiveDOMObject(&context)
    , m_mediaElement(nullptr)
    , m_duration(MediaTime::invalidTime())
    , m_pendingSeekTime(MediaTime::invalidTime())
    , m_readyState(closedKeyword())
    , m_asyncEventQueue(*this)
{
    LOG(MediaSource, "MediaSource::MediaSource %p", this);
    m_sourceBuffers = SourceBufferList::create(scriptExecutionContext());
    m_activeSourceBuffers = SourceBufferList::create(scriptExecutionContext());
}
Пример #13
0
bool MediaSource::setTimestampOffset(const String& id, double offset, ExceptionCode& ec)
{
    if (!m_player || m_readyState == closedKeyword()) {
        ec = INVALID_STATE_ERR;
        return false;
    }

    if (!m_player->sourceSetTimestampOffset(id, offset)) {
        ec = INVALID_STATE_ERR;
        return false;
    }
    return true;
}
Пример #14
0
void MediaSource::append(const String& id, PassRefPtr<Uint8Array> data, ExceptionCode& ec)
{
    if (!data.get()) {
        ec = INVALID_ACCESS_ERR;
        return;
    }

    if (!m_player || m_readyState == closedKeyword()) {
        ec = INVALID_STATE_ERR;
        return;
    }

    if (m_readyState == endedKeyword())
        setReadyState(openKeyword());

    if (!m_player->sourceAppend(id, data->data(), data->length())) {
        ec = SYNTAX_ERR;
        return;
    }
}
Пример #15
0
void MediaSource::close()
{
    setReadyState(closedKeyword());
}
Пример #16
0
bool MediaSource::isClosed() const
{
    return readyState() == closedKeyword();
}
Пример #17
0
double MediaSource::duration() const
{
    return m_readyState == closedKeyword() ? std::numeric_limits<float>::quiet_NaN() : m_player->duration();
}