RTCRtpSFrameTransform.h [plain text]
#pragma once
#if ENABLE(WEB_RTC)
#include "ContextDestructionObserver.h"
#include "JSDOMPromiseDeferred.h"
#include "RTCRtpSFrameTransformer.h"
namespace WebCore {
class CryptoKey;
class RTCRtpTransformBackend;
class ReadableStream;
class SimpleReadableStreamSource;
class WritableStream;
class RTCRtpSFrameTransform : public RefCounted<RTCRtpSFrameTransform>, private ContextDestructionObserver {
public:
enum class Role { Encrypt, Decrypt };
using CompatibilityMode = RTCRtpSFrameTransformer::CompatibilityMode;
struct Options {
Role role { Role::Encrypt };
uint64_t authenticationSize { 10 };
CompatibilityMode compatibilityMode { CompatibilityMode::None };
};
static Ref<RTCRtpSFrameTransform> create(ScriptExecutionContext& context, Options options) { return adoptRef(*new RTCRtpSFrameTransform(context, options)); }
~RTCRtpSFrameTransform();
void setEncryptionKey(CryptoKey&, Optional<uint64_t>, DOMPromiseDeferred<void>&&);
bool isAttached() const;
void initializeBackendForReceiver(RTCRtpTransformBackend&);
void initializeBackendForSender(RTCRtpTransformBackend&);
void willClearBackend(RTCRtpTransformBackend&);
WEBCORE_EXPORT uint64_t counterForTesting() const;
WEBCORE_EXPORT uint64_t keyIdForTesting() const;
ExceptionOr<RefPtr<ReadableStream>> readable();
ExceptionOr<RefPtr<WritableStream>> writable();
private:
RTCRtpSFrameTransform(ScriptExecutionContext&, Options);
enum class Side { Sender, Receiver };
void initializeTransformer(RTCRtpTransformBackend&, Side);
void createStreams();
bool m_isAttached { false };
Ref<RTCRtpSFrameTransformer> m_transformer;
RefPtr<ReadableStream> m_readable;
RefPtr<WritableStream> m_writable;
RefPtr<SimpleReadableStreamSource> m_readableStreamSource;
};
}
#endif // ENABLE(WEB_RTC)