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