Note that this version does not have Widevine Provisioning 4.0 support. It is only suitable for device upgrades. A new patch with provisioning 4.0 support will be made later.
54 lines
1.7 KiB
C++
54 lines
1.7 KiB
C++
// Copyright 2018 Google LLC. All Rights Reserved. This file and proprietary
|
|
// source code may only be used and distributed under the Widevine Master
|
|
// License Agreement.
|
|
|
|
#ifndef WIDEVINE_CAS_SESSION_MAP_H
|
|
#define WIDEVINE_CAS_SESSION_MAP_H
|
|
|
|
#include <map>
|
|
#include <memory>
|
|
#include <mutex>
|
|
#include <string>
|
|
#include <utility>
|
|
|
|
#include "cas_types.h"
|
|
#include "widevine_cas_session.h"
|
|
|
|
namespace wvcas {
|
|
|
|
typedef std::map<WvCasSessionId, CasSessionPtr> CasSessionMap;
|
|
|
|
// WidevineCasSessionMap is a singleton. It used as a shared resource used by
|
|
// both cas and descrambler plugins. Cas sessions are created by the cas plugin,
|
|
// and can be *discovered* by descrambler plugins.
|
|
class WidevineCasSessionMap {
|
|
public:
|
|
virtual ~WidevineCasSessionMap() {}
|
|
|
|
// Adds a new Widevine cas session to the map.
|
|
// Returns true if the session is successfully added to the map, false
|
|
// otherwise.
|
|
bool AddSession(const WvCasSessionId& cas_session_id, CasSessionPtr session);
|
|
// Obtain a shared pointer to a cas session. If the session does not exist in
|
|
// the map, the returned pointer == nullptr.
|
|
CasSessionPtr GetSession(const WvCasSessionId& cas_session_id) const;
|
|
// Remove an entry in the map.
|
|
void RemoveSession(const WvCasSessionId& cas_session_id);
|
|
// Retrieves all the session ids.
|
|
std::vector<CasSessionPtr> GetAllSessions() const;
|
|
|
|
// Returns a reference to the map.
|
|
static WidevineCasSessionMap& instance();
|
|
|
|
WidevineCasSessionMap(const WidevineCasSessionMap&) = delete;
|
|
WidevineCasSessionMap& operator=(const WidevineCasSessionMap&) = delete;
|
|
|
|
private:
|
|
WidevineCasSessionMap() {}
|
|
CasSessionMap map_;
|
|
mutable std::mutex lock_;
|
|
};
|
|
|
|
} // namespace wvcas
|
|
|
|
#endif // WIDEVINE_CAS_SESSION_MAP_H
|