Re-subimission of https://codereview.chromium.org/1041213003/
[chromium-blink-merge.git] / media / base / eme_constants.h
blob8bb3883adc27738453bafb67cae0594c8b4fd069
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
3 // found in the LICENSE file.
5 #ifndef MEDIA_BASE_EME_CONSTANTS_H_
6 #define MEDIA_BASE_EME_CONSTANTS_H_
8 #include <stdint.h>
10 namespace media {
12 // Defines values that specify registered Initialization Data Types used
13 // in Encrypted Media Extensions (EME).
14 // http://w3c.github.io/encrypted-media/initdata-format-registry.html#registry
15 // The mask values are stored in a InitDataTypeMask.
16 enum class EmeInitDataType {
17 UNKNOWN,
18 WEBM,
19 CENC,
20 KEYIDS
23 typedef uint32_t InitDataTypeMask;
24 const InitDataTypeMask kInitDataTypeMaskNone = 0;
25 const InitDataTypeMask kInitDataTypeMaskWebM = 1 << 0;
26 const InitDataTypeMask kInitDataTypeMaskCenc = 1 << 1;
27 const InitDataTypeMask kInitDataTypeMaskKeyIds = 1 << 2;
29 // Defines bitmask values that specify codecs used in Encrypted Media Extension
30 // (EME). Each value represents a codec within a specific container.
31 // The mask values are stored in a SupportedCodecs.
32 enum EmeCodec {
33 // *_ALL values should only be used for masking, do not use them to specify
34 // codec support because they may be extended to include more codecs.
35 EME_CODEC_NONE = 0,
36 EME_CODEC_WEBM_OPUS = 1 << 0,
37 EME_CODEC_WEBM_VORBIS = 1 << 1,
38 EME_CODEC_WEBM_AUDIO_ALL = EME_CODEC_WEBM_OPUS | EME_CODEC_WEBM_VORBIS,
39 EME_CODEC_WEBM_VP8 = 1 << 2,
40 EME_CODEC_WEBM_VP9 = 1 << 3,
41 EME_CODEC_WEBM_VIDEO_ALL = (EME_CODEC_WEBM_VP8 | EME_CODEC_WEBM_VP9),
42 EME_CODEC_WEBM_ALL = (EME_CODEC_WEBM_AUDIO_ALL | EME_CODEC_WEBM_VIDEO_ALL),
43 #if defined(USE_PROPRIETARY_CODECS)
44 EME_CODEC_MP4_AAC = 1 << 4,
45 EME_CODEC_MP4_AUDIO_ALL = EME_CODEC_MP4_AAC,
46 EME_CODEC_MP4_AVC1 = 1 << 5,
47 EME_CODEC_MP4_VIDEO_ALL = EME_CODEC_MP4_AVC1,
48 EME_CODEC_MP4_ALL = (EME_CODEC_MP4_AUDIO_ALL | EME_CODEC_MP4_VIDEO_ALL),
49 EME_CODEC_AUDIO_ALL = (EME_CODEC_WEBM_AUDIO_ALL | EME_CODEC_MP4_AUDIO_ALL),
50 EME_CODEC_VIDEO_ALL = (EME_CODEC_WEBM_VIDEO_ALL | EME_CODEC_MP4_VIDEO_ALL),
51 EME_CODEC_ALL = (EME_CODEC_WEBM_ALL | EME_CODEC_MP4_ALL),
52 #else
53 EME_CODEC_AUDIO_ALL = EME_CODEC_WEBM_AUDIO_ALL,
54 EME_CODEC_VIDEO_ALL = EME_CODEC_WEBM_VIDEO_ALL,
55 EME_CODEC_ALL = EME_CODEC_WEBM_ALL,
56 #endif // defined(USE_PROPRIETARY_CODECS)
59 typedef uint32_t SupportedCodecs;
61 enum EmeSessionTypeSupport {
62 // Invalid default value.
63 EME_SESSION_TYPE_INVALID,
64 // The session type is not supported.
65 EME_SESSION_TYPE_NOT_SUPPORTED,
66 // The session type is supported if a distinctive identifier is available.
67 EME_SESSION_TYPE_SUPPORTED_WITH_IDENTIFIER,
68 // The session type is always supported.
69 EME_SESSION_TYPE_SUPPORTED,
72 // Used to declare support for distinctive identifier and persistent state.
73 // These are purposefully limited to not allow one to require the other, so that
74 // transitive requirements are not possible. Non-trivial refactoring would be
75 // required to support transitive requirements.
76 enum EmeFeatureSupport {
77 // Invalid default value.
78 EME_FEATURE_INVALID,
79 // Access to the feature is not supported at all.
80 EME_FEATURE_NOT_SUPPORTED,
81 // Access to the feature may be requested.
82 EME_FEATURE_REQUESTABLE,
83 // Access to the feature cannot be blocked.
84 EME_FEATURE_ALWAYS_ENABLED,
87 // Used to query support for distinctive identifier and persistent state.
88 enum EmeFeatureRequirement {
89 EME_FEATURE_NOT_ALLOWED,
90 EME_FEATURE_OPTIONAL,
91 EME_FEATURE_REQUIRED,
94 enum class EmeMediaType {
95 AUDIO,
96 VIDEO,
99 // Robustness values understood by KeySystems.
100 // Note: key_systems.cc expects this ordering in GetRobustnessConfigRule(),
101 // make sure to correct that code if this list changes.
102 enum class EmeRobustness {
103 INVALID,
104 EMPTY,
105 SW_SECURE_CRYPTO,
106 SW_SECURE_DECODE,
107 HW_SECURE_CRYPTO,
108 HW_SECURE_DECODE,
109 HW_SECURE_ALL,
112 // Configuration rules indicate the configuration state required to support a
113 // configuration option (note: a configuration option may be disallowing a
114 // feature). Configuration rules are used to answer queries about distinctive
115 // identifier, persistent state, and robustness requirements, as well as to
116 // describe support for different session types.
118 // If in the future there are reasons to request user permission other than
119 // access to a distinctive identifier, then additional rules should be added.
120 // Rules are implemented in ConfigState and are otherwise opaque.
121 enum class EmeConfigRule {
122 // The configuration option is not supported.
123 NOT_SUPPORTED,
124 // The configuration option prevents use of a distinctive identifier.
125 IDENTIFIER_NOT_ALLOWED,
126 // The configuration option is supported if a distinctive identifier is
127 // available.
128 IDENTIFIER_REQUIRED,
129 // The configuration option is supported, but the user experience may be
130 // improved if a distinctive identifier is available.
131 IDENTIFIER_RECOMMENDED,
132 // The configuration option prevents use of persistent state.
133 PERSISTENCE_NOT_ALLOWED,
134 // The configuration option is supported if persistent state is available.
135 PERSISTENCE_REQUIRED,
136 // The configuration option is supported if both a distinctive identifier and
137 // persistent state are available.
138 IDENTIFIER_AND_PERSISTENCE_REQUIRED,
139 // The configuration option is supported without conditions.
140 SUPPORTED,
143 } // namespace media
145 #endif // MEDIA_BASE_EME_CONSTANTS_H_