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.
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.
32 // Transport layer of media::CdmPromise (see media/base/cdm_promise.h).
33 // - When |success| is true, the promise is resolved and all other fields should
35 // - When |success| is false, the promise is rejected with |exception|,
36 // |system_code| and |error_message|.
37 struct CdmPromiseResult {
39 CdmException exception;
44 // Transport layer of media::CdmKeyInformation (see
45 // media/base/cdm_key_information.h). It is used to specify a key_id and it's
47 struct CdmKeyInformation {
53 // See media::MediaKeys::MessageType
60 // An interface that represents a CDM in the Encrypted Media Extensions (EME)
61 // spec (https://w3c.github.io/encrypted-media/). See media/base/media_keys.h.
62 interface ContentDecryptionModule {
63 // See media::MediaKeys::SessionType.
66 PERSISTENT_LICENSE_SESSION,
67 PERSISTENT_RELEASE_MESSAGE_SESSION
70 // See media::EmeInitDataType.
78 // Sets ContentDecryptionModuleClient. Must be called before any other calls.
79 SetClient(ContentDecryptionModuleClient client);
81 // Provides a server certificate to be used to encrypt messages to the
83 SetServerCertificate(array<uint8> certificate_data)
84 => (CdmPromiseResult result);
86 // Creates a session with the |init_data_type|, |init_data| and |session_type|
87 // provided. If |result.success| is false, the output |session_id| will be
89 CreateSessionAndGenerateRequest(SessionType session_type,
90 InitDataType init_data_type,
91 array<uint8> init_data)
92 => (CdmPromiseResult result, string? session_id);
94 // Loads the session associated with |session_id| and |session_type|.
95 // Combinations of |result.success| and |session_id| means:
96 // (true, non-null) : Session successfully loaded.
97 // (true, null) : Session not found.
98 // (false, non-null): N/A; this combination is not allowed.
99 // (false, null) : Unexpected error. See other fields in |result|.
100 LoadSession(SessionType session_type, string session_id)
101 => (CdmPromiseResult result, string? session_id);
103 // Updates a session specified by |session_id| with |response|.
104 UpdateSession(string session_id, array<uint8> response)
105 => (CdmPromiseResult result);
107 // Closes the session specified by |session_id|.
108 CloseSession(string session_id) => (CdmPromiseResult result);
110 // Removes stored session data associated with the active session specified by
112 RemoveSession(string session_id) => (CdmPromiseResult result);
114 // Assigns the |cdm_id| to the CDM, and retrieves the |decryptor| associated
115 // with this CDM instance.
116 // A CDM implementation must choose to support either an explicit or implicit
118 // - Explicit (non-null) decryptor: The client (e.g. media pipeline) will use
119 // the |decryptor| directly to decrypt (and decode) encrypted buffers.
120 // - Implicit (null) decryptor: The client (e.g. media pipeline) will use the
121 // |cdm_id| to locate a decryptor and associate it with the client.
122 // Note: In Chromium GetCdmContext() is a sync call. But we don't have an easy
123 // way to support sync calls on a mojo interface. Instead the client should
124 // generate a client side ID and pass it to the service.
125 GetCdmContext(int32 cdm_id, Decryptor&? decryptor);
128 // Session callbacks. See media/base/media_keys.h for details.
129 interface ContentDecryptionModuleClient {
130 OnSessionMessage(string session_id, CdmMessageType message_type,
131 array<uint8> message, string legacy_destination_url);
133 OnSessionClosed(string session_id);
135 OnLegacySessionError(string session_id, CdmException exception,
136 uint32 system_code, string error_message);
138 OnSessionKeysChange(string session_id, bool has_additional_usable_key,
139 array<CdmKeyInformation> key_information);
141 // Provide session expiration update for |session_id|.
142 // |new_expiry_time_sec| is the number of seconds since epoch (Jan 1, 1970).
143 OnSessionExpirationUpdate(string session_id, double new_expiry_time_sec);