Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(41)

Side by Side Diff: media/mojo/services/mojo_cdm_service.h

Issue 840473002: media: Support creation and SetCdm() for mojo based CDM. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef MEDIA_MOJO_SERVICES_MOJO_CDM_SERVICE_H_ 5 #ifndef MEDIA_MOJO_SERVICES_MOJO_CDM_SERVICE_H_
6 #define MEDIA_MOJO_SERVICES_MOJO_CDM_SERVICE_H_ 6 #define MEDIA_MOJO_SERVICES_MOJO_CDM_SERVICE_H_
7 7
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
11 #include "base/memory/weak_ptr.h" 11 #include "base/memory/weak_ptr.h"
12 #include "media/base/media_keys.h" 12 #include "media/base/media_keys.h"
13 #include "media/mojo/interfaces/content_decryption_module.mojom.h" 13 #include "media/mojo/interfaces/content_decryption_module.mojom.h"
14 #include "mojo/public/cpp/bindings/interface_impl.h" 14 #include "mojo/public/cpp/bindings/interface_impl.h"
15 15
16 namespace media { 16 namespace media {
17 17
18 class MojoCdmServiceContext;
19
18 // A mojo::ContentDecryptionModule implementation backed by a media::MediaKeys. 20 // A mojo::ContentDecryptionModule implementation backed by a media::MediaKeys.
19 class MojoCdmService 21 class MojoCdmService
20 : public mojo::InterfaceImpl<mojo::ContentDecryptionModule> { 22 : public mojo::InterfaceImpl<mojo::ContentDecryptionModule> {
21 public: 23 public:
22 MojoCdmService(const mojo::String& key_system); 24 // Creates MojoCdmService for |key_system|. Returns nullptr if |key_system| is
25 // not supported.
26 static MojoCdmService* Create(MojoCdmServiceContext* context,
27 const mojo::String& key_system);
28
23 ~MojoCdmService() final; 29 ~MojoCdmService() final;
24 30
25 // mojo::ContentDecryptionModule implementation. 31 // mojo::ContentDecryptionModule implementation.
26 void SetServerCertificate( 32 void SetServerCertificate(
27 mojo::Array<uint8_t> certificate_data, 33 mojo::Array<uint8_t> certificate_data,
28 const mojo::Callback<void(mojo::CdmPromiseResultPtr)>& callback) final; 34 const mojo::Callback<void(mojo::CdmPromiseResultPtr)>& callback) final;
29 void CreateSession(const mojo::String& init_data_type, 35 void CreateSession(const mojo::String& init_data_type,
30 mojo::Array<uint8_t> init_data, 36 mojo::Array<uint8_t> init_data,
31 mojo::ContentDecryptionModule::SessionType session_type, 37 mojo::ContentDecryptionModule::SessionType session_type,
32 const mojo::Callback<void(mojo::CdmPromiseResultPtr, 38 const mojo::Callback<void(mojo::CdmPromiseResultPtr,
33 mojo::String)>& callback) final; 39 mojo::String)>& callback) final;
34 void LoadSession(const mojo::String& session_id, 40 void LoadSession(const mojo::String& session_id,
35 const mojo::Callback<void(mojo::CdmPromiseResultPtr, 41 const mojo::Callback<void(mojo::CdmPromiseResultPtr,
36 mojo::String)>& callback) final; 42 mojo::String)>& callback) final;
37 void UpdateSession( 43 void UpdateSession(
38 const mojo::String& session_id, 44 const mojo::String& session_id,
39 mojo::Array<uint8_t> response, 45 mojo::Array<uint8_t> response,
40 const mojo::Callback<void(mojo::CdmPromiseResultPtr)>& callback) final; 46 const mojo::Callback<void(mojo::CdmPromiseResultPtr)>& callback) final;
41 void CloseSession( 47 void CloseSession(
42 const mojo::String& session_id, 48 const mojo::String& session_id,
43 const mojo::Callback<void(mojo::CdmPromiseResultPtr)>& callback) final; 49 const mojo::Callback<void(mojo::CdmPromiseResultPtr)>& callback) final;
44 void RemoveSession( 50 void RemoveSession(
45 const mojo::String& session_id, 51 const mojo::String& session_id,
46 const mojo::Callback<void(mojo::CdmPromiseResultPtr)>& callback) final; 52 const mojo::Callback<void(mojo::CdmPromiseResultPtr)>& callback) final;
47 void GetCdmContext(int32_t cdm_id, 53 void GetDecryptor(mojo::InterfaceRequest<mojo::Decryptor> decryptor) final;
48 mojo::InterfaceRequest<mojo::Decryptor> decryptor) final; 54
55 // Get CdmContext to be used by the media pipeline.
56 CdmContext* GetCdmContext();
49 57
50 private: 58 private:
59 MojoCdmService(MojoCdmServiceContext* context,
60 const mojo::String& key_system);
61
62 // mojo::InterfaceImpl implementation.
63 void OnConnectionError() override;
64
51 // Callbacks for firing session events. 65 // Callbacks for firing session events.
52 void OnSessionMessage(const std::string& session_id, 66 void OnSessionMessage(const std::string& session_id,
53 const std::vector<uint8_t>& message, 67 const std::vector<uint8_t>& message,
54 const GURL& destination_url); 68 const GURL& destination_url);
55 void OnSessionKeysChange(const std::string& session_id, 69 void OnSessionKeysChange(const std::string& session_id,
56 bool has_additional_usable_key); 70 bool has_additional_usable_key);
57 void OnSessionExpirationUpdate(const std::string& session_id, 71 void OnSessionExpirationUpdate(const std::string& session_id,
58 const base::Time& new_expiry_time); 72 const base::Time& new_expiry_time);
59 void OnSessionClosed(const std::string& session_id); 73 void OnSessionClosed(const std::string& session_id);
60 void OnSessionError(const std::string& session_id, 74 void OnSessionError(const std::string& session_id,
61 MediaKeys::Exception exception, 75 MediaKeys::Exception exception,
62 uint32_t system_code, 76 uint32_t system_code,
63 const std::string& error_message); 77 const std::string& error_message);
64 78
79 MojoCdmServiceContext* context_;
65 scoped_ptr<MediaKeys> cdm_; 80 scoped_ptr<MediaKeys> cdm_;
66 81
67 base::WeakPtrFactory<MojoCdmService> weak_factory_; 82 base::WeakPtrFactory<MojoCdmService> weak_factory_;
68 base::WeakPtr<MojoCdmService> weak_this_; 83 base::WeakPtr<MojoCdmService> weak_this_;
69 84
70 DISALLOW_COPY_AND_ASSIGN(MojoCdmService); 85 DISALLOW_COPY_AND_ASSIGN(MojoCdmService);
71 }; 86 };
72 87
73 } // namespace media 88 } // namespace media
74 89
75 #endif // MEDIA_MOJO_SERVICES_MOJO_CDM_SERVICE_H_ 90 #endif // MEDIA_MOJO_SERVICES_MOJO_CDM_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698