1 // Copyright 2014 The Chromium Authors
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/mojom/media_types.mojom";
9 // Interface for decrypting (and decoding) encrypted streams.
10 // See media/base/decryptor.h for details.
11 // TODO(crbug.com/794326): Deduplicate this interface with audio_decoder.mojom
12 // and audio_decoder.mojom.
14 // Status of a decrypt or decrypt-and-decode operation. See decryptor.h for
19 // Stream type (audio/video). See decryptor.h for descriptions.
23 // Pass three data pipes used to transfer compressed DecoderBuffer data for
24 // DecryptAndDecodeAudio(), and DecryptAndDecodeVideo() and Decrypt(),
25 // respectively, and one data pipe to receive DecoderBuffer data for decrypt
26 // result passed back in OnDecryptDone() calls.
27 // This method must be called before any methods listed are called.
28 Initialize(handle<data_pipe_consumer> audio_pipe,
29 handle<data_pipe_consumer> video_pipe,
30 handle<data_pipe_consumer> decrypt_pipe,
31 handle<data_pipe_producer> decrypted_pipe);
33 // Decrypts the |encrypted| buffer and returns the decrypt |status| and
34 // decrypted |buffer|.
35 // At most one decrypt call is allowed at any time for a |stream_type|.
36 Decrypt(StreamType stream_type, DecoderBuffer encrypted)
37 => (Status status, DecoderBuffer? buffer);
39 // Cancels any pending decrypt for |stream_type| with SUCCESS.
40 CancelDecrypt(StreamType stream_type);
42 // Initializes a decoder with the given |config|. Returns whether the
43 // initialization succeeded.
44 InitializeAudioDecoder(AudioDecoderConfig config) => (bool success);
45 InitializeVideoDecoder(VideoDecoderConfig config) => (bool success);
47 // Decrypts and decodes the |encrypted| buffer and returns the |status| and
48 // the decrypted |audio_buffers| or |video_frame|.
49 // At end-of-stream, this method should be called repeatedly with
50 // end-of-stream |encrypted| until no buffer/frame can be produced.
51 // These methods can only be called after the corresponding decoder has
52 // been successfully initialized.
53 // At most one decrypt-and-decode call is allowed at any time for a
55 // For video, |releaser| must be closed (if it is bound) when the VideoFrame
56 // is no longer needed so that any shared resources can be reused.
57 DecryptAndDecodeAudio(DecoderBuffer encrypted)
58 => (Status status, array<AudioBuffer> audio_buffers);
59 DecryptAndDecodeVideo(DecoderBuffer encrypted)
61 VideoFrame? video_frame,
62 pending_remote<FrameResourceReleaser>? releaser);
64 // Resets the decoder for |stream_type| to a clean initialized state and
65 // cancels any pending decrypt-and-decode operations immediately with ERROR.
66 // This method can only be called after the corresponding decoder has been
67 // successfully initialized.
68 ResetDecoder(StreamType stream_type);
70 // Releases decoder resources, deinitializes the decoder, aborts any pending
71 // initialization (with false) or decrypt-and-decode (with ERROR) for
72 // |stream_type| immediately.
73 // This method can be called any time after Initialize{Audio|Video}Decoder()
74 // has been called (with the correct stream type).
75 // After this operation, the decoder is set to an uninitialized state.
76 // The decoder can be reinitialized after it is deinitialized.
77 DeinitializeDecoder(StreamType stream_type);
80 // Interface for controlling the the resources associated with a VideoFrame.
81 // This is returned when calling DecryptAndDecodeVideo(), and the connection
82 // (if it exists) should be closed when the VideoFrame is no longer needed in
83 // order to reuse the shared resources associated with the VideoFrame.
84 interface FrameResourceReleaser {};