OLD | NEW |
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_BLINK_WEBENCRYPTEDMEDIACLIENT_IMPL_H_ | 5 #ifndef MEDIA_BLINK_WEBENCRYPTEDMEDIACLIENT_IMPL_H_ |
6 #define MEDIA_BLINK_WEBENCRYPTEDMEDIACLIENT_IMPL_H_ | 6 #define MEDIA_BLINK_WEBENCRYPTEDMEDIACLIENT_IMPL_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
| 10 #include "base/callback.h" |
10 #include "base/containers/scoped_ptr_hash_map.h" | 11 #include "base/containers/scoped_ptr_hash_map.h" |
11 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
12 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
13 #include "media/base/media_export.h" | 14 #include "media/base/media_export.h" |
14 #include "media/blink/key_system_config_selector.h" | 15 #include "media/blink/key_system_config_selector.h" |
15 #include "third_party/WebKit/public/platform/WebEncryptedMediaClient.h" | 16 #include "third_party/WebKit/public/platform/WebEncryptedMediaClient.h" |
16 | 17 |
17 namespace blink { | 18 namespace blink { |
18 | 19 |
19 class WebContentDecryptionModuleResult; | 20 class WebContentDecryptionModuleResult; |
20 struct WebMediaKeySystemConfiguration; | 21 struct WebMediaKeySystemConfiguration; |
21 class WebSecurityOrigin; | 22 class WebSecurityOrigin; |
22 | 23 |
23 } // namespace blink | 24 } // namespace blink |
24 | 25 |
25 namespace media { | 26 namespace media { |
26 | 27 |
27 class CdmFactory; | 28 class CdmFactory; |
28 class KeySystems; | 29 class KeySystems; |
29 class MediaPermission; | 30 class MediaPermission; |
30 | 31 |
31 class MEDIA_EXPORT WebEncryptedMediaClientImpl | 32 class MEDIA_EXPORT WebEncryptedMediaClientImpl |
32 : public blink::WebEncryptedMediaClient { | 33 : public blink::WebEncryptedMediaClient { |
33 public: | 34 public: |
34 WebEncryptedMediaClientImpl(CdmFactory* cdm_factory, | 35 WebEncryptedMediaClientImpl( |
35 MediaPermission* media_permission); | 36 base::Callback<bool(void)> are_secure_codecs_supported_cb, |
| 37 CdmFactory* cdm_factory, |
| 38 MediaPermission* media_permission); |
36 virtual ~WebEncryptedMediaClientImpl(); | 39 virtual ~WebEncryptedMediaClientImpl(); |
37 | 40 |
38 // WebEncryptedMediaClient implementation. | 41 // WebEncryptedMediaClient implementation. |
39 virtual void requestMediaKeySystemAccess( | 42 virtual void requestMediaKeySystemAccess( |
40 blink::WebEncryptedMediaRequest request); | 43 blink::WebEncryptedMediaRequest request); |
41 | 44 |
42 // Create the CDM for |key_system| and |security_origin|. The caller owns | 45 // Create the CDM for |key_system| and |security_origin|. The caller owns |
43 // the created cdm (passed back using |result|). | 46 // the created cdm (passed back using |result|). |
44 void CreateCdm(const blink::WebString& key_system, | 47 void CreateCdm(const blink::WebString& key_system, |
45 bool allow_distinctive_identifier, | 48 bool allow_distinctive_identifier, |
46 bool allow_persistent_state, | 49 bool allow_persistent_state, |
47 const blink::WebSecurityOrigin& security_origin, | 50 const blink::WebSecurityOrigin& security_origin, |
48 blink::WebContentDecryptionModuleResult result); | 51 blink::WebContentDecryptionModuleResult result); |
49 | 52 |
50 private: | 53 private: |
51 // Report usage of key system to UMA. There are 2 different counts logged: | 54 // Report usage of key system to UMA. There are 2 different counts logged: |
52 // 1. The key system is requested. | 55 // 1. The key system is requested. |
53 // 2. The requested key system and options are supported. | 56 // 2. The requested key system and options are supported. |
54 // Each stat is only reported once per renderer frame per key system. | 57 // Each stat is only reported once per renderer frame per key system. |
55 class Reporter; | 58 class Reporter; |
56 | 59 |
57 // Complete a requestMediaKeySystemAccess() request with a supported | 60 // Complete a requestMediaKeySystemAccess() request with a supported |
58 // accumulated configuration. | 61 // accumulated configuration. |
59 void OnRequestSucceeded( | 62 void OnRequestSucceeded( |
60 blink::WebEncryptedMediaRequest request, | 63 blink::WebEncryptedMediaRequest request, |
61 const blink::WebMediaKeySystemConfiguration& accumulated_configuration); | 64 const blink::WebMediaKeySystemConfiguration& accumulated_configuration, |
| 65 bool are_secure_codecs_required); |
62 | 66 |
63 // Complete a requestMediaKeySystemAccess() request with an error message. | 67 // Complete a requestMediaKeySystemAccess() request with an error message. |
64 void OnRequestNotSupported(blink::WebEncryptedMediaRequest request, | 68 void OnRequestNotSupported(blink::WebEncryptedMediaRequest request, |
65 const blink::WebString& error_message); | 69 const blink::WebString& error_message); |
66 | 70 |
67 // Gets the Reporter for |key_system|. If it doesn't already exist, | 71 // Gets the Reporter for |key_system|. If it doesn't already exist, |
68 // create one. | 72 // create one. |
69 Reporter* GetReporter(const blink::WebString& key_system); | 73 Reporter* GetReporter(const blink::WebString& key_system); |
70 | 74 |
71 // Reporter singletons. | 75 // Reporter singletons. |
72 base::ScopedPtrHashMap<std::string, scoped_ptr<Reporter>> reporters_; | 76 base::ScopedPtrHashMap<std::string, scoped_ptr<Reporter>> reporters_; |
73 | 77 |
| 78 base::Callback<bool(void)> are_secure_codecs_supported_cb_; |
74 CdmFactory* cdm_factory_; | 79 CdmFactory* cdm_factory_; |
75 KeySystemConfigSelector key_system_config_selector_; | 80 KeySystemConfigSelector key_system_config_selector_; |
76 base::WeakPtrFactory<WebEncryptedMediaClientImpl> weak_factory_; | 81 base::WeakPtrFactory<WebEncryptedMediaClientImpl> weak_factory_; |
77 }; | 82 }; |
78 | 83 |
79 } // namespace media | 84 } // namespace media |
80 | 85 |
81 #endif // MEDIA_BLINK_WEBENCRYPTEDMEDIACLIENT_IMPL_H_ | 86 #endif // MEDIA_BLINK_WEBENCRYPTEDMEDIACLIENT_IMPL_H_ |
OLD | NEW |