SourceBufferList.h [plain text]
#ifndef SourceBufferList_h
#define SourceBufferList_h
#if ENABLE(MEDIA_SOURCE)
#include "EventTarget.h"
#include "GenericEventQueue.h"
#include "ScriptWrappable.h"
#include <wtf/RefCounted.h>
#include <wtf/Vector.h>
namespace WebCore {
class SourceBuffer;
class SourceBufferList final : public RefCounted<SourceBufferList>, public ScriptWrappable, public EventTargetWithInlineData {
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() : 0; }
void add(PassRefPtr<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(); }
virtual EventTargetInterface eventTargetInterface() const override { return SourceBufferListEventTargetInterfaceType; }
virtual ScriptExecutionContext* scriptExecutionContext() const override { return m_scriptExecutionContext; }
using RefCounted<SourceBufferList>::ref;
using RefCounted<SourceBufferList>::deref;
private:
explicit SourceBufferList(ScriptExecutionContext*);
void scheduleEvent(const AtomicString&);
virtual void refEventTarget() override { ref(); }
virtual void derefEventTarget() override { deref(); }
ScriptExecutionContext* m_scriptExecutionContext;
GenericEventQueue m_asyncEventQueue;
Vector<RefPtr<SourceBuffer>> m_list;
};
}
#endif
#endif