#pragma once
#if ENABLE(VIDEO)
#include "SerializedPlatformDataCue.h"
#include "TextTrackCue.h"
#include <wtf/MediaTime.h>
#include <wtf/TypeCasts.h>
namespace JSC {
class ArrayBuffer;
class JSValue;
}
namespace WebCore {
class ScriptExecutionContext;
class DataCue final : public TextTrackCue {
WTF_MAKE_ISO_ALLOCATED(DataCue);
public:
static Ref<DataCue> create(Document&, double start, double end, ArrayBuffer& data);
static Ref<DataCue> create(Document&, double start, double end, JSC::JSValue, const String& type);
static Ref<DataCue> create(Document&, const MediaTime& start, const MediaTime& end, const void* data, unsigned length);
static Ref<DataCue> create(Document&, const MediaTime& start, const MediaTime& end, Ref<SerializedPlatformDataCue>&&, const String& type);
virtual ~DataCue();
RefPtr<JSC::ArrayBuffer> data() const;
void setData(JSC::ArrayBuffer&);
const SerializedPlatformDataCue* platformValue() const { return m_platformValue.get(); }
JSC::JSValue value(JSC::JSGlobalObject&) const;
void setValue(JSC::JSGlobalObject&, JSC::JSValue);
String type() const { return m_type; }
void setType(const String& type) { m_type = type; }
private:
DataCue(Document&, const MediaTime& start, const MediaTime& end, ArrayBuffer&, const String&);
DataCue(Document&, const MediaTime& start, const MediaTime& end, const void*, unsigned);
DataCue(Document&, const MediaTime& start, const MediaTime& end, Ref<SerializedPlatformDataCue>&&, const String&);
DataCue(Document&, const MediaTime& start, const MediaTime& end, JSC::JSValue, const String&);
JSC::JSValue valueOrNull() const;
CueType cueType() const final { return Data; }
bool cueContentsMatch(const TextTrackCue&) const final;
void toJSON(JSON::Object&) const final;
RefPtr<ArrayBuffer> m_data;
String m_type;
RefPtr<SerializedPlatformDataCue> m_platformValue;
JSC::Strong<JSC::Unknown> m_value;
};
}
namespace WTF {
template<> struct LogArgument<WebCore::DataCue> : LogArgument<WebCore::TextTrackCue> { };
}
SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::DataCue)
static bool isType(const WebCore::TextTrackCue& cue) { return cue.cueType() == WebCore::TextTrackCue::Data; }
SPECIALIZE_TYPE_TRAITS_END()
#endif