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; } }
MediaSourceBase::MediaSourceBase(ScriptExecutionContext* context) : ActiveDOMObject(context) , m_readyState(closedKeyword()) , m_asyncEventQueue(*this) , m_attached(false) { }
void MediaSource::stop() { m_asyncEventQueue.close(); if (!isClosed()) setReadyState(closedKeyword()); m_private = nullptr; }
void MediaSourceBase::stop() { m_asyncEventQueue->close(); if (!isClosed()) setReadyState(closedKeyword()); m_private.clear(); }
MediaSourceBase::MediaSourceBase(ScriptExecutionContext* context) : ActiveDOMObject(context) , m_readyState(closedKeyword()) , m_asyncEventQueue(GenericEventQueue::create(this)) , m_attachedElement(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)) { }
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()); }
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); }
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()); }
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); }
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); }
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()); }
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; }
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; } }
void MediaSource::close() { setReadyState(closedKeyword()); }
bool MediaSource::isClosed() const { return readyState() == closedKeyword(); }
double MediaSource::duration() const { return m_readyState == closedKeyword() ? std::numeric_limits<float>::quiet_NaN() : m_player->duration(); }