Restrict use of hardware-secure codecs based on the RendererPreference.
[chromium-blink-merge.git] / media / blink / key_system_config_selector.h
blob0d84fe3b17683701d33d2d4eb3c0caa198122cf4
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef MEDIA_BLINK_KEY_SYSTEM_CONFIG_SELECTOR_H_
6 #define MEDIA_BLINK_KEY_SYSTEM_CONFIG_SELECTOR_H_
8 #include <string>
9 #include <vector>
11 #include "base/bind.h"
12 #include "base/callback.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "base/memory/weak_ptr.h"
15 #include "media/base/eme_constants.h"
16 #include "media/base/media_export.h"
17 #include "third_party/WebKit/public/platform/WebVector.h"
19 namespace blink {
21 struct WebMediaKeySystemConfiguration;
22 struct WebMediaKeySystemMediaCapability;
23 class WebSecurityOrigin;
24 class WebString;
26 } // namespace blink
28 namespace media {
30 class KeySystems;
31 class MediaPermission;
33 class MEDIA_EXPORT KeySystemConfigSelector {
34 public:
35 KeySystemConfigSelector(
36 const KeySystems* key_systems,
37 MediaPermission* media_permission);
39 ~KeySystemConfigSelector();
41 void SelectConfig(
42 const blink::WebString& key_system,
43 const blink::WebVector<blink::WebMediaKeySystemConfiguration>&
44 candidate_configurations,
45 const blink::WebSecurityOrigin& security_origin,
46 bool are_secure_codecs_supported,
47 // The second argument is |are_secure_codecs_required|.
48 base::Callback<void(const blink::WebMediaKeySystemConfiguration&,
49 bool)> succeeded_cb,
50 base::Callback<void(const blink::WebString&)> not_supported_cb);
52 private:
53 struct SelectionRequest;
54 class ConfigState;
56 enum ConfigurationSupport {
57 CONFIGURATION_NOT_SUPPORTED,
58 CONFIGURATION_REQUIRES_PERMISSION,
59 CONFIGURATION_SUPPORTED,
62 void SelectConfigInternal(scoped_ptr<SelectionRequest> request);
64 void OnPermissionResult(scoped_ptr<SelectionRequest> request,
65 bool is_permission_granted);
67 ConfigurationSupport GetSupportedConfiguration(
68 const std::string& key_system,
69 const blink::WebMediaKeySystemConfiguration& candidate,
70 ConfigState* config_state,
71 blink::WebMediaKeySystemConfiguration* accumulated_configuration);
73 bool GetSupportedCapabilities(
74 const std::string& key_system,
75 EmeMediaType media_type,
76 const blink::WebVector<blink::WebMediaKeySystemMediaCapability>&
77 requested_media_capabilities,
78 ConfigState* config_state,
79 std::vector<blink::WebMediaKeySystemMediaCapability>*
80 supported_media_capabilities);
82 bool IsSupportedContentType(const std::string& key_system,
83 EmeMediaType media_type,
84 const std::string& container_mime_type,
85 const std::string& codecs,
86 ConfigState* config_state);
88 const KeySystems* key_systems_;
89 MediaPermission* media_permission_;
90 base::WeakPtrFactory<KeySystemConfigSelector> weak_factory_;
92 DISALLOW_COPY_AND_ASSIGN(KeySystemConfigSelector);
95 } // namespace media
97 #endif // MEDIA_BLINK_KEY_SYSTEM_CONFIG_SELECTOR_H_