summaryrefslogtreecommitdiff
path: root/chromium/media/mojo/mojom/stable/stable_video_decoder.mojom
blob: 83b6bd9484aebbbc081c46a745cafb078aed3b55 (plain)
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
// Copyright 2021 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

module media.stable.mojom;

import "media/mojo/mojom/stable/stable_video_decoder_types.mojom";
import "mojo/public/mojom/base/unguessable_token.mojom";
import "sandbox/policy/mojom/sandbox.mojom";
import "ui/gfx/geometry/mojom/geometry.mojom";

// This API is a stable version of VideoDecoder. This is used both by LaCrOS and
// by out-of-process video decoding to allow the GPU process to forward video
// decoding requests to a video decoder process.
// In order to avoid depending on unstable definitions or on components which
// will cause cyclic dependencies, some similar but occasionally simplified
// version of structures were used rather than directly depending on the
// structures in other components.

// Based on |media.mojom.MediaLog| but does not depend on
// |media.mojom.MediaLogRecord|.
// Next min method ID: 1
[Stable, Uuid="2e4c1aed-fd62-40e6-8601-e5c4288246c0"]
interface MediaLog {
  // Adds a log record to a MediaLog service.
  AddLogRecord@0(MediaLogRecord event);
};

// Based on |media.mojom.VideoFrameHandleReleaser| but does not depend on
// |gpu.mojom.SyncToken|.
// Next min method ID: 1
[Stable, Uuid="8afdcf21-99d7-4864-a957-75d2a7e17da6"]
interface VideoFrameHandleReleaser {
  // Signals that the VideoFrame identified by |release_token| should be
  // released.
  ReleaseVideoFrame@0(mojo_base.mojom.UnguessableToken release_token);
};

// Based on |media.mojom.VideoDecoderClient| but does not depend on
// |media.mojom.VideoFrame| or |media.mojom.WaitingReason|.
// Next min method ID: 2
[Stable, Uuid="8a6fce77-7fcc-42e1-ac74-443859039696"]
interface VideoDecoderClient {
  // Output a decoded frame. Frames are output in presentation order.
  //
  // When |can_read_without_stalling| is false, preroll should be disabled. This
  // is necessary if the decoder cannot guarantee that it can output another
  // frame, for example if output buffers are limited or configuration changes
  // require the return of all outstanding frames.
  //
  // The client shall call VideoFrameHandleReleaser::ReleaseVideoFrame() with
  // |release_token| when it is finished using |frame|.
  OnVideoFrameDecoded@0(VideoFrame frame,
                      bool can_read_without_stalling,
                      mojo_base.mojom.UnguessableToken release_token);

  // Called when the remote decoder is waiting because of |reason|, e.g. waiting
  // for decryption key.
  OnWaiting@1(WaitingReason reason);
};

// Interface for handling callbacks from the StableCdmContext interface below.
// Next min method ID: 1
[Stable, Uuid="a1a73e1f-5297-49a2-a4e5-df875a44b61e"]
interface CdmContextEventCallback {
  // Sends the event back to the registrar.
  EventCallback@0(CdmContextEvent event);
};

// Maps to the media::CdmContext interface for remoting it to another process.
// Next MinVersion: 2
// Next min method ID: 4
[Stable, Uuid="33c7a00e-2970-41b3-8c7b-f1074a539740"]
interface StableCdmContext {
  // Proxies to media::CdmContext::GetChromeOsCdmContext()->GetHwKeyData.
  [MinVersion=1]
  GetHwKeyData@0(DecryptConfig decrypt_config, array<uint8> hw_identifier) =>
      (DecryptStatus status, array<uint8> key_data);

  // Registers an interface for receiving event callbacks. This maps to
  // media::CdmContext::RegisterEventCB.
  [MinVersion=1]
  RegisterEventCallback@1(pending_remote<CdmContextEventCallback> callback);

  // Proxies to media::CdmContext::GetChromeOsCdmContext()->GetHwConfigData.
  [MinVersion=1]
  GetHwConfigData@2() => (bool success, array<uint8> config_data);

  // Proxies to media::CdmContext::GetChromeOsCdmContext()->
  // GetScreenResolutions.
  [MinVersion=1]
  GetScreenResolutions@3() => (array<gfx.mojom.Size> resolutions);
};

// Based on |media.mojom.VideoDecoder|.
// Next min method ID: 5
[Stable, Uuid="85611470-3e87-43a9-ac75-a11a63e76415"]
interface StableVideoDecoder {
  // Returns a list of supported configs as well as the decoder ID for the
  // decoder which supports them. It is expected that Initialize() will fail
  // for any config that does not match an entry in this list.
  //
  // May be called before Construct().
  GetSupportedConfigs@0() =>
      (array<SupportedVideoDecoderConfig> supported_configs,
       VideoDecoderType decoder_type);

  // Initialize the decoder. This must be called before any method other than
  // GetSupportedConfigs().
  // StableVideoDecoder may hold onto references to VideoFrames sent to the
  // client. However, it shall not re-use those frames until the client calls
  // ReleaseVideoFrame() on |video_frame_handle_releaser|. The
  // StableVideoDecoder may, however, release those references at any time.
  // Therefore, VideoFrames sent to the client shall contain resources whose
  // lifetime is independent of the StableVideoDecoder's lifetime, e.g., file
  // descriptors.
  Construct@1(
      pending_associated_remote<VideoDecoderClient> client,
      pending_remote<MediaLog> media_log,
      pending_receiver<VideoFrameHandleReleaser> video_frame_handle_releaser,
      handle<data_pipe_consumer> decoder_buffer_pipe,
      ColorSpace target_color_space);

  // Configure (or reconfigure) the decoder. This must be called before decoding
  // any frames, and must not be called while there are pending Initialize(),
  // Decode(), or Reset() requests.
  Initialize@2(VideoDecoderConfig config, bool low_delay,
               pending_remote<StableCdmContext>? cdm_context)
      => (Status status,
          bool needs_bitstream_conversion,
          int32 max_decode_requests,
          VideoDecoderType decoder_type);

  // Request decoding of exactly one frame or an EOS buffer. This must not be
  // called while there are pending Initialize(), Reset(), or Decode(EOS)
  // requests.
  Decode@3(DecoderBuffer buffer) => (Status status);

  // Reset the decoder. All ongoing Decode() requests must be completed or
  // aborted before executing the callback. This must not be called while there
  // is a pending Initialize() request.
  Reset@4() => ();
};

// Only Chrome-for-Linux and ash-chrome should host the implementation of a
// StableVideoDecoderFactory.
[EnableIf=is_linux_or_chromeos_ash]
const sandbox.mojom.Sandbox kStableVideoDecoderFactoryServiceSandbox
 = sandbox.mojom.Sandbox.kHardwareVideoDecoding;
[EnableIfNot=is_linux_or_chromeos_ash]
const sandbox.mojom.Sandbox kStableVideoDecoderFactoryServiceSandbox
 = sandbox.mojom.Sandbox.kNoSandbox;

// A StableVideoDecoderFactory service is intended to be hosted in a utility
// process in either ash-chrome or Chrome-for-Linux. It allows the browser
// process to bind a StableVideoDecoder on behalf of some client which can be,
// e.g., the lacros-chrome browser process or a renderer process in ash-chrome.
// Next min method ID: 1
[ServiceSandbox=kStableVideoDecoderFactoryServiceSandbox, Stable,
Uuid="d6047fd9-fffb-4e37-ad9b-383a1c9e1d2d"]
interface StableVideoDecoderFactory {
  // Creates a StableVideoDecoder and should be called by the browser process.
  CreateStableVideoDecoder@0(pending_receiver<StableVideoDecoder> receiver);
};