video_capture.mojom 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. // Copyright 2021 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. module crosapi.mojom;
  5. import "media/capture/mojom/image_capture.mojom";
  6. import "media/capture/mojom/video_capture_types.mojom";
  7. import "mojo/public/mojom/base/shared_memory.mojom";
  8. import "mojo/public/mojom/base/time.mojom";
  9. import "mojo/public/mojom/base/unguessable_token.mojom";
  10. import "ui/gfx/geometry/mojom/geometry.mojom";
  11. import "ui/gfx/mojom/native_handle_types.mojom";
  12. // This API is used to forward requests/respond of video_capture::DeviceFactory
  13. // and video_capture::Device from Lacros (Client) to the actual implementation
  14. // in Ash-Chrome.
  15. // In addition, to avoid affecting too much on non-Chrome OS components and
  16. // depends on components which will cause cyclic dependency, we used some
  17. // similar but simplified version of structures rather than directly depends on
  18. // the structures in other components.
  19. // Similar to |gfx.mojom.NativePixmapHandle| but does not contain fields which
  20. // are not available on Chrome OS.
  21. // Next min field ID: 2
  22. [Stable]
  23. struct NativePixmapHandle {
  24. array<gfx.mojom.NativePixmapPlane> planes@0;
  25. uint64 modifier@1;
  26. };
  27. // Similar to |gfx.mojom.GpuMemoryBufferPlatformHandle| but does not contain
  28. // fields which are not available on Chrome OS.
  29. // Next min field ID: 2
  30. [Stable]
  31. union GpuMemoryBufferPlatformHandle {
  32. mojo_base.mojom.UnsafeSharedMemoryRegion shared_memory_handle@0;
  33. NativePixmapHandle native_pixmap_handle@1;
  34. };
  35. // Similar to |gfx.mojom.GpuMemoryBufferHandle| but does not depend on
  36. // |gfx.mojom.GpuMemoryBufferPlatformHandle|.
  37. // Next min field ID: 4
  38. [Stable]
  39. struct GpuMemoryBufferHandle {
  40. int32 id@0;
  41. uint32 offset@1;
  42. uint32 stride@2;
  43. GpuMemoryBufferPlatformHandle? platform_handle@3;
  44. };
  45. // Similar to |media.mojom.VideoBufferHandle| but does not contain fields which
  46. // are not used in Chrome OS implementation.
  47. // Next min field ID: 3
  48. [Stable, Uuid="0259e126-6da3-4cbb-8774-da1a7bf7f2f8"]
  49. union VideoBufferHandle {
  50. handle<shared_buffer> shared_buffer_handle@0;
  51. GpuMemoryBufferHandle gpu_memory_buffer_handle@1;
  52. // TODO(https://crbug.com/1261313): Until unions truly support versioning, we
  53. // don't have a way to check this/it ends up ignored. Currently this is only
  54. // set by code in ash to be read by lacros, which is strictly guaranteed to be
  55. // flowing from an older version to a newer version, so this is fine. It can
  56. // be proxied by checking if VideoCaptureDevice supports RequestRefreshFrame,
  57. // which was added at the same time.
  58. [MinVersion=1]
  59. mojo_base.mojom.ReadOnlySharedMemoryRegion read_only_shmem_region@2;
  60. };
  61. [Stable, Extensible]
  62. enum DeviceAccessResultCode {
  63. NOT_INITIALIZED,
  64. SUCCESS,
  65. ERROR_DEVICE_NOT_FOUND
  66. };
  67. // Identical to |media.mojom.VideoRotation|.
  68. [Stable, Extensible]
  69. enum VideoRotation {
  70. kVideoRotation0,
  71. kVideoRotation90,
  72. kVideoRotation180,
  73. kVideoRotation270,
  74. };
  75. // Similar to |media.mojom.VideoFrameInfo| but without some fields which does
  76. // not implement on Chrome OS. In addition, since most of the fields in
  77. // |metadata| field is not used in Chrome OS implementation, we also simplify
  78. // the structure by only containing |rotation| and |reference_time|.
  79. // Next min field ID: 6
  80. [Stable]
  81. struct VideoFrameInfo {
  82. mojo_base.mojom.TimeDelta timestamp@0;
  83. media.mojom.VideoCapturePixelFormat pixel_format@1;
  84. gfx.mojom.Size coded_size@2;
  85. gfx.mojom.Rect visible_rect@3;
  86. // The following fields are the fields we may use for constructing
  87. // media::VideoFrameMetadata.
  88. VideoRotation rotation@4;
  89. mojo_base.mojom.TimeTicks reference_time@5;
  90. };
  91. // Similar to |video_capture.mojom.ReadyFrameInBuffer| but does not depend on
  92. // |media.mojom.VideoFrameInfo| and
  93. // |video_capture.mojom.ScopedAccessPermission|.
  94. // Next min field ID: 4
  95. [Stable]
  96. struct ReadyFrameInBuffer {
  97. int32 buffer_id@0;
  98. int32 frame_feedback_id@1;
  99. pending_remote<ScopedAccessPermission> access_permission@2;
  100. VideoFrameInfo frame_info@3;
  101. };
  102. // Identical to |video_capture.mojom.ScopedAccessPermission|.
  103. // Next min method ID: 0
  104. [Stable, Uuid="bf0f3239-26d2-45f8-9875-490563f5af97"]
  105. interface ScopedAccessPermission {};
  106. // Similar to |video_capture.mojom.VideoFrameHandler| but depends on simplified
  107. // structures.
  108. // Next min method ID: 11
  109. [Stable, Uuid="590ab36a-9162-4c9d-8429-1753108825ea"]
  110. interface VideoFrameHandler {
  111. OnNewBuffer@0(int32 buffer_id, VideoBufferHandle buffer_handle);
  112. OnFrameReadyInBuffer@1(ReadyFrameInBuffer buffer,
  113. array<ReadyFrameInBuffer> scaled_buffers);
  114. OnBufferRetired@2(int32 buffer_id);
  115. OnError@3(media.mojom.VideoCaptureError error);
  116. OnFrameDropped@4(media.mojom.VideoCaptureFrameDropReason reason);
  117. [MinVersion=2]
  118. OnNewCropVersion@10(uint32 crop_version);
  119. [MinVersion=1]
  120. OnFrameWithEmptyRegionCapture@9();
  121. OnLog@5(string message);
  122. OnStarted@6();
  123. OnStartedUsingGpuDecode@7();
  124. OnStopped@8();
  125. };
  126. // Similar to |video_capture.mojom.Device| but depends on simplified structures.
  127. // Next min method ID: 8
  128. [Stable, Uuid="f50f1672-d512-451e-9c70-998ed45ab596"]
  129. interface VideoCaptureDevice {
  130. // It is assumed that it will be called only once.
  131. Start@0(media.mojom.VideoCaptureParams requested_settings,
  132. pending_remote<VideoFrameHandler> handler);
  133. MaybeSuspend@1();
  134. Resume@2();
  135. GetPhotoState@3() => (media.mojom.PhotoState? capabilities);
  136. SetPhotoOptions@4(media.mojom.PhotoSettings settings) => (bool success);
  137. TakePhoto@5() => (media.mojom.Blob? blob);
  138. ProcessFeedback@6(media.mojom.VideoCaptureFeedback feedback);
  139. [MinVersion = 1]
  140. RequestRefreshFrame@7();
  141. };
  142. // Similar to |video_capture.mojom.DeviceFactory| but depends on simplified
  143. // structures.
  144. // Next min method ID: 2
  145. [Stable, Uuid="b79ed8be-cf39-4d0d-a819-2d299022124a"]
  146. interface VideoCaptureDeviceFactory {
  147. GetDeviceInfos@0()
  148. => (array<media.mojom.VideoCaptureDeviceInfo> device_infos);
  149. CreateDevice@1(string device_id,
  150. pending_receiver<VideoCaptureDevice> device_receiver)
  151. => (DeviceAccessResultCode result_code);
  152. };