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/demuxer_stream.mojom";
8 import "media/mojo/interfaces/media_types.mojom";
10 // TODO(xhwang): Add mojo types for AudioBuffer and VideoFrame.
11 struct AudioBuffer {};
14 // Interface for decrypting (and decoding) encrypted streams.
15 // See media/base/decryptor.h for details.
17 // Status of a decrypt or decrypt-and-decode operation. The returned
18 // buffer/frame of such an operation is NOT null iff the status is SUCCESS.
20 SUCCESS, // Successfully completed. Decrypted buffer ready.
21 NO_KEY, // No key is available to decrypt.
22 NEED_MORE_DATA, // Decoder needs more data to produce an output.
23 ERROR // Key is available but an error occurred during decryption.
26 // Decrypts the |encrypted| buffer and returns the decrypt |status| and
27 // decrypted |buffer|.
28 // At most one decrypt call is allowed at any time for a |stream_type|.
29 Decrypt(DemuxerStream.Type stream_type, MediaDecoderBuffer encrypted)
30 => (Status status, MediaDecoderBuffer? buffer);
32 // Cancels any pending decrypt for |stream_type| with SUCCESS.
33 CancelDecrypt(DemuxerStream.Type stream_type);
35 // Initializes a decoder with the given |config|. Returns whether the
36 // initialization succeeded.
37 InitializeAudioDecoder(AudioDecoderConfig config) => (bool success);
38 InitializeVideoDecoder(VideoDecoderConfig config) => (bool success);
40 // Decrypts and decodes the |encrypted| buffer and returns the |status| and
41 // the decrypted |audio_buffers| or |video_frame|.
42 // At end-of-stream, this method should be called repeatedly with
43 // end-of-stream |encrypted| until no buffer/frame can be produced.
44 // These methods can only be called after the corresponding decoder has
45 // been successfully initialized.
46 // At most one decrypt-and-decode call is allowed at any time for a
48 DecryptAndDecodeAudio(MediaDecoderBuffer encrypted)
49 => (Status status, array<AudioBuffer>? audio_buffers);
50 DecryptAndDecodeVideo(
51 MediaDecoderBuffer encrypted) => (Status status, VideoFrame? video_frame);
53 // Resets the decoder for |stream_type| to a clean initialized state and
54 // cancels any pending decrypt-and-decode operations immediately with ERROR.
55 // This method can only be called after the corresponding decoder has been
56 // successfully initialized.
57 ResetDecoder(DemuxerStream.Type stream_type);
59 // Releases decoder resources, deinitializes the decoder, aborts any pending
60 // initialization (with false) or decrypt-and-decode (with ERROR) for
61 // |stream_type| immediately.
62 // This method can be called any time after Initialize{Audio|Video}Decoder()
63 // has been called (with the correct stream type).
64 // After this operation, the decoder is set to an uninitialized state.
65 // The decoder can be reinitialized after it is deinitialized.
66 DeinitializeDecoder(DemuxerStream.Type stream_type);
69 interface DecryptorClient {
70 // Indicates that a new usable key is available in the CDM associated with the