// %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.Runtime.InteropServices; using UnityEngine.XR.MagicLeap.Native; /// /// 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 { /// /// Native bindings for the MLWebRTC.VideoSink class. /// internal class NativeBindings : MagicLeapNativeBindings { /// /// Creates a video sink. /// /// The handle to the video sink to return to the caller. /// /// MLResult.Result will be MLResult.Code.Ok if the video sink was successfully created. /// MLResult.Result will be MLResult.Code.PermissionDenied if necessary permission is missing. /// MLResult.Result will be MLResult.Code.UnspecifiedFailure if failed due to other internal error. /// [DllImport(MLWebRTCDLL, CallingConvention = CallingConvention.Cdecl)] public static extern MLResult.Code MLWebRTCVideoSinkCreate(out ulong sinkHandle); /// /// Sets the source of a video sink. /// /// The handle to the video sink to set the source to. /// The handle to the source to set onto the video sink. /// /// MLResult.Result will be MLResult.Code.Ok if the source was successfully set onto the video sink. /// MLResult.Result will be MLResult.Code.PermissionDenied if necessary permission is missing. /// MLResult.Result will be MLResult.Code.UnspecifiedFailure if failed due to other internal error. /// [DllImport(MLWebRTCDLL, CallingConvention = CallingConvention.Cdecl)] public static extern MLResult.Code MLWebRTCVideoSinkSetSource(ulong sinkHandle, ulong sourceHandle); /// /// Gets if a new frame is available for a video sink. /// /// The handle to the video sink to check a new frame for. /// Used to return to the caller if a new frame is available. /// /// MLResult.Result will be MLResult.Code.Ok if the video sink was successfully queried. /// MLResult.Result will be MLResult.Code.PermissionDenied if necessary permission is missing. /// MLResult.Result will be MLResult.Code.UnspecifiedFailure if failed due to other internal error. /// [DllImport(MLWebRTCDLL, CallingConvention = CallingConvention.Cdecl)] public static extern MLResult.Code MLWebRTCVideoSinkIsNewFrameAvailable(ulong sinkHandle, [MarshalAs(UnmanagedType.I1)] out bool newFrameAvailable); /// /// Gets a newly available frame from a video sink. /// /// The handle to the video sink to get a new frame from. /// The handle to the new frame. /// /// MLResult.Result will be MLResult.Code.Ok if the new frame was successfully acquired. /// MLResult.Result will be MLResult.Code.PermissionDenied if necessary permission is missing. /// MLResult.Result will be MLResult.Code.UnspecifiedFailure if failed due to other internal error. /// [DllImport(MLWebRTCDLL, CallingConvention = CallingConvention.Cdecl)] public static extern MLResult.Code MLWebRTCVideoSinkAcquireNextAvailableFrame(ulong sinkHandle, out ulong frameHandle); /// /// Releases a frame from a video sink. /// /// The handle to the video sink to release the frame from. /// The handle to the frame to release. /// /// MLResult.Result will be MLResult.Code.Ok if the frame was successfully released. /// MLResult.Result will be MLResult.Code.PermissionDenied if necessary permission is missing. /// MLResult.Result will be MLResult.Code.UnspecifiedFailure if failed due to other internal error. /// [DllImport(MLWebRTCDLL, CallingConvention = CallingConvention.Cdecl)] public static extern MLResult.Code MLWebRTCVideoSinkReleaseFrame(ulong sinkHandle, ulong frameHandle); /// /// Destroys a video sink. /// /// The handle to the video sink to destroy. /// /// MLResult.Result will be MLResult.Code.Ok if the video sink was successfully destroyed. /// MLResult.Result will be MLResult.Code.PermissionDenied if necessary permission is missing. /// MLResult.Result will be MLResult.Code.UnspecifiedFailure if failed due to other internal error. /// [DllImport(MLWebRTCDLL, CallingConvention = CallingConvention.Cdecl)] public static extern MLResult.Code MLWebRTCVideoSinkDestroy(ulong sinkHandle); } } } }