RTCRtpScriptTransformerContext.h [plain text]
#pragma once
#if ENABLE(WEB_RTC)
#include "RTCRtpTransformBackend.h"
#include <wtf/Ref.h>
namespace WebCore {
class RTCRtpTransformBackend;
class RTCRtpScriptTransformerContext
: public RefCounted<RTCRtpScriptTransformerContext> {
public:
static Ref<RTCRtpScriptTransformerContext> create(Ref<RTCRtpTransformBackend>&&);
~RTCRtpScriptTransformerContext() = default;
using Side = RTCRtpTransformBackend::Side;
Side side() const { return m_backend->side(); }
using MediaType = RTCRtpTransformBackend::MediaType;
MediaType mediaType() const { return m_backend->mediaType(); }
ExceptionOr<void> requestKeyFrame();
private:
explicit RTCRtpScriptTransformerContext(Ref<RTCRtpTransformBackend>&&);
Ref<RTCRtpTransformBackend> m_backend;
};
inline Ref<RTCRtpScriptTransformerContext> RTCRtpScriptTransformerContext::create(Ref<RTCRtpTransformBackend>&& backend)
{
return adoptRef(*new RTCRtpScriptTransformerContext(WTFMove(backend)));
}
inline RTCRtpScriptTransformerContext::RTCRtpScriptTransformerContext(Ref<RTCRtpTransformBackend>&& backend)
: m_backend(WTFMove(backend))
{
}
inline ExceptionOr<void> RTCRtpScriptTransformerContext::requestKeyFrame()
{
switch (mediaType()) {
case MediaType::Audio:
return Exception { InvalidStateError, "Cannot request key frame on audio sender"_s };
case MediaType::Video:
m_backend->requestKeyFrame();
return { };
default:
return { };
}
}
}
#endif // ENABLE(WEB_RTC)