// %BANNER_BEGIN% // --------------------------------------------------------------------- // %COPYRIGHT_BEGIN% // Copyright (c) (2018-2022) Magic Leap, Inc. All Rights Reserved. // Use of this file is governed by the Software License Agreement, located here: https://www.magicleap.com/software-license-agreement-ml2 // Terms and conditions applicable to third-party materials accompanying this distribution may also be found in the top-level NOTICE file appearing herein. // %COPYRIGHT_END% // --------------------------------------------------------------------- // %BANNER_END% namespace UnityEngine.XR.MagicLeap { using System; /// /// MLWebRTC class contains the API to interface with the /// WebRTC C API. /// public partial class MLWebRTC { /// /// Class that represents a video sink used by the MLWebRTC API. /// Video sinks are fed data by media sources and produces frames to render. /// public partial class VideoSink { /// /// Struct representing a captured camera frame. /// public partial struct Frame { /// /// Struct representing an image plane that comes from some captured camera frame. /// public struct PlaneInfo { /// /// Max amount of image planes that can be in a single frame. /// public const int MaxImagePlanes = 3; /// /// Gets the width of the image plane. /// public uint Width { get; private set; } /// /// Gets the height of the image plane. /// public uint Height { get; private set; } /// /// Gets the stride of the image plane, representing how many bytes one row of the image plane contains. /// public uint Stride { get; private set; } /// /// Gets the bytes per pixel of the image plane. /// public uint BytesPerPixel { get; private set; } /// /// Gets the size of the image plane, representing how many bytes in total the entire image plane contains. /// public uint Size { get; private set; } /// /// Gets the pointer to the unmanaged memory where the actual image data is found. /// public IntPtr DataPtr { get; private set; } /// /// Creates and returns an initialized version of this struct. /// /// Width of the image plane. /// Height of the image plane. /// Stride of the image plane. /// Bytes per pixel of the image plane. /// Size of the image plane. /// Pointer to the image data for the image plane. /// An initialized version of this struct. public static PlaneInfo Create(uint width, uint height, uint stride, uint bytesPerPixel, uint size, IntPtr dataPtr) { PlaneInfo imagePlane = new PlaneInfo() { Width = width, Height = height, Stride = stride, BytesPerPixel = bytesPerPixel, Size = size, DataPtr = dataPtr }; return imagePlane; } /// /// Override to display the contents of a image plane as a string. /// /// A string representation of this struct. public override string ToString() => $"\nWidth: {this.Width} pixels, \nHeight: {this.Height} pixels, \nBytes Per Pixel:{this.BytesPerPixel} bytes, \nStride: {this.Stride} bytes per row, \nSize: {this.Size} total bytes"; } public struct NativeBufferInfo { public uint Width { get; set; } public uint Height { get; set; } public float[] Transform { get; set; } public ulong SurfaceHandle { get; set; } public ulong NativeBufferHandle { get; set; } internal static NativeBufferInfo Create(NativeBindings.MLWebRTCNativeFrameInfo nativeFrameInfo) { NativeBufferInfo nativeBufferInfo = new NativeBufferInfo() { Width = nativeFrameInfo.Width, Height = nativeFrameInfo.Height, Transform = nativeFrameInfo.Transform, SurfaceHandle = nativeFrameInfo.SurfaceHandle, NativeBufferHandle = nativeFrameInfo.NativeBufferHandle }; return nativeBufferInfo; } public override string ToString() => $"\nWidth: {this.Width} pixels, \nHeight: {this.Height} pixels, \nSurfaceHandle:{this.SurfaceHandle}, \nNativeBufferHandle: {this.NativeBufferHandle}"; } } } } }