1 // Copyright 2016 Samsung Electronics. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CONTENT_BROWSER_RENDERER_HOST_PEPPER_MEDIA_PLAYER_TIZEN_PEPPER_TIZEN_DRM_SESSION_H_
6 #define CONTENT_BROWSER_RENDERER_HOST_PEPPER_MEDIA_PLAYER_TIZEN_PEPPER_TIZEN_DRM_SESSION_H_
8 #include <drmdecrypt_api.h>
9 #include <emeCDM/IEME.h>
12 #include "base/memory/ref_counted.h"
13 #include "base/memory/weak_ptr.h"
14 #include "ppapi/c/samsung/pp_media_player_samsung.h"
15 #include "ppapi/shared_impl/media_player/es_packet.h"
19 class PepperTizenDRMListener;
21 struct HandleAndSizeDeleter {
22 void operator()(handle_and_size_s* ptr) const;
25 using ScopedHandleAndSize =
26 std::unique_ptr<handle_and_size_s, HandleAndSizeDeleter>;
28 class PepperTizenDRMSession
29 : public base::RefCountedThreadSafe<PepperTizenDRMSession>,
30 public base::SupportsWeakPtr<PepperTizenDRMSession> {
32 static scoped_refptr<PepperTizenDRMSession> Create(PP_MediaPlayerDRMType,
33 eme::IEventListener*);
35 ~PepperTizenDRMSession();
37 bool Initialize(const std::string& init_data);
39 ScopedHandleAndSize Decrypt(const ppapi::EncryptedESPacket&);
41 bool InstallLicense(const std::string& response);
43 bool is_valid() const { return !session_id_.empty(); }
45 std::string session_id() const { return session_id_; }
48 friend class scoped_refptr<PepperTizenDRMSession>;
49 PepperTizenDRMSession(PP_MediaPlayerDRMType drm_type,
50 const std::string& keysystem_name,
51 eme::IEventListener* listener);
53 PP_MediaPlayerDRMType drm_type_;
54 std::string session_id_;
55 std::unique_ptr<eme::IEME, decltype(&eme::IEME::destroy)> ieme_;
57 bool InitializeSession();
60 ScopedHandleAndSize AdoptHandle(handle_and_size_s* handle_and_size);
62 void ClearHandle(handle_and_size_s* handle_and_size);
64 } // namespace content
66 #endif // CONTENT_BROWSER_RENDERER_HOST_PEPPER_MEDIA_PLAYER_TIZEN_PEPPER_TIZEN_DRM_SESSION_H_