summaryrefslogtreecommitdiff
path: root/chromium/media/mojo/interfaces/content_decryption_module.mojom
blob: 3e217641ab2c7e0efd21914f131fad1ac7077658 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

module mojo;

import "media/mojo/interfaces/decryptor.mojom";

// Transport layer of media::MediaKeys::Exception (see media/base/media_keys.h).
// This is used for ContentDecryptionModule (CDM) promise rejections.
// Note: This can also be used for session errors in prefixed API.
enum CdmException {
  NOT_SUPPORTED_ERROR,
  INVALID_STATE_ERROR,
  INVALID_ACCESS_ERROR,
  QUOTA_EXCEEDED_ERROR,
  UNKNOWN_ERROR,
  CLIENT_ERROR,
  OUTPUT_ERROR
};

// Transport layer of media::CdmKeyInformation::KeyStatus (see
// media/base/cdm_key_information.h). This is used for indicating the status
// of a specific key ID.
enum CdmKeyStatus {
  USABLE,
  INTERNAL_ERROR,
  EXPIRED,
  OUTPUT_NOT_ALLOWED
};

// Transport layer of media::CdmConfig (see media/base/cdm_config.h).
struct CdmConfig {
  bool allow_distinctive_identifier;
  bool allow_persistent_state;
  bool use_hw_secure_codecs;
};

// Transport layer of media::CdmPromise (see media/base/cdm_promise.h).
// - When |success| is true, the promise is resolved and all other fields should
//   be ignored.
// - When |success| is false, the promise is rejected with |exception|,
//   |system_code| and |error_message|.
struct CdmPromiseResult {
  bool success;
  CdmException exception;
  uint32 system_code;
  string? error_message;
};

// Transport layer of media::CdmKeyInformation (see
// media/base/cdm_key_information.h). It is used to specify a key_id and it's
// associated status.
struct CdmKeyInformation {
  array<uint8> key_id;
  CdmKeyStatus status;
  uint32 system_code;
};

// See media::MediaKeys::MessageType
enum CdmMessageType {
  LICENSE_REQUEST,
  LICENSE_RENEWAL,
  LICENSE_RELEASE
};

// An interface that represents a CDM in the Encrypted Media Extensions (EME)
// spec (https://w3c.github.io/encrypted-media/). See media/base/media_keys.h.
interface ContentDecryptionModule {
  // See media::MediaKeys::SessionType.
  enum SessionType {
    TEMPORARY_SESSION,
    PERSISTENT_LICENSE_SESSION,
    PERSISTENT_RELEASE_MESSAGE_SESSION
  };

  // See media::EmeInitDataType.
  enum InitDataType {
    UNKNOWN,
    WEBM,
    CENC,
    KEYIDS
  };

  // Sets ContentDecryptionModuleClient. Must be called before any other calls.
  SetClient(ContentDecryptionModuleClient client);

  // Initializes the CDM. |cdm_id| will later be used to locate the CDM at the
  // remote side. If initialization failed (e.g. |key_system| or |cdm_config| is
  // not supported), |result.success| will be false.
  Initialize(string key_system, string security_origin, CdmConfig cdm_config,
             int32 cdm_id) => (CdmPromiseResult result);

  // Provides a server certificate to be used to encrypt messages to the
  // license server.
  SetServerCertificate(array<uint8> certificate_data)
      => (CdmPromiseResult result);

  // Creates a session with the |init_data_type|, |init_data| and |session_type|
  // provided. If |result.success| is false, the output |session_id| will be
  // null.
  CreateSessionAndGenerateRequest(SessionType session_type,
                                  InitDataType init_data_type,
                                  array<uint8> init_data)
      => (CdmPromiseResult result, string? session_id);

  // Loads the session associated with |session_id| and |session_type|.
  // Combinations of |result.success| and |session_id| means:
  //   (true, non-null) : Session successfully loaded.
  //   (true, null) : Session not found.
  //   (false, non-null): N/A; this combination is not allowed.
  //   (false, null) : Unexpected error. See other fields in |result|.
  LoadSession(SessionType session_type, string session_id)
      => (CdmPromiseResult result, string? session_id);

  // Updates a session specified by |session_id| with |response|.
  UpdateSession(string session_id, array<uint8> response)
      => (CdmPromiseResult result);

  // Closes the session specified by |session_id|.
  CloseSession(string session_id) => (CdmPromiseResult result);

  // Removes stored session data associated with the active session specified by
  // |session_id|.
  RemoveSession(string session_id) => (CdmPromiseResult result);

  // Retrieves the |decryptor| associated with this CDM instance.
  GetDecryptor(Decryptor&? decryptor);
};

// Session callbacks. See media/base/media_keys.h for details.
interface ContentDecryptionModuleClient {
  OnSessionMessage(string session_id, CdmMessageType message_type,
                   array<uint8> message, string legacy_destination_url);

  OnSessionClosed(string session_id);

  OnLegacySessionError(string session_id, CdmException exception,
                       uint32 system_code, string error_message);

  OnSessionKeysChange(string session_id, bool has_additional_usable_key,
                      array<CdmKeyInformation> key_information);

  // Provide session expiration update for |session_id|.
  // |new_expiry_time_sec| is the number of seconds since epoch (Jan 1, 1970).
  OnSessionExpirationUpdate(string session_id, double new_expiry_time_sec);
};