Unregister from GCM when the only GCM app is removed
[chromium-blink-merge.git] / media / base / key_systems.h
blobd761abf2c66a3cc1391754588b1a71bfce2b43cc
1 // Copyright 2013 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_BASE_KEY_SYSTEMS_H_
6 #define MEDIA_BASE_KEY_SYSTEMS_H_
8 #include <string>
9 #include <vector>
11 #include "base/memory/scoped_ptr.h"
12 #include "media/base/media_export.h"
14 namespace media {
16 // Prefixed EME API only supports prefixed (webkit-) key system name for
17 // certain key systems. But internally only unprefixed key systems are
18 // supported. The following two functions help convert between prefixed and
19 // unprefixed key system names.
21 // Gets the unprefixed key system name for |key_system|.
22 MEDIA_EXPORT std::string GetUnprefixedKeySystemName(
23 const std::string& key_system);
25 // Gets the prefixed key system name for |key_system|.
26 MEDIA_EXPORT std::string GetPrefixedKeySystemName(
27 const std::string& key_system);
29 // Returns false if a container-specific |init_data_type| is specified with an
30 // inappropriate container.
31 // TODO(sandersd): Remove this essentially internal detail if the spec is
32 // updated to not convolve the two in a single method call.
33 // TODO(sandersd): Use enum values instead of strings. http://crbug.com/417440
34 MEDIA_EXPORT bool IsSaneInitDataTypeWithContainer(
35 const std::string& init_data_type,
36 const std::string& container);
38 // Note: Shouldn't be used for prefixed API as the original
39 // IsSupportedKeySystemWithMediaMimeType() path reports UMAs, but this path does
40 // not.
41 MEDIA_EXPORT bool IsSupportedKeySystem(const std::string& key_system);
43 MEDIA_EXPORT bool IsSupportedKeySystemWithInitDataType(
44 const std::string& key_system,
45 const std::string& init_data_type);
47 // Returns whether |key_system| is a real supported key system that can be
48 // instantiated.
49 // Abstract parent |key_system| strings will return false.
50 // Call IsSupportedKeySystemWithMediaMimeType() to determine whether a
51 // |key_system| supports a specific type of media or to check parent key
52 // systems.
53 MEDIA_EXPORT bool IsConcreteSupportedKeySystem(const std::string& key_system);
55 // Returns whether |key_system| supports the specified media type and codec(s).
56 MEDIA_EXPORT bool IsSupportedKeySystemWithMediaMimeType(
57 const std::string& mime_type,
58 const std::vector<std::string>& codecs,
59 const std::string& key_system);
61 // Returns whether |key_system| supports the specified media type and codec(s).
62 // To be used with prefixed EME only as it generates UMAs based on the query.
63 MEDIA_EXPORT bool PrefixedIsSupportedKeySystemWithMediaMimeType(
64 const std::string& mime_type,
65 const std::vector<std::string>& codecs,
66 const std::string& key_system);
68 // Returns a name for |key_system| suitable to UMA logging.
69 MEDIA_EXPORT std::string GetKeySystemNameForUMA(const std::string& key_system);
71 // Returns whether AesDecryptor can be used for the given |concrete_key_system|.
72 MEDIA_EXPORT bool CanUseAesDecryptor(const std::string& concrete_key_system);
74 #if defined(ENABLE_PEPPER_CDMS)
75 // Returns the Pepper MIME type for |concrete_key_system|.
76 // Returns empty string if |concrete_key_system| is unknown or not Pepper-based.
77 MEDIA_EXPORT std::string GetPepperType(
78 const std::string& concrete_key_system);
79 #endif
81 #if defined(UNIT_TEST)
82 // Helper functions to add container/codec types for testing purposes.
83 MEDIA_EXPORT void AddContainerMask(const std::string& container, uint32 mask);
84 MEDIA_EXPORT void AddCodecMask(const std::string& codec, uint32 mask);
85 #endif // defined(UNIT_TEST)
87 } // namespace media
89 #endif // MEDIA_BASE_KEY_SYSTEMS_H_