SourceBufferList.h [plain text]
#pragma once
#if ENABLE(MEDIA_SOURCE)
#include "ContextDestructionObserver.h"
#include "EventTarget.h"
#include "GenericEventQueue.h"
#include <wtf/RefCounted.h>
#include <wtf/Vector.h>
namespace WebCore {
class SourceBuffer;
class SourceBufferList final : public RefCounted<SourceBufferList>, public EventTargetWithInlineData, public ContextDestructionObserver {
public:
static Ref<SourceBufferList> create(ScriptExecutionContext* context)
{
return adoptRef(*new SourceBufferList(context));
}
virtual ~SourceBufferList();
unsigned long length() const { return m_list.size(); }
SourceBuffer* item(unsigned long index) const { return (index < m_list.size()) ? m_list[index].get() : nullptr; }
void add(Ref<SourceBuffer>&&);
void remove(SourceBuffer&);
bool contains(SourceBuffer& buffer) { return m_list.find(&buffer) != notFound; }
void clear();
void swap(Vector<RefPtr<SourceBuffer>>&);
Vector<RefPtr<SourceBuffer>>::iterator begin() { return m_list.begin(); }
Vector<RefPtr<SourceBuffer>>::iterator end() { return m_list.end(); }
EventTargetInterface eventTargetInterface() const final { return SourceBufferListEventTargetInterfaceType; }
ScriptExecutionContext* scriptExecutionContext() const final { return ContextDestructionObserver::scriptExecutionContext(); }
using RefCounted<SourceBufferList>::ref;
using RefCounted<SourceBufferList>::deref;
private:
explicit SourceBufferList(ScriptExecutionContext*);
void scheduleEvent(const AtomicString&);
void refEventTarget() override { ref(); }
void derefEventTarget() override { deref(); }
GenericEventQueue m_asyncEventQueue;
Vector<RefPtr<SourceBuffer>> m_list;
};
}
#endif // ENABLE(MEDIA_SOURCE)