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 module media.interfaces;
7 import "media/mojo/interfaces/decryptor.mojom";
9 // Transport layer of media::MediaKeys::Exception (see media/base/media_keys.h).
10 // This is used for ContentDecryptionModule (CDM) promise rejections.
11 // Note: This can also be used for session errors in prefixed API.
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.
34 // Transport layer of media::CdmConfig (see media/base/cdm_config.h).
36 bool allow_distinctive_identifier;
37 bool allow_persistent_state;
38 bool use_hw_secure_codecs;
41 // Transport layer of media::CdmPromise (see media/base/cdm_promise.h).
42 // - When |success| is true, the promise is resolved and all other fields should
44 // - When |success| is false, the promise is rejected with |exception|,
45 // |system_code| and |error_message|.
46 struct CdmPromiseResult {
48 CdmException exception;
50 string? error_message;
53 // Transport layer of media::CdmKeyInformation (see
54 // media/base/cdm_key_information.h). It is used to specify a key_id and it's
56 struct CdmKeyInformation {
62 // See media::MediaKeys::MessageType
69 // An interface that represents a CDM in the Encrypted Media Extensions (EME)
70 // spec (https://w3c.github.io/encrypted-media/). See media/base/media_keys.h.
71 interface ContentDecryptionModule {
72 // See media::MediaKeys::SessionType.
75 PERSISTENT_LICENSE_SESSION,
76 PERSISTENT_RELEASE_MESSAGE_SESSION
79 // See media::EmeInitDataType.
87 // Sets ContentDecryptionModuleClient. Must be called before any other calls.
88 SetClient(ContentDecryptionModuleClient client);
90 // Initializes the CDM. |cdm_id| will later be used to locate the CDM at the
91 // remote side. If initialization failed (e.g. |key_system| or |cdm_config| is
92 // not supported), |result.success| will be false.
93 Initialize(string key_system, string security_origin, CdmConfig cdm_config,
94 int32 cdm_id) => (CdmPromiseResult result);
96 // Provides a server certificate to be used to encrypt messages to the
98 SetServerCertificate(array<uint8> certificate_data)
99 => (CdmPromiseResult result);
101 // Creates a session with the |init_data_type|, |init_data| and |session_type|
102 // provided. If |result.success| is false, the output |session_id| will be
104 CreateSessionAndGenerateRequest(SessionType session_type,
105 InitDataType init_data_type,
106 array<uint8> init_data)
107 => (CdmPromiseResult result, string? session_id);
109 // Loads the session associated with |session_id| and |session_type|.
110 // Combinations of |result.success| and |session_id| means:
111 // (true, non-null) : Session successfully loaded.
112 // (true, null) : Session not found.
113 // (false, non-null): N/A; this combination is not allowed.
114 // (false, null) : Unexpected error. See other fields in |result|.
115 LoadSession(SessionType session_type, string session_id)
116 => (CdmPromiseResult result, string? session_id);
118 // Updates a session specified by |session_id| with |response|.
119 UpdateSession(string session_id, array<uint8> response)
120 => (CdmPromiseResult result);
122 // Closes the session specified by |session_id|.
123 CloseSession(string session_id) => (CdmPromiseResult result);
125 // Removes stored session data associated with the active session specified by
127 RemoveSession(string session_id) => (CdmPromiseResult result);
129 // Retrieves the |decryptor| associated with this CDM instance.
130 GetDecryptor(Decryptor&? decryptor);
133 // Session callbacks. See media/base/media_keys.h for details.
134 interface ContentDecryptionModuleClient {
135 OnSessionMessage(string session_id, CdmMessageType message_type,
136 array<uint8> message, string legacy_destination_url);
138 OnSessionClosed(string session_id);
140 OnLegacySessionError(string session_id, CdmException exception,
141 uint32 system_code, string error_message);
143 OnSessionKeysChange(string session_id, bool has_additional_usable_key,
144 array<CdmKeyInformation> key_information);
146 // Provide session expiration update for |session_id|.
147 // |new_expiry_time_sec| is the number of seconds since epoch (Jan 1, 1970).
148 OnSessionExpirationUpdate(string session_id, double new_expiry_time_sec);