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

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: Fix TODO. Created 5 years, 9 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 "third_party/mojo/src/mojo/public/cpp/bindings/interface_impl.h" 14 #include "third_party/mojo/src/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 SetClient(mojo::ContentDecryptionModuleClientPtr client) final; 32 void SetClient(mojo::ContentDecryptionModuleClientPtr client) final;
27 void SetServerCertificate( 33 void SetServerCertificate(
28 mojo::Array<uint8_t> certificate_data, 34 mojo::Array<uint8_t> certificate_data,
29 const mojo::Callback<void(mojo::CdmPromiseResultPtr)>& callback) final; 35 const mojo::Callback<void(mojo::CdmPromiseResultPtr)>& callback) final;
30 void CreateSessionAndGenerateRequest( 36 void CreateSessionAndGenerateRequest(
31 mojo::ContentDecryptionModule::SessionType session_type, 37 mojo::ContentDecryptionModule::SessionType session_type,
32 const mojo::String& init_data_type, 38 const mojo::String& init_data_type,
33 mojo::Array<uint8_t> init_data, 39 mojo::Array<uint8_t> init_data,
34 const mojo::Callback<void(mojo::CdmPromiseResultPtr, mojo::String)>& 40 const mojo::Callback<void(mojo::CdmPromiseResultPtr, mojo::String)>&
35 callback) final; 41 callback) final;
36 void LoadSession(mojo::ContentDecryptionModule::SessionType session_type, 42 void LoadSession(mojo::ContentDecryptionModule::SessionType session_type,
37 const mojo::String& session_id, 43 const mojo::String& session_id,
38 const mojo::Callback<void(mojo::CdmPromiseResultPtr, 44 const mojo::Callback<void(mojo::CdmPromiseResultPtr,
39 mojo::String)>& callback) final; 45 mojo::String)>& callback) final;
40 void UpdateSession( 46 void UpdateSession(
41 const mojo::String& session_id, 47 const mojo::String& session_id,
42 mojo::Array<uint8_t> response, 48 mojo::Array<uint8_t> response,
43 const mojo::Callback<void(mojo::CdmPromiseResultPtr)>& callback) final; 49 const mojo::Callback<void(mojo::CdmPromiseResultPtr)>& callback) final;
44 void CloseSession( 50 void CloseSession(
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 RemoveSession( 53 void RemoveSession(
48 const mojo::String& session_id, 54 const mojo::String& session_id,
49 const mojo::Callback<void(mojo::CdmPromiseResultPtr)>& callback) final; 55 const mojo::Callback<void(mojo::CdmPromiseResultPtr)>& callback) final;
50 void GetCdmContext(int32_t cdm_id, 56 void GetDecryptor(mojo::InterfaceRequest<mojo::Decryptor> decryptor) final;
51 mojo::InterfaceRequest<mojo::Decryptor> decryptor) final; 57
58 // Get CdmContext to be used by the media pipeline.
59 CdmContext* GetCdmContext();
52 60
53 private: 61 private:
62 MojoCdmService(MojoCdmServiceContext* context,
63 const mojo::String& key_system);
64
65 // mojo::InterfaceImpl implementation.
66 void OnConnectionError() override;
67
54 // Callbacks for firing session events. 68 // Callbacks for firing session events.
55 void OnSessionMessage(const std::string& session_id, 69 void OnSessionMessage(const std::string& session_id,
56 MediaKeys::MessageType message_type, 70 MediaKeys::MessageType message_type,
57 const std::vector<uint8_t>& message, 71 const std::vector<uint8_t>& message,
58 const GURL& legacy_destination_url); 72 const GURL& legacy_destination_url);
59 void OnSessionKeysChange(const std::string& session_id, 73 void OnSessionKeysChange(const std::string& session_id,
60 bool has_additional_usable_key, 74 bool has_additional_usable_key,
61 CdmKeysInfo keys_info); 75 CdmKeysInfo keys_info);
62 void OnSessionExpirationUpdate(const std::string& session_id, 76 void OnSessionExpirationUpdate(const std::string& session_id,
63 const base::Time& new_expiry_time); 77 const base::Time& new_expiry_time);
64 void OnSessionClosed(const std::string& session_id); 78 void OnSessionClosed(const std::string& session_id);
65 void OnSessionError(const std::string& session_id, 79 void OnSessionError(const std::string& session_id,
66 MediaKeys::Exception exception, 80 MediaKeys::Exception exception,
67 uint32_t system_code, 81 uint32_t system_code,
68 const std::string& error_message); 82 const std::string& error_message);
69 83
84 MojoCdmServiceContext* context_;
70 scoped_ptr<MediaKeys> cdm_; 85 scoped_ptr<MediaKeys> cdm_;
71 86
72 mojo::ContentDecryptionModuleClientPtr client_; 87 mojo::ContentDecryptionModuleClientPtr client_;
73 88
74 base::WeakPtr<MojoCdmService> weak_this_; 89 base::WeakPtr<MojoCdmService> weak_this_;
75 base::WeakPtrFactory<MojoCdmService> weak_factory_; 90 base::WeakPtrFactory<MojoCdmService> weak_factory_;
76 91
77 DISALLOW_COPY_AND_ASSIGN(MojoCdmService); 92 DISALLOW_COPY_AND_ASSIGN(MojoCdmService);
78 }; 93 };
79 94
80 } // namespace media 95 } // namespace media
81 96
82 #endif // MEDIA_MOJO_SERVICES_MOJO_CDM_SERVICE_H_ 97 #endif // MEDIA_MOJO_SERVICES_MOJO_CDM_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698