[M120 Migration][MM] Framerate calculation
[platform/framework/web/chromium-efl.git] / media / mojo / mojom / renderer_extensions.mojom
1 // Copyright 2019 The Chromium Authors
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 media.mojom;
6
7 import "media/mojo/mojom/media_types.mojom";
8 import "mojo/public/mojom/base/time.mojom";
9 import "mojo/public/mojom/base/shared_memory.mojom";
10 import "mojo/public/mojom/base/unguessable_token.mojom";
11 import "ui/gfx/geometry/mojom/geometry.mojom";
12 import "ui/gfx/mojom/buffer_types.mojom";
13
14 [EnableIf=is_win]
15 import "ui/gfx/mojom/buffer_types.mojom";
16 // Extension of the mojo::RendererClient communication layer for HLS and Android
17 // software rendering fallback paths.
18 // This allows the Browser side to call back into the Renderer side. Concretely,
19 // the MediaPlayerRenderer uses these methods to propagate events it raises to
20 // the MediaPlayerRendererClient, which lives in the Renderer process.
21 interface MediaPlayerRendererClientExtension {
22   // Called when the first time the metadata is updated, and whenever the
23   // metadata changes.
24   OnVideoSizeChange(gfx.mojom.Size size);
25   OnDurationChange(mojo_base.mojom.TimeDelta duration);
26
27   [EnableIf=tizen_multimedia]
28   OnBufferUpdate(mojo_base.mojom.TimeDelta time);
29
30   [EnableIf=tizen_multimedia]
31   OnNewFrameAvailable(uint32 playerId,
32                       mojo_base.mojom.UnsafeSharedMemoryRegion frame,
33                       uint32 size,
34                       mojo_base.mojom.TimeDelta timestamp,
35                       uint32 width,
36                       uint32 height);
37
38   [EnableIf=tizen_tbm_support]
39   OnNewTbmFrameAvailable(uint32 playerId,
40                          gfx.mojom.TbmBufferHandle tbm_buffer_handle,
41                          mojo_base.mojom.TimeDelta timestamp);
42 };
43
44 // Extension of the mojo::Renderer communication layer for HLS and Android
45 // software rendering fallback paths.
46 // This allows the Renderer side to call into the Browser side.
47 // Concretely, the MediaPlayerRendererClient uses these methods to send commands
48 // to MediaPlayerRenderer, which lives in the Browser process.
49 interface MediaPlayerRendererExtension {
50   // Registers a new request in the ScopedSurfaceRequestManager, and returns
51   // its token.
52   // Called once, during media::Renderer initialization, as part of
53   // StreamTexture's set-up.
54   InitiateScopedSurfaceRequest()
55       => (mojo_base.mojom.UnguessableToken request_token);
56
57   [EnableIf=tizen_tbm_support]
58   OnTbmBufferExhausted(gfx.mojom.TbmBufferHandle tbm_buffer_handle);
59 };
60
61 // Extension of the mojo::RendererClient communication layer for media flinging,
62 // a.k.a RemotePlayback, when playing media on a remote Cast device.
63 // This allows the Browser side to call back into the Renderer side.
64 // Concretely, the FlingingRenderer uses these methods to propagate events it
65 // raises to the FlingingRendererClient, which lives in the Renderer process.
66 interface FlingingRendererClientExtension {
67   // Called when the play state of a casted device goes out of sync with WMPI's
68   // play state (e.g. when another phone play/pauses a cast device on the same
69   // network).
70   OnRemotePlayStateChange(MediaStatusState state);
71 };
72
73 [EnableIf=is_win]
74 struct FrameTextureInfo {
75   gfx.mojom.GpuMemoryBufferHandle texture_handle;
76   mojo_base.mojom.UnguessableToken token;
77 };
78
79 [EnableIf=is_win]
80 struct FramePoolInitializationParameters {
81   array<FrameTextureInfo> frame_textures;
82   gfx.mojom.Size texture_size;
83 };
84
85 [EnableIf=is_win]
86 // Extension of the mojo:RendererClient communication layer for Media
87 // Foundation based Renderer.
88 // This allows the MF_CDM utility process to call the blink Renderer process
89 // side.
90 // Concretely, the MediaFoundationRenderer (in the MF_CDM process) uses these
91 // methods to send video frames as textures to the
92 // MediaFoundationRendererClient which lives in the blink renderer process so
93 // that the MediaFoundationRenderer can signal to the video stream sink that
94 // the specific texture is ready to be displayed.
95 interface MediaFoundationRendererClientExtension {
96   // Provide the GPU textures (ID3D11Texture2D) to the
97   // MediaFoundationRendererClient with the associated token so that the
98   // MediaFoundationRendererClient can create the shared images in the GPU
99   // process using the SharedImageInterface.
100   InitializeFramePool(FramePoolInitializationParameters pool_info);
101
102   // Signal to the MediaFoundationRendererClient that the texture associated
103   // with the frame_token is ready to be displayed with the corresponding
104   // frame size and timestamp which is the delta between the start of the
105   // AV presentation and the time that the frame is to be presented.
106   OnFrameAvailable(mojo_base.mojom.UnguessableToken frame_token,
107     gfx.mojom.Size size, mojo_base.mojom.TimeDelta timestamp);
108 };
109
110 // The Media Foundation Media Engine has two modes for playback.
111 // DirectComposition is when the media engine will render directly to a
112 // direct composition visual, skipping the Chromium compositor.
113 // FrameServer is when the media engine will render to a texture and
114 // that textured is provided to the Chromium compositor.
115 enum MediaFoundationRenderingMode {
116   DirectComposition,
117   FrameServer
118 };
119
120 [EnableIf=is_win]
121 // Extension of the mojo::Renderer communication layer for MediaFoundation-based
122 // Renderer.
123 // This allows the MediaFoundationRendererClient in the render process to call
124 // into the MediaFoundationRenderer in the MediaFoundationService (utility/LPAC)
125 // process.
126 // Please refer to media/renderers/win/media_foundation_renderer_extension.h
127 // for its C++ interface equivalence.
128 interface MediaFoundationRendererExtension {
129   // Enables Direct Composition video rendering and gets the token associated
130   // with the Direct Composition surface handle, which can be retrieved later
131   // in the GPU process using the token. Returns a null `token` on failures when
132   // `error` explains the failure reason.
133   GetDCOMPSurface() => (mojo_base.mojom.UnguessableToken? token, string error);
134
135   // Notifies whether video is enabled.
136   SetVideoStreamEnabled(bool enabled);
137
138   // Notifies of output composition parameters. It might fail if
139   // MediaFoundationRenderer runs into error while setting the `rect`
140   // information onto MFMediaEngine. It it fails, the video will be displayed
141   // incorrectly (e.g. a smaller video rendered at the corner of the video
142   // output area.). In case of failure, caller should not use the `rect` for
143   // further operations.
144   SetOutputRect(gfx.mojom.Rect rect) => (bool success);
145
146   // Notify that the frame has been displayed and can be reused.
147   NotifyFrameReleased(mojo_base.mojom.UnguessableToken frame_token);
148
149   // Request a frame from the media engine if it is available
150   // The frame will be returned async via the
151   // MediaFoundationRendererClientExtension::OnFrameAvailable callback.
152   RequestNextFrame();
153
154   // Notify which rendering mode to be using for future video frames.
155   SetMediaFoundationRenderingMode(MediaFoundationRenderingMode mode);
156 };
157
158 // This interface is used by the browser to determine if there are any renderers
159 // actively using the Media Foundation Renderer. The number of Media Foundation
160 // Renderers in use is determined by the number of active connections. The
161 // remote lives in the renderer process and the receiver lives in the browser
162 // process.
163 interface MediaFoundationRendererObserver {
164 };
165
166 // This interface is used to notify the browser that the renderer is using the
167 // Media Foundation Renderer which uses MediaFoundation to render audio
168 // directly. Live Caption will not work in this case because Chrome is unable
169 // to tap into the audio rendering pipeline. The remote lives in the renderer
170 // process and the receiver lives in the browser process.
171 interface MediaFoundationRendererNotifier {
172   // Notify the browser than a Media Foundation Renderer has been created. The
173   // browser will use this event to notify the user that some features
174   // incompatible with the Media Foundation Renderer may not work.
175   MediaFoundationRendererCreated(
176     pending_receiver<MediaFoundationRendererObserver> observer);
177 };