示例#1
0
        private void InitializeSessionOnIemeThread(MediaKeySession session, DrmInitData initData)
        {
            var sessionId = CreateSession();

            session.SetSessionId(sessionId);

            lock (cdmInstanceLock)
                if (!sessionsByIds.TryAdd(sessionId, session))
                {
                    session.Release();
                    throw new Exception("Duplicate sessionId.");
                }

            GenerateRequest(sessionId, initData);
        }
示例#2
0
        private async Task <IDrmSession> CreateDrmSession(DrmInitData initData, IEnumerable <byte[]> keys, List <DrmDescription> clipDrmConfigurations)
        {
            Logger.Warn("Creating new DRM session.");
            var scheme         = EmeUtils.GetScheme(initData.SystemId);
            var drmDescription = clipDrmConfigurations.FirstOrDefault(o => SchemeEquals(o.Scheme, scheme));

            if (drmDescription == null)
            {
                Logger.Warn("DRM not configured.");
                throw new DrmException("DRM not configured.");
            }

            var iemeKeySystemName = EmeUtils.GetKeySystemName(initData.SystemId);

            if (IEME.isKeySystemSupported(iemeKeySystemName) != Status.kSupported)
            {
                Logger.Warn($"Key System: {iemeKeySystemName} is not supported");
                throw new DrmException($"Key System: {iemeKeySystemName} is not supported");
            }

            var session = new MediaKeySession(initData, drmDescription, keys, this);

            SessionInitializing();

            try
            {
                await thread.Factory.Run(() => InitializeSessionOnIemeThread(session, initData)).ConfigureAwait(false);
            }
            catch (Exception e)
            {
                Logger.Error($"EME session creation fail: {e}");
                SessionInitializingDone();
                CloseSession(session.GetSessionId());
                session.Release();
                return(null);
            }

            return(session);
        }
示例#3
0
 private bool TryGetSession(string sessionId, out MediaKeySession session)
 {
     lock (cdmInstanceLock)
         return(sessionsByIds.TryGetValue(sessionId, out session));
 }