| 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 module media.mojom; | 5 module media.mojom; |
| 6 | 6 |
| 7 import "media/mojo/interfaces/decryptor.mojom"; | 7 import "media/mojo/interfaces/decryptor.mojom"; |
| 8 import "url/mojo/url.mojom"; | 8 import "url/mojo/url.mojom"; |
| 9 | 9 |
| 10 // Transport layer of media::MediaKeys::Exception (see media/base/media_keys.h). | 10 // See media::EmeInitDataType. |
| 11 // This is used for ContentDecryptionModule (CDM) promise rejections. | 11 [Native] |
| 12 enum CdmException { | 12 enum EmeInitDataType; |
| 13 NOT_SUPPORTED_ERROR, | |
| 14 INVALID_STATE_ERROR, | |
| 15 INVALID_ACCESS_ERROR, | |
| 16 QUOTA_EXCEEDED_ERROR, | |
| 17 UNKNOWN_ERROR, | |
| 18 CLIENT_ERROR, | |
| 19 OUTPUT_ERROR | |
| 20 }; | |
| 21 | |
| 22 // Transport layer of media::CdmKeyInformation::KeyStatus (see | |
| 23 // media/base/cdm_key_information.h). This is used for indicating the status | |
| 24 // of a specific key ID. | |
| 25 enum CdmKeyStatus { | |
| 26 USABLE, | |
| 27 INTERNAL_ERROR, | |
| 28 EXPIRED, | |
| 29 OUTPUT_RESTRICTED, | |
| 30 OUTPUT_DOWNSCALED, | |
| 31 KEY_STATUS_PENDING, | |
| 32 RELEASED | |
| 33 }; | |
| 34 | 13 |
| 35 // Transport layer of media::CdmConfig (see media/base/cdm_config.h). | 14 // Transport layer of media::CdmConfig (see media/base/cdm_config.h). |
| 36 struct CdmConfig { | 15 struct CdmConfig { |
| 37 bool allow_distinctive_identifier; | 16 bool allow_distinctive_identifier; |
| 38 bool allow_persistent_state; | 17 bool allow_persistent_state; |
| 39 bool use_hw_secure_codecs; | 18 bool use_hw_secure_codecs; |
| 40 }; | 19 }; |
| 41 | 20 |
| 42 // Transport layer of media::CdmPromise (see media/base/cdm_promise.h). | 21 // Transport layer of media::CdmPromise (see media/base/cdm_promise.h). |
| 43 // - When |success| is true, the promise is resolved and all other fields should | 22 // - When |success| is true, the promise is resolved and all other fields should |
| 44 // be ignored. | 23 // be ignored. |
| 45 // - When |success| is false, the promise is rejected with |exception|, | 24 // - When |success| is false, the promise is rejected with |exception|, |
| 46 // |system_code| and |error_message|. | 25 // |system_code| and |error_message|. |
| 47 struct CdmPromiseResult { | 26 struct CdmPromiseResult { |
| 27 // See media::MediaKeys::Exception |
| 28 [Native] |
| 29 enum Exception; |
| 30 |
| 48 bool success; | 31 bool success; |
| 49 CdmException exception; | 32 Exception exception; |
| 50 uint32 system_code; | 33 uint32 system_code; |
| 51 string error_message; | 34 string error_message; |
| 52 }; | 35 }; |
| 53 | 36 |
| 54 // Transport layer of media::CdmKeyInformation (see | 37 // Transport layer of media::CdmKeyInformation (see |
| 55 // media/base/cdm_key_information.h). It is used to specify a key_id and it's | 38 // media/base/cdm_key_information.h). It is used to specify a key_id and it's |
| 56 // associated status. | 39 // associated status. |
| 57 struct CdmKeyInformation { | 40 struct CdmKeyInformation { |
| 41 [Native] |
| 42 enum KeyStatus; |
| 43 |
| 58 array<uint8> key_id; | 44 array<uint8> key_id; |
| 59 CdmKeyStatus status; | 45 KeyStatus status; |
| 60 uint32 system_code; | 46 uint32 system_code; |
| 61 }; | 47 }; |
| 62 | 48 |
| 63 // See media::MediaKeys::MessageType | |
| 64 enum CdmMessageType { | |
| 65 LICENSE_REQUEST, | |
| 66 LICENSE_RENEWAL, | |
| 67 LICENSE_RELEASE | |
| 68 }; | |
| 69 | |
| 70 // An interface that represents a CDM in the Encrypted Media Extensions (EME) | 49 // An interface that represents a CDM in the Encrypted Media Extensions (EME) |
| 71 // spec (https://w3c.github.io/encrypted-media/). See media/base/media_keys.h. | 50 // spec (https://w3c.github.io/encrypted-media/). See media/base/media_keys.h. |
| 72 interface ContentDecryptionModule { | 51 interface ContentDecryptionModule { |
| 73 // See media::MediaKeys::SessionType. | 52 // See media::MediaKeys::SessionType |
| 74 enum SessionType { | 53 [Native] |
| 75 TEMPORARY_SESSION, | 54 enum SessionType; |
| 76 PERSISTENT_LICENSE_SESSION, | |
| 77 PERSISTENT_RELEASE_MESSAGE_SESSION | |
| 78 }; | |
| 79 | |
| 80 // See media::EmeInitDataType. | |
| 81 enum InitDataType { | |
| 82 UNKNOWN, | |
| 83 WEBM, | |
| 84 CENC, | |
| 85 KEYIDS | |
| 86 }; | |
| 87 | 55 |
| 88 // Sets ContentDecryptionModuleClient. Must be called before any other calls. | 56 // Sets ContentDecryptionModuleClient. Must be called before any other calls. |
| 89 SetClient(ContentDecryptionModuleClient client); | 57 SetClient(ContentDecryptionModuleClient client); |
| 90 | 58 |
| 91 // Initializes the CDM. If initialization failed (e.g. |key_system| or | 59 // Initializes the CDM. If initialization failed (e.g. |key_system| or |
| 92 // |cdm_config| is not supported), |result.success| will be false and |cdm_id| | 60 // |cdm_config| is not supported), |result.success| will be false and |cdm_id| |
| 93 // will be zero. Upon success, |cdm_id| will be non-zero and will later be | 61 // will be zero. Upon success, |cdm_id| will be non-zero and will later be |
| 94 // used to locate the CDM at the remote side. |decryptor| is the remote | 62 // used to locate the CDM at the remote side. |decryptor| is the remote |
| 95 // Decryptor. | 63 // Decryptor. |
| 96 Initialize(string key_system, string security_origin, CdmConfig cdm_config) | 64 Initialize(string key_system, string security_origin, CdmConfig cdm_config) |
| 97 => (CdmPromiseResult result, int32 cdm_id, Decryptor? decryptor); | 65 => (CdmPromiseResult result, int32 cdm_id, Decryptor? decryptor); |
| 98 | 66 |
| 99 // Provides a server certificate to be used to encrypt messages to the | 67 // Provides a server certificate to be used to encrypt messages to the |
| 100 // license server. | 68 // license server. |
| 101 SetServerCertificate(array<uint8> certificate_data) | 69 SetServerCertificate(array<uint8> certificate_data) |
| 102 => (CdmPromiseResult result); | 70 => (CdmPromiseResult result); |
| 103 | 71 |
| 104 // Creates a session with the |init_data_type|, |init_data| and |session_type| | 72 // Creates a session with the |init_data_type|, |init_data| and |session_type| |
| 105 // provided. If |result.success| is false, the output |session_id| will be | 73 // provided. If |result.success| is false, the output |session_id| will be |
| 106 // empty. | 74 // empty. |
| 107 CreateSessionAndGenerateRequest(SessionType session_type, | 75 CreateSessionAndGenerateRequest(SessionType session_type, |
| 108 InitDataType init_data_type, | 76 EmeInitDataType init_data_type, |
| 109 array<uint8> init_data) | 77 array<uint8> init_data) |
| 110 => (CdmPromiseResult result, string session_id); | 78 => (CdmPromiseResult result, string session_id); |
| 111 | 79 |
| 112 // Loads the session associated with |session_id| and |session_type|. | 80 // Loads the session associated with |session_id| and |session_type|. |
| 113 // Combinations of |result.success| and |session_id| means: | 81 // Combinations of |result.success| and |session_id| means: |
| 114 // (true, non-empty) : Session successfully loaded. | 82 // (true, non-empty) : Session successfully loaded. |
| 115 // (true, empty) : Session not found. | 83 // (true, empty) : Session not found. |
| 116 // (false, non-empty): N/A; this combination is not allowed. | 84 // (false, non-empty): N/A; this combination is not allowed. |
| 117 // (false, empty) : Unexpected error. See other fields in |result|. | 85 // (false, empty) : Unexpected error. See other fields in |result|. |
| 118 LoadSession(SessionType session_type, string session_id) | 86 LoadSession(SessionType session_type, string session_id) |
| 119 => (CdmPromiseResult result, string session_id); | 87 => (CdmPromiseResult result, string session_id); |
| 120 | 88 |
| 121 // Updates a session specified by |session_id| with |response|. | 89 // Updates a session specified by |session_id| with |response|. |
| 122 UpdateSession(string session_id, array<uint8> response) | 90 UpdateSession(string session_id, array<uint8> response) |
| 123 => (CdmPromiseResult result); | 91 => (CdmPromiseResult result); |
| 124 | 92 |
| 125 // Closes the session specified by |session_id|. | 93 // Closes the session specified by |session_id|. |
| 126 CloseSession(string session_id) => (CdmPromiseResult result); | 94 CloseSession(string session_id) => (CdmPromiseResult result); |
| 127 | 95 |
| 128 // Removes stored session data associated with the active session specified by | 96 // Removes stored session data associated with the active session specified by |
| 129 // |session_id|. | 97 // |session_id|. |
| 130 RemoveSession(string session_id) => (CdmPromiseResult result); | 98 RemoveSession(string session_id) => (CdmPromiseResult result); |
| 131 }; | 99 }; |
| 132 | 100 |
| 133 // Session callbacks. See media/base/media_keys.h for details. | 101 // Session callbacks. See media/base/media_keys.h for details. |
| 134 interface ContentDecryptionModuleClient { | 102 interface ContentDecryptionModuleClient { |
| 135 OnSessionMessage(string session_id, CdmMessageType message_type, | 103 // See media::MediaKeys::MessageType |
| 104 [Native] |
| 105 enum MessageType; |
| 106 |
| 107 OnSessionMessage(string session_id, MessageType message_type, |
| 136 array<uint8> message); | 108 array<uint8> message); |
| 137 | 109 |
| 138 OnSessionClosed(string session_id); | 110 OnSessionClosed(string session_id); |
| 139 | 111 |
| 140 OnSessionKeysChange(string session_id, bool has_additional_usable_key, | 112 OnSessionKeysChange(string session_id, bool has_additional_usable_key, |
| 141 array<CdmKeyInformation> keys_info); | 113 array<CdmKeyInformation> keys_info); |
| 142 | 114 |
| 143 // Provide session expiration update for |session_id|. | 115 // Provide session expiration update for |session_id|. |
| 144 // |new_expiry_time_sec| is the number of seconds since epoch (Jan 1, 1970). | 116 // |new_expiry_time_sec| is the number of seconds since epoch (Jan 1, 1970). |
| 145 OnSessionExpirationUpdate(string session_id, double new_expiry_time_sec); | 117 OnSessionExpirationUpdate(string session_id, double new_expiry_time_sec); |
| 146 }; | 118 }; |
| OLD | NEW |