CDMSessionMediaSourceAVFObjC.h [plain text]
#ifndef CDMSessionMediaSourceAVFObjC_h
#define CDMSessionMediaSourceAVFObjC_h
#include "CDMSession.h"
#include "SourceBufferPrivateAVFObjC.h"
#include <wtf/RetainPtr.h>
#include <wtf/WeakPtr.h>
#if ENABLE(ENCRYPTED_MEDIA_V2) && ENABLE(MEDIA_SOURCE)
OBJC_CLASS AVStreamDataParser;
OBJC_CLASS NSError;
namespace WebCore {
class CDMPrivateMediaSourceAVFObjC;
class CDMSessionMediaSourceAVFObjC : public CDMSession, public SourceBufferPrivateAVFObjCErrorClient {
public:
CDMSessionMediaSourceAVFObjC(CDMPrivateMediaSourceAVFObjC&, CDMSessionClient*);
virtual ~CDMSessionMediaSourceAVFObjC();
virtual void addParser(AVStreamDataParser*) = 0;
virtual void removeParser(AVStreamDataParser*) = 0;
void setClient(CDMSessionClient* client) override { m_client = client; }
const String& sessionId() const override { return m_sessionId; }
void layerDidReceiveError(AVSampleBufferDisplayLayer *, NSError *, bool& shouldIgnore) override;
void rendererDidReceiveError(AVSampleBufferAudioRenderer *, NSError *, bool& shouldIgnore) override;
void addSourceBuffer(SourceBufferPrivateAVFObjC*);
void removeSourceBuffer(SourceBufferPrivateAVFObjC*);
void setSessionId(const String& sessionId) { m_sessionId = sessionId; }
void invalidateCDM() { m_cdm = nullptr; }
protected:
String storagePath() const;
CDMPrivateMediaSourceAVFObjC* m_cdm;
CDMSessionClient* m_client { nullptr };
Vector<RefPtr<SourceBufferPrivateAVFObjC>> m_sourceBuffers;
RefPtr<Uint8Array> m_certificate;
String m_sessionId;
bool m_stopped { false };
};
inline CDMSessionMediaSourceAVFObjC* toCDMSessionMediaSourceAVFObjC(CDMSession* session)
{
if (!session || (session->type() != CDMSessionTypeAVStreamSession && session->type() != CDMSessionTypeAVContentKeySession))
return nullptr;
return static_cast<CDMSessionMediaSourceAVFObjC*>(session);
}
}
#endif // ENABLE(ENCRYPTED_MEDIA_V2) && ENABLE(MEDIA_SOURCE)
#endif // CDMSessionMediaSourceAVFObjC_h