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

media / capture / mojom / video_capture_buffer.mojom [blame]

// Copyright 2021 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 "gpu/ipc/common/mailbox_holder.mojom";
import "gpu/ipc/common/exported_shared_image.mojom";
import "gpu/ipc/common/sync_token.mojom";
import "media/capture/mojom/video_capture_types.mojom";
import "media/mojo/mojom/media_types.mojom";
import "mojo/public/mojom/base/shared_memory.mojom";
import "mojo/public/mojom/base/time.mojom";
import "ui/gfx/geometry/mojom/geometry.mojom";
import "ui/gfx/mojom/buffer_types.mojom";
import "ui/gfx/mojom/color_space.mojom";

struct VideoFrameInfo {
  mojo_base.mojom.TimeDelta timestamp;
  VideoFrameMetadata metadata;
  VideoCapturePixelFormat pixel_format;
  gfx.mojom.Size coded_size;
  gfx.mojom.Rect visible_rect;
  // Some buffer types may be preemtively mapped in the capturer.
  // In that case a shared memory region is passed to the consumer together
  // with a GMB handle, and this flag here is passed to notify the consumer
  // that the region has valid data.
  bool is_premapped;
  // Describes the color space in use for this video frame.
  gfx.mojom.ColorSpace color_space;
  // Optionally, stride information can be provided.
  // If not provided, it is assumed that frame data is tightly packed.
  PlaneStrides? strides;
};

// Represents a buffer that is ready for consumption. |buffer_id| has video
// capture data and |info| contains the associated VideoFrame constituent parts.
struct ReadyBuffer {
  int32 buffer_id;
  VideoFrameInfo info;
};

// Represents an ExportedSharedImage when used with GpuMemoryBufferHandle as
// part of VideoBufferHandle.
struct SharedImageBufferHandleSet {
  gpu.mojom.ExportedSharedImage shared_image;
  gpu.mojom.SyncToken sync_token;
};

union VideoBufferHandle {
  // TODO(crbug.com/40222341): It is extremely confusing that this union
  // has both an unsafe and a read-only shmem region subtype. This is probably
  // a sign that this union needs better documentation or to be split apart
  // into more distinct types.
  mojo_base.mojom.UnsafeSharedMemoryRegion unsafe_shmem_region;
  mojo_base.mojom.ReadOnlySharedMemoryRegion read_only_shmem_region;
  SharedImageBufferHandleSet shared_image_handle;
  gfx.mojom.GpuMemoryBufferHandle gpu_memory_buffer_handle;
};