Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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. | |
| 4 | |
| 5 module mojo; | |
| 6 | |
| 7 import "media/mojo/interfaces/demuxer_stream.mojom"; | |
| 8 import "media/mojo/interfaces/media_types.mojom"; | |
| 9 | |
| 10 // TODO(xhwang): Add mojo types for AudioBuffer and VideoFrame. | |
| 11 struct AudioBuffer {}; | |
| 12 struct VideoFrame {}; | |
| 13 | |
| 14 // Interface for decrypting (and decoding) encrypted streams. | |
| 15 // See media/base/decryptor.h for details. | |
| 16 // TODO(xhwang): Canceling/resetting is messy. Clean this up later. For now, | |
| 17 // make this interface as close as media::Decryptor. | |
|
ddorwin
2014/12/08 23:46:48
nit: missing words
xhwang
2014/12/10 04:59:16
Dropped. We may want to clean up decryptor.h at so
| |
| 18 [Client=DecryptorClient] | |
| 19 interface Decryptor { | |
| 20 // Status of a decrypt or a decrypt-and-decode operation. The returned | |
|
ddorwin
2014/12/08 23:46:48
nit: drop second "a"
xhwang
2014/12/10 04:59:16
Done.
| |
| 21 // buffer/frame of such an operation is NOT null iff the status is SUCCESS. | |
| 22 enum Status { | |
| 23 SUCCESS, // Successfully completed. Decrypted buffer ready. | |
| 24 NO_KEY, // No key is available to decrypt. | |
| 25 NEED_MORE_DATA, // Decoder needs more data to produce an output. | |
| 26 ERROR // Key is available but an error occurred during decryption. | |
|
ddorwin
2014/12/08 23:46:49
OOC, this always results in DECODE_ERROR, right?
xhwang
2014/12/10 04:59:16
Yes.
| |
| 27 }; | |
| 28 | |
| 29 // Decrypts the |encrypted| buffer and returns the decrypt |status| and | |
| 30 // decrypted |buffer|. | |
| 31 // At most one decrypt call is allowed at any time for a |stream_type|. | |
|
ddorwin
2014/12/08 23:46:48
We should replace stream_type with IDs before this
xhwang
2014/12/10 04:59:16
Hmm, but the calls are different on different stre
ddorwin
2014/12/12 19:25:13
Decrypt callbacks aren't, right?
What I'm really
xhwang
2014/12/12 23:15:44
I see. Let's iterate on this later. We can update
| |
| 32 Decrypt(DemuxerStream.Type stream_type, MediaDecoderBuffer encrypted) | |
| 33 => (Status status, MediaDecoderBuffer? buffer); | |
| 34 | |
| 35 // Cancels any pending decrypt for |stream_type| with SUCCESS. | |
| 36 CancelDecrypt(DemuxerStream.Type stream_type); | |
| 37 | |
| 38 // Initializes a decoder with the given |config|. Returns whether the | |
| 39 // initialization succeeded. | |
| 40 InitializeAudioDecoder(AudioDecoderConfig config) => (bool success); | |
| 41 InitializeVideoDecoder(VideoDecoderConfig config) => (bool success); | |
| 42 | |
| 43 // Decrypts and decodes the |encrypted| buffer and returns the |status| and | |
| 44 // the decrypted |audio_buffers| or |video_frame|. | |
| 45 // At end-of-stream, this method should be called repeatedly with | |
| 46 // end-of-stream |encrypted| until no buffer/frame can be produced. | |
| 47 // These methods can only be called after the corresponding decoder has | |
| 48 // been successfully initialized. | |
| 49 // At most one decrypt-and-decode call is allowed at any time for a | |
|
ddorwin
2014/12/08 23:46:49
Are D and D&D calls also mutually-exclusive?
xhwang
2014/12/10 04:59:16
That's a grey area. We never do it in our code. Bu
ddorwin
2014/12/12 19:25:12
Perhaps per stream ID (if we supported multiple).
xhwang
2014/12/12 23:15:44
Acknowledged.
| |
| 50 // |stream_type|. | |
| 51 DecryptAndDecodeAudio(MediaDecoderBuffer encrypted) | |
| 52 => (Status status, array<AudioBuffer>? audio_buffers); | |
| 53 DecryptAndDecodeVideo( | |
| 54 MediaDecoderBuffer encrypted) => (Status status, VideoFrame? video_frame); | |
| 55 | |
| 56 // Resets the decoder for |stream_type| to a clean initialized state, cancels | |
|
ddorwin
2014/12/08 23:46:48
nit: s/,/and/
xhwang
2014/12/10 04:59:16
Done.
| |
| 57 // any pending decrypt-and-decode operations immediately with ERROR. | |
| 58 // This method can only be called after the corresponding decoder has been | |
| 59 // successfully initialized. | |
| 60 ResetDecoder(DemuxerStream.Type stream_type); | |
| 61 | |
| 62 // Releases decoder resources, deinitializes the decoder, aborts any pending | |
| 63 // initialization (with false) or decrypt-and-decode (with ERROR) for | |
| 64 // |stream_type| immediately. | |
| 65 // This method can be called any time after Initialize{Audio|Video}Decoder() | |
| 66 // has been called (with the correct stream type). | |
| 67 // After this operation, the decoder is set to an uninitialized state. | |
| 68 // The decoder can be reinitialized after it is deinitialized. | |
| 69 DeinitializeDecoder(DemuxerStream.Type stream_type); | |
|
ddorwin
2014/12/08 23:46:48
Do we want this to be sync? Same for ResetDecoder.
xhwang
2014/12/10 04:59:16
This is how things work now. Non of our CDM/decode
| |
| 70 }; | |
| 71 | |
| 72 interface DecryptorClient { | |
| 73 // Indicates that a new usable key is available in the CDM associated with the | |
|
ddorwin
2014/12/08 23:46:48
I don't think we need this (and it seems like the
xhwang
2014/12/10 04:59:16
The client needs a way to retry. This is the repla
| |
| 74 // Decryptor. | |
| 75 OnNewUsableKey(); | |
| 76 }; | |
| OLD | NEW |