1
    2
    3
    4
    5
    6
    7
    8
    9
   10
   11
   12
   13
   14
   15
   16
   17
   18
   19
   20
   21
   22
   23
   24
   25
   26
   27
   28
   29
   30
   31
   32
   33
   34
   35
   36
   37
   38
   39
   40
   41
   42
   43
   44
   45
   46
   47
   48
   49
   50
   51
   52
   53
   54
   55
   56
   57
   58
   59
   60
   61
   62
   63
   64
   65
   66
   67
   68
   69
   70
   71
   72
   73
   74
   75
   76
   77
   78
   79
   80
   81
   82
   83
   84

media / mojo / mojom / decryptor.mojom [blame]

// Copyright 2014 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

module media.mojom;

import "media/mojo/mojom/media_types.mojom";

// Interface for decrypting (and decoding) encrypted streams.
// See media/base/decryptor.h for details.
// TODO(crbug.com/40554405): Deduplicate this interface with audio_decoder.mojom
// and audio_decoder.mojom.
interface Decryptor {
  // Status of a decrypt or decrypt-and-decode operation. See decryptor.h for
  // descriptions.
  [Native]
  enum Status;

  // Stream type (audio/video). See decryptor.h for descriptions.
  [Native]
  enum StreamType;

  // Pass three data pipes used to transfer compressed DecoderBuffer data for
  // DecryptAndDecodeAudio(), and DecryptAndDecodeVideo() and Decrypt(),
  // respectively, and one data pipe to receive DecoderBuffer data for decrypt
  // result passed back in OnDecryptDone() calls.
  // This method must be called before any methods listed are called.
  Initialize(handle<data_pipe_consumer> audio_pipe,
             handle<data_pipe_consumer> video_pipe,
             handle<data_pipe_consumer> decrypt_pipe,
             handle<data_pipe_producer> decrypted_pipe);

  // Decrypts the |encrypted| buffer and returns the decrypt |status| and
  // decrypted |buffer|.
  // At most one decrypt call is allowed at any time for a |stream_type|.
  Decrypt(StreamType stream_type, DecoderBuffer encrypted)
      => (Status status, DecoderBuffer? buffer);

  // Cancels any pending decrypt for |stream_type| with SUCCESS.
  CancelDecrypt(StreamType stream_type);

  // Initializes a decoder with the given |config|. Returns whether the
  // initialization succeeded.
  InitializeAudioDecoder(AudioDecoderConfig config) => (bool success);
  InitializeVideoDecoder(VideoDecoderConfig config) => (bool success);

  // Decrypts and decodes the |encrypted| buffer and returns the |status| and
  // the decrypted |audio_buffers| or |video_frame|.
  // At end-of-stream, this method should be called repeatedly with
  // end-of-stream |encrypted| until no buffer/frame can be produced.
  // These methods can only be called after the corresponding decoder has
  // been successfully initialized.
  // At most one decrypt-and-decode call is allowed at any time for a
  // |stream_type|.
  // For video, |releaser| must be closed (if it is bound) when the VideoFrame
  // is no longer needed so that any shared resources can be reused.
  DecryptAndDecodeAudio(DecoderBuffer encrypted)
      => (Status status, array<AudioBuffer> audio_buffers);
  DecryptAndDecodeVideo(DecoderBuffer encrypted)
      => (Status status,
          VideoFrame? video_frame,
          pending_remote<FrameResourceReleaser>? releaser);

  // Resets the decoder for |stream_type| to a clean initialized state and
  // cancels any pending decrypt-and-decode operations immediately with ERROR.
  // This method can only be called after the corresponding decoder has been
  // successfully initialized.
  ResetDecoder(StreamType stream_type);

  // Releases decoder resources, deinitializes the decoder, aborts any pending
  // initialization (with false) or decrypt-and-decode (with ERROR) for
  // |stream_type| immediately.
  // This method can be called any time after Initialize{Audio|Video}Decoder()
  // has been called (with the correct stream type).
  // After this operation, the decoder is set to an uninitialized state.
  // The decoder can be reinitialized after it is deinitialized.
  DeinitializeDecoder(StreamType stream_type);
};

// Interface for controlling the the resources associated with a VideoFrame.
// This is returned when calling DecryptAndDecodeVideo(), and the connection
// (if it exists) should be closed when the VideoFrame is no longer needed in
// order to reuse the shared resources associated with the VideoFrame.
interface FrameResourceReleaser {};