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