| Index: content/renderer/media/cdm_session_id_adapter.h
|
| diff --git a/content/renderer/media/cdm_session_id_adapter.h b/content/renderer/media/cdm_session_id_adapter.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..4ffb348a4031c1cd579fe57cf2e3580582196fb3
|
| --- /dev/null
|
| +++ b/content/renderer/media/cdm_session_id_adapter.h
|
| @@ -0,0 +1,93 @@
|
| +// Copyright 2014 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#ifndef CONTENT_RENDERER_MEDIA_CDM_SESSION_ID_ADAPTER_H_
|
| +#define CONTENT_RENDERER_MEDIA_CDM_SESSION_ID_ADAPTER_H_
|
| +
|
| +#include <map>
|
| +
|
| +#include "base/basictypes.h"
|
| +#include "base/memory/ref_counted.h"
|
| +#include "base/memory/weak_ptr.h"
|
| +#include "media/base/media_keys.h"
|
| +
|
| +namespace content {
|
| +class WebContentDecryptionModuleSessionImpl;
|
| +
|
| +// Forwards the session ID-based callbacks of the MediaKeys interface to the
|
| +// appropriate session object. Both WebContentDecryptionModuleImpl and
|
| +// WebContentDecryptionModuleSessionImpl will hold references to this object.
|
| +class CdmSessionIdAdapter : public base::RefCounted<CdmSessionIdAdapter> {
|
| + public:
|
| + CdmSessionIdAdapter();
|
| +
|
| + // On success returns true.
|
| + bool Initialize(const std::string& key_system);
|
| +
|
| + // Generates a unique internal session id.
|
| + uint32 GenerateSessionId();
|
| +
|
| + // Adds a session to the internal map. Does not take ownership of the session.
|
| + void AddSession(uint32 session_id,
|
| + WebContentDecryptionModuleSessionImpl* session);
|
| +
|
| + // Removes a session from the internal map.
|
| + void RemoveSession(uint32 session_id);
|
| +
|
| + // Creates a session with the |content_type| and |init_data| provided.
|
| + bool CreateSession(uint32 session_id,
|
| + const std::string& content_type,
|
| + const uint8* init_data,
|
| + int init_data_length);
|
| +
|
| + // Updates a session specified by |session_id| with |response|.
|
| + void UpdateSession(uint32 session_id,
|
| + const uint8* response,
|
| + int response_length);
|
| +
|
| + // Releases the session specified by |session_id|.
|
| + void ReleaseSession(uint32 session_id);
|
| +
|
| + // Returns the Decryptor associated with this CDM. May be NULL if no
|
| + // Decryptor associated with the MediaKeys object.
|
| + // TODO(jrummell): Figure out lifetimes, as WMPI may still use the decryptor
|
| + // after WebContentDecryptionModule is freed. http://crbug.com/330324
|
| + media::Decryptor* GetDecryptor();
|
| +
|
| + private:
|
| + friend class base::RefCounted<CdmSessionIdAdapter>;
|
| + typedef std::map<uint32, WebContentDecryptionModuleSessionImpl*> SessionMap;
|
| +
|
| + ~CdmSessionIdAdapter();
|
| +
|
| + // Callbacks for firing session events.
|
| + void OnSessionCreated(uint32 session_id, const std::string& web_session_id);
|
| + void OnSessionMessage(uint32 session_id,
|
| + const std::vector<uint8>& message,
|
| + const std::string& destination_url);
|
| + void OnSessionReady(uint32 session_id);
|
| + void OnSessionClosed(uint32 session_id);
|
| + void OnSessionError(uint32 session_id,
|
| + media::MediaKeys::KeyError error_code,
|
| + int system_code);
|
| +
|
| + // Helper function of the callbacks.
|
| + WebContentDecryptionModuleSessionImpl* GetSession(uint32 session_id);
|
| +
|
| + // Keep ownership of MediaKeys.
|
| + scoped_ptr<media::MediaKeys> media_keys_;
|
| +
|
| + base::WeakPtrFactory<CdmSessionIdAdapter> weak_ptr_factory_;
|
| +
|
| + SessionMap sessions_;
|
| +
|
| + // Session ID should be unique per renderer process for debugging purposes.
|
| + static uint32 next_session_id_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(CdmSessionIdAdapter);
|
| +};
|
| +
|
| +} // namespace content
|
| +
|
| +#endif // CONTENT_RENDERER_MEDIA_CDM_SESSION_ID_ADAPTER_H_
|
|
|