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

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

Issue 1977173002: Rename media::interfaces to media::mojom. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: android + chromeos files Created 4 years, 7 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
« no previous file with comments | « media/mojo/services/mojo_cdm_promise.cc ('k') | media/mojo/services/mojo_cdm_service.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory> 10 #include <memory>
11 11
12 #include "base/callback.h" 12 #include "base/callback.h"
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "base/memory/ref_counted.h" 14 #include "base/memory/ref_counted.h"
15 #include "base/memory/weak_ptr.h" 15 #include "base/memory/weak_ptr.h"
16 #include "media/base/media_keys.h" 16 #include "media/base/media_keys.h"
17 #include "media/mojo/interfaces/content_decryption_module.mojom.h" 17 #include "media/mojo/interfaces/content_decryption_module.mojom.h"
18 #include "media/mojo/services/mojo_cdm_promise.h" 18 #include "media/mojo/services/mojo_cdm_promise.h"
19 #include "media/mojo/services/mojo_cdm_service_context.h" 19 #include "media/mojo/services/mojo_cdm_service_context.h"
20 #include "media/mojo/services/mojo_decryptor_service.h" 20 #include "media/mojo/services/mojo_decryptor_service.h"
21 #include "mojo/public/cpp/bindings/strong_binding.h" 21 #include "mojo/public/cpp/bindings/strong_binding.h"
22 22
23 namespace media { 23 namespace media {
24 24
25 class CdmFactory; 25 class CdmFactory;
26 26
27 // A interfaces::ContentDecryptionModule implementation backed by a 27 // A mojom::ContentDecryptionModule implementation backed by a
28 // media::MediaKeys. 28 // media::MediaKeys.
29 class MojoCdmService : public interfaces::ContentDecryptionModule { 29 class MojoCdmService : public mojom::ContentDecryptionModule {
30 public: 30 public:
31 // Get the CDM associated with |cdm_id|, which is unique per process. 31 // Get the CDM associated with |cdm_id|, which is unique per process.
32 // Can be called on any thread. The returned CDM is not guaranteed to be 32 // Can be called on any thread. The returned CDM is not guaranteed to be
33 // thread safe. 33 // thread safe.
34 // Note: This provides a generic hack to get the CDM in the process where 34 // Note: This provides a generic hack to get the CDM in the process where
35 // MojoMediaApplication is running, regardless of which render process or 35 // MojoMediaApplication is running, regardless of which render process or
36 // render frame the caller is associated with. In the future, we should move 36 // render frame the caller is associated with. In the future, we should move
37 // all out-of-process media players into the MojoMediaApplicaiton so that we 37 // all out-of-process media players into the MojoMediaApplicaiton so that we
38 // can use MojoCdmServiceContext (per render frame) to get the CDM. 38 // can use MojoCdmServiceContext (per render frame) to get the CDM.
39 static scoped_refptr<MediaKeys> LegacyGetCdm(int cdm_id); 39 static scoped_refptr<MediaKeys> LegacyGetCdm(int cdm_id);
40 40
41 // Constructs a MojoCdmService and strongly binds it to the |request|. 41 // Constructs a MojoCdmService and strongly binds it to the |request|.
42 MojoCdmService( 42 MojoCdmService(
43 base::WeakPtr<MojoCdmServiceContext> context, 43 base::WeakPtr<MojoCdmServiceContext> context,
44 CdmFactory* cdm_factory, 44 CdmFactory* cdm_factory,
45 mojo::InterfaceRequest<interfaces::ContentDecryptionModule> request); 45 mojo::InterfaceRequest<mojom::ContentDecryptionModule> request);
46 46
47 ~MojoCdmService() final; 47 ~MojoCdmService() final;
48 48
49 // interfaces::ContentDecryptionModule implementation. 49 // mojom::ContentDecryptionModule implementation.
50 void SetClient(interfaces::ContentDecryptionModuleClientPtr client) final; 50 void SetClient(mojom::ContentDecryptionModuleClientPtr client) final;
51 void Initialize(const mojo::String& key_system, 51 void Initialize(const mojo::String& key_system,
52 const mojo::String& security_origin, 52 const mojo::String& security_origin,
53 interfaces::CdmConfigPtr cdm_config, 53 mojom::CdmConfigPtr cdm_config,
54 const InitializeCallback& callback) final; 54 const InitializeCallback& callback) final;
55 void SetServerCertificate( 55 void SetServerCertificate(
56 mojo::Array<uint8_t> certificate_data, 56 mojo::Array<uint8_t> certificate_data,
57 const mojo::Callback<void(interfaces::CdmPromiseResultPtr)>& callback) 57 const mojo::Callback<void(mojom::CdmPromiseResultPtr)>& callback) final;
58 final;
59 void CreateSessionAndGenerateRequest( 58 void CreateSessionAndGenerateRequest(
60 interfaces::ContentDecryptionModule::SessionType session_type, 59 mojom::ContentDecryptionModule::SessionType session_type,
61 interfaces::ContentDecryptionModule::InitDataType init_data_type, 60 mojom::ContentDecryptionModule::InitDataType init_data_type,
62 mojo::Array<uint8_t> init_data, 61 mojo::Array<uint8_t> init_data,
63 const mojo::Callback<void(interfaces::CdmPromiseResultPtr, mojo::String)>& 62 const mojo::Callback<void(mojom::CdmPromiseResultPtr, mojo::String)>&
64 callback) final; 63 callback) final;
65 void LoadSession( 64 void LoadSession(mojom::ContentDecryptionModule::SessionType session_type,
66 interfaces::ContentDecryptionModule::SessionType session_type, 65 const mojo::String& session_id,
67 const mojo::String& session_id, 66 const mojo::Callback<void(mojom::CdmPromiseResultPtr,
68 const mojo::Callback<void(interfaces::CdmPromiseResultPtr, mojo::String)>& 67 mojo::String)>& callback) final;
69 callback) final;
70 void UpdateSession( 68 void UpdateSession(
71 const mojo::String& session_id, 69 const mojo::String& session_id,
72 mojo::Array<uint8_t> response, 70 mojo::Array<uint8_t> response,
73 const mojo::Callback<void(interfaces::CdmPromiseResultPtr)>& callback) 71 const mojo::Callback<void(mojom::CdmPromiseResultPtr)>& callback) final;
74 final; 72 void CloseSession(
75 void CloseSession(const mojo::String& session_id, 73 const mojo::String& session_id,
76 const mojo::Callback<void(interfaces::CdmPromiseResultPtr)>& 74 const mojo::Callback<void(mojom::CdmPromiseResultPtr)>& callback) final;
77 callback) final;
78 void RemoveSession( 75 void RemoveSession(
79 const mojo::String& session_id, 76 const mojo::String& session_id,
80 const mojo::Callback<void(interfaces::CdmPromiseResultPtr)>& callback) 77 const mojo::Callback<void(mojom::CdmPromiseResultPtr)>& callback) final;
81 final;
82 78
83 // Get CDM to be used by the media pipeline. 79 // Get CDM to be used by the media pipeline.
84 scoped_refptr<MediaKeys> GetCdm(); 80 scoped_refptr<MediaKeys> GetCdm();
85 81
86 private: 82 private:
87 // Callback for CdmFactory::Create(). 83 // Callback for CdmFactory::Create().
88 void OnCdmCreated(const InitializeCallback& callback, 84 void OnCdmCreated(const InitializeCallback& callback,
89 const scoped_refptr<MediaKeys>& cdm, 85 const scoped_refptr<MediaKeys>& cdm,
90 const std::string& error_message); 86 const std::string& error_message);
91 87
(...skipping 14 matching lines...) Expand all
106 const std::string& error_message); 102 const std::string& error_message);
107 103
108 // Callback for when |decryptor_| loses connectivity. 104 // Callback for when |decryptor_| loses connectivity.
109 void OnDecryptorConnectionError(); 105 void OnDecryptorConnectionError();
110 106
111 // CDM ID to be assigned to the next successfully initialized CDM. This ID is 107 // CDM ID to be assigned to the next successfully initialized CDM. This ID is
112 // unique per process. It will be used to locate the CDM by the media players 108 // unique per process. It will be used to locate the CDM by the media players
113 // living in the same process. 109 // living in the same process.
114 static int next_cdm_id_; 110 static int next_cdm_id_;
115 111
116 mojo::StrongBinding<interfaces::ContentDecryptionModule> binding_; 112 mojo::StrongBinding<mojom::ContentDecryptionModule> binding_;
117 base::WeakPtr<MojoCdmServiceContext> context_; 113 base::WeakPtr<MojoCdmServiceContext> context_;
118 114
119 CdmFactory* cdm_factory_; 115 CdmFactory* cdm_factory_;
120 scoped_refptr<MediaKeys> cdm_; 116 scoped_refptr<MediaKeys> cdm_;
121 117
122 std::unique_ptr<MojoDecryptorService> decryptor_; 118 std::unique_ptr<MojoDecryptorService> decryptor_;
123 119
124 // Set to a valid CDM ID if the |cdm_| is successfully created. 120 // Set to a valid CDM ID if the |cdm_| is successfully created.
125 int cdm_id_; 121 int cdm_id_;
126 122
127 interfaces::ContentDecryptionModuleClientPtr client_; 123 mojom::ContentDecryptionModuleClientPtr client_;
128 124
129 base::WeakPtr<MojoCdmService> weak_this_; 125 base::WeakPtr<MojoCdmService> weak_this_;
130 base::WeakPtrFactory<MojoCdmService> weak_factory_; 126 base::WeakPtrFactory<MojoCdmService> weak_factory_;
131 127
132 DISALLOW_COPY_AND_ASSIGN(MojoCdmService); 128 DISALLOW_COPY_AND_ASSIGN(MojoCdmService);
133 }; 129 };
134 130
135 } // namespace media 131 } // namespace media
136 132
137 #endif // MEDIA_MOJO_SERVICES_MOJO_CDM_SERVICE_H_ 133 #endif // MEDIA_MOJO_SERVICES_MOJO_CDM_SERVICE_H_
OLDNEW
« no previous file with comments | « media/mojo/services/mojo_cdm_promise.cc ('k') | media/mojo/services/mojo_cdm_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698