OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 module media.mojom; | 5 module media.mojom; |
6 | 6 |
7 import "media/mojo/interfaces/demuxer_stream.mojom"; | |
8 import "media/mojo/interfaces/media_types.mojom"; | 7 import "media/mojo/interfaces/media_types.mojom"; |
9 | 8 |
10 // Interface for decrypting (and decoding) encrypted streams. | 9 // Interface for decrypting (and decoding) encrypted streams. |
11 // See media/base/decryptor.h for details. | 10 // See media/base/decryptor.h for details. |
12 interface Decryptor { | 11 interface Decryptor { |
13 // Status of a decrypt or decrypt-and-decode operation. The returned | 12 // Status of a decrypt or decrypt-and-decode operation. See decryptor.h for |
14 // buffer/frame of such an operation is NOT null iff the status is SUCCESS. | 13 // descriptions. |
15 enum Status { | 14 [Native] |
16 SUCCESS, // Successfully completed. Decrypted buffer ready. | 15 enum Status; |
17 NO_KEY, // No key is available to decrypt. | 16 |
18 NEED_MORE_DATA, // Decoder needs more data to produce an output. | 17 // Stream type (audio/video). See decryptor.h for descriptions. |
19 // Key is available but an error occurred during decryption. | 18 [Native] |
20 DECRYPTION_ERROR | 19 enum StreamType; |
21 }; | |
22 | 20 |
23 // Pass the two data pipes used to transfer DecoderBuffer contents to and | 21 // Pass the two data pipes used to transfer DecoderBuffer contents to and |
24 // from the Decryptor. |receive_pipe| will be used to receive DecoderBuffer | 22 // from the Decryptor. |receive_pipe| will be used to receive DecoderBuffer |
25 // data on Decrypt(), DecryptAndDecodeAudio(), and DecryptAndDecodeVideo() | 23 // data on Decrypt(), DecryptAndDecodeAudio(), and DecryptAndDecodeVideo() |
26 // calls. |transmit_pipe| will be used to pass the DecoderBuffer data | 24 // calls. |transmit_pipe| will be used to pass the DecoderBuffer data |
27 // back with OnDecryptDone() calls. This method must be called before any | 25 // back with OnDecryptDone() calls. This method must be called before any |
28 // methods listed are called. | 26 // methods listed are called. |
29 Initialize(handle<data_pipe_consumer> receive_pipe, | 27 Initialize(handle<data_pipe_consumer> receive_pipe, |
30 handle<data_pipe_producer> transmit_pipe); | 28 handle<data_pipe_producer> transmit_pipe); |
31 | 29 |
32 // Decrypts the |encrypted| buffer and returns the decrypt |status| and | 30 // Decrypts the |encrypted| buffer and returns the decrypt |status| and |
33 // decrypted |buffer|. | 31 // decrypted |buffer|. |
34 // At most one decrypt call is allowed at any time for a |stream_type|. | 32 // At most one decrypt call is allowed at any time for a |stream_type|. |
35 Decrypt(DemuxerStream.Type stream_type, DecoderBuffer encrypted) | 33 Decrypt(StreamType stream_type, DecoderBuffer encrypted) |
36 => (Status status, DecoderBuffer? buffer); | 34 => (Status status, DecoderBuffer? buffer); |
37 | 35 |
38 // Cancels any pending decrypt for |stream_type| with SUCCESS. | 36 // Cancels any pending decrypt for |stream_type| with SUCCESS. |
39 CancelDecrypt(DemuxerStream.Type stream_type); | 37 CancelDecrypt(StreamType stream_type); |
40 | 38 |
41 // Initializes a decoder with the given |config|. Returns whether the | 39 // Initializes a decoder with the given |config|. Returns whether the |
42 // initialization succeeded. | 40 // initialization succeeded. |
43 InitializeAudioDecoder(AudioDecoderConfig config) => (bool success); | 41 InitializeAudioDecoder(AudioDecoderConfig config) => (bool success); |
44 InitializeVideoDecoder(VideoDecoderConfig config) => (bool success); | 42 InitializeVideoDecoder(VideoDecoderConfig config) => (bool success); |
45 | 43 |
46 // Decrypts and decodes the |encrypted| buffer and returns the |status| and | 44 // Decrypts and decodes the |encrypted| buffer and returns the |status| and |
47 // the decrypted |audio_buffers| or |video_frame|. | 45 // the decrypted |audio_buffers| or |video_frame|. |
48 // At end-of-stream, this method should be called repeatedly with | 46 // At end-of-stream, this method should be called repeatedly with |
49 // end-of-stream |encrypted| until no buffer/frame can be produced. | 47 // end-of-stream |encrypted| until no buffer/frame can be produced. |
50 // These methods can only be called after the corresponding decoder has | 48 // These methods can only be called after the corresponding decoder has |
51 // been successfully initialized. | 49 // been successfully initialized. |
52 // At most one decrypt-and-decode call is allowed at any time for a | 50 // At most one decrypt-and-decode call is allowed at any time for a |
53 // |stream_type|. | 51 // |stream_type|. |
54 // For video, ReleaseSharedBuffer() must be called when the VideoFrame | 52 // For video, ReleaseSharedBuffer() must be called when the VideoFrame |
55 // is shared memory based and the memory is no longer needed. | 53 // is shared memory based and the memory is no longer needed. |
56 DecryptAndDecodeAudio(DecoderBuffer encrypted) | 54 DecryptAndDecodeAudio(DecoderBuffer encrypted) |
57 => (Status status, array<AudioBuffer> audio_buffers); | 55 => (Status status, array<AudioBuffer> audio_buffers); |
58 DecryptAndDecodeVideo(DecoderBuffer encrypted) | 56 DecryptAndDecodeVideo(DecoderBuffer encrypted) |
59 => (Status status, VideoFrame? video_frame); | 57 => (Status status, VideoFrame? video_frame); |
60 | 58 |
61 // Resets the decoder for |stream_type| to a clean initialized state and | 59 // Resets the decoder for |stream_type| to a clean initialized state and |
62 // cancels any pending decrypt-and-decode operations immediately with ERROR. | 60 // cancels any pending decrypt-and-decode operations immediately with ERROR. |
63 // This method can only be called after the corresponding decoder has been | 61 // This method can only be called after the corresponding decoder has been |
64 // successfully initialized. | 62 // successfully initialized. |
65 ResetDecoder(DemuxerStream.Type stream_type); | 63 ResetDecoder(StreamType stream_type); |
66 | 64 |
67 // Releases decoder resources, deinitializes the decoder, aborts any pending | 65 // Releases decoder resources, deinitializes the decoder, aborts any pending |
68 // initialization (with false) or decrypt-and-decode (with ERROR) for | 66 // initialization (with false) or decrypt-and-decode (with ERROR) for |
69 // |stream_type| immediately. | 67 // |stream_type| immediately. |
70 // This method can be called any time after Initialize{Audio|Video}Decoder() | 68 // This method can be called any time after Initialize{Audio|Video}Decoder() |
71 // has been called (with the correct stream type). | 69 // has been called (with the correct stream type). |
72 // After this operation, the decoder is set to an uninitialized state. | 70 // After this operation, the decoder is set to an uninitialized state. |
73 // The decoder can be reinitialized after it is deinitialized. | 71 // The decoder can be reinitialized after it is deinitialized. |
74 DeinitializeDecoder(DemuxerStream.Type stream_type); | 72 DeinitializeDecoder(StreamType stream_type); |
75 | 73 |
76 // Releases the shared memory. | 74 // Releases the shared memory. |
77 ReleaseSharedBuffer(handle<shared_buffer> buffer, uint64 buffer_size); | 75 ReleaseSharedBuffer(handle<shared_buffer> buffer, uint64 buffer_size); |
78 }; | 76 }; |
OLD | NEW |