using System; using System.Collections; using System.Collections.Generic; using System.IO; using System.Runtime.InteropServices; using System.Text; using UnityEngine; using GCSeries.Core; using F3Device.Device; namespace GCSeries.zView { public partial class GView : MonoBehaviour { ////////////////////////////////////////////////////////////////// // Events ////////////////////////////////////////////////////////////////// public delegate void EventHandler(GView sender, IntPtr connection); /// /// Event dispatched when a connection has been accepted. /// public event EventHandler ConnectionAccepted; /// /// Event dispatched when a connection has switched modes. /// public event EventHandler ConnectionModeSwitched; #pragma warning disable 0067 /// /// Event dispatched when a connection has transitioned /// to the ModeActive connection state. /// public event EventHandler ConnectionModeActive; /// /// Event dispatched when a connection has transitioned /// to the ModePaused connection state. /// public event EventHandler ConnectionModePaused; /// /// Event dispatched when a connection has been closed. /// public event EventHandler ConnectionClosed; /// /// Event dispatched when a connection error has occurred. /// public event EventHandler ConnectionError; /// /// Event dispatched when video recording has transitioned to /// an inactive state. /// public event EventHandler VideoRecordingInactive; /// /// Event dispatched when video recording has transitioned to /// an active recording state. /// public event EventHandler VideoRecordingActive; /// /// Event dispatched when video recording has finished. /// public event EventHandler VideoRecordingFinished; /// /// Event dispatched when video recording has paused. /// public event EventHandler VideoRecordingPaused; /// /// Event dispatched when a video recording error has occurred. /// public event EventHandler VideoRecordingError; /// /// Event dispatched when the video recording quality has changed. /// public event EventHandler VideoRecordingQualityChanged; ////////////////////////////////////////////////////////////////// // Enumerations ////////////////////////////////////////////////////////////////// /// /// Defines the types of zView nodes that can exist. /// public enum NodeType { Presenter = 0, Viewer = 1, } /// /// Defines the availability states for zView modes. /// public enum ModeAvailability { /// /// Mode is available. /// Available = 0, /// /// Mode is not available. /// NotAvailable = 1, /// /// Mode is not available because no webcam hardware is available. /// NotAvailableNoWebcam = 2, /// /// Mode is not available because necessary calibration has not been /// performed. /// NotAvailableNotCalibrated = 3, } /// /// Defines the optional capabilities that may be implemented by a zView /// node. /// public enum Capability { /// /// The node supports video recording via the video recording APIs. /// /// /// /// A zView connection will support this capability as long as the viewer /// node in the connection supports this capability. The presenter node /// need not support this capability. /// VideoRecording = 0, /// /// The node supports responding to requests to exit the application /// hosting the node when a zView connection is closed. /// /// /// /// For a zView node to support this capability, the application hosting /// the node must call GetConnectionCloseAction() whenever a zView /// connection enters the ConnectionState.Closed state and then exit /// if the close action is ConnectionCloseAction.ExitApplication. /// RemoteApplicationExit = 1, } /// /// Defines the keys for all mode and mode spec attributes. /// public enum ModeAttributeKey { /// /// The version of the mode. /// Datatype: UInt32. /// /// /// /// Different versions of a mode may function differently and may have /// different settings and frame data/buffers. /// Version = 0, /// /// The mode's compositing mode. /// Datatype: CompositingMode (get/set as UInt32). /// /// /// /// This indicates how the viewer node should composite the images it /// receives from the presenter node. /// CompositingMode = 1, /// /// The mode's presenter camera mode. /// Datatype: CameraMode (get/set as UInt32). /// /// /// /// This indicates how the presenter node's camera should function when the /// mode is active. /// PresenterCameraMode = 2, /// /// The order of rows of pixels in images generated for the mode. /// Datatype: ImageRowOrder (get/set as UInt32). /// /// /// /// Any images generated by either the presenter or viewer node for the /// mode should have their rows of pixels in this order. /// ImageRowOrder = 3, /// /// The format of pixels in color images generated for the mode. /// Datatype: PixelFormat (get/set as UInt32). /// /// /// /// Any color images generated by either the presenter or viewer node for /// the mode should use this pixel format. The pixel format specifies the /// number, type, order, and size of the channels in a pixel. /// ColorImagePixelFormat = 4, } /// /// Defines the possible zView mode compositing modes. /// /// /// /// This specifies the valid values that can be used to set the /// ModeAttributeKey.CompositingMode mode/mode spec attribute. /// public enum CompositingMode { /// /// No compositing will be performed. /// None = 0, /// /// Images will be composited on top of images from an augmented /// reality camera video stream. /// AugmentedRealityCamera = 1, } /// /// Defines the possible zView mode camera modes. /// /// /// /// This currently specifies the valid values that can be used to set the /// ModeAttributeKey.PresenterCameraMode mode/mode spec attribute. /// public enum CameraMode { /// /// The camera should have a fixed pose that never changes. /// Fixed = 0, /// /// The camera's pose should change according to head tracking /// information obtained on the local zView node. /// LocalHeadTracked = 1, /// /// The camera's pose should change according to information sent /// from the remote zView node. /// RemoteMovable = 2, } /// /// Defines the possible image pixel formats. /// /// /// /// This currently specifies the valid values that can be used to set the /// ModeAttributeKey.ColorImagePixelFormat mode/mode spec attribute. /// public enum PixelFormat { /// /// Pixel format with four 8-bit channels in the following order: /// red, green, blue, and alpha. /// R8G8B8A8 = 0, } /// /// Defines the possible orderings for pixel rows within images. /// /// /// /// This currently specifies the valid values that can be used to set the /// ModeAttributeKey.ImageRowOrder mode/mode spec attribute. /// public enum ImageRowOrder { /// /// The top row of pixels occurs first in the image data and the /// remaining rows are ordered from top to bottom. /// TopToBottom = 0, /// /// The bottom row of pixels occurs first in the image data and the /// remaining rows are ordered from bottom to top. /// BottomToTop = 1, } /// /// Defines the possible zView connection states. /// public enum ConnectionState { /// /// The connection is initializing. /// /// /// /// In this state, client code should not perform any zView operations /// using the connection. /// /// The connection will automatically transition to the /// AwaitingConnectionAcceptance state when it has /// finished initializing. /// ConnectionInitialization = 0, /// /// The connection is waiting to be locally accepted or rejected. /// /// /// /// If the connection is accepted, it will transition to the /// SwitchingModes state. If the connection is rejected, it will /// transition to the Closed state. /// AwaitingConnectionAcceptance = 1, /// /// The connection is internally switching between zView modes. /// /// /// /// In this state, client code is not required to perform any zView /// operations using the connection. /// /// The connection will automatically transition to the NoMode state (if /// a switch to the NULL mode was requested) or to the ModeSetup state /// (if a switch a non-NULL mode was requested) when it has finished switching /// modes internally. /// SwitchingModes = 2, /// /// The connection is not currently in any zView mode. /// /// /// /// In this state, client code is not required to perform any zView /// operations using the connection. /// /// The connection can be switched into a mode by calling /// SetConnectionMode(). /// NoMode = 3, /// /// The connection is setting up the current zView mode. /// /// /// /// The connection will transition to the ModeActive state once all /// mode setup phases for the current mode have been completed by both /// the local and remote nodes. /// ModeSetup = 4, /// /// The connection's current zView mode is active. /// /// /// /// In this state, client code should be sending frames to and/or receiving /// frames from the remote zView node. /// /// The connection's current zView mode can be paused by calling PauseMode(). /// This will transition the connection into the ModePaused state. /// ModeActive = 5, /// /// The connection's current zView mode is paused. /// /// /// /// In this state, client code should not be sending frames to nor /// receiving frames from the remote zView node. Client code is not /// required to perform any zView operations while the connection is in /// this state. /// /// The connection's current zView mode can be resumed by calling /// ResumeMode(). This will transition the connection into the /// ModeResuming state. /// ModePaused = 6, /// /// The connection's current zView mode is resuming. /// /// /// /// The connection will automatically transition to the ModeActive state /// or to the ModeSetup state when it has finished resuming the current mode. /// The ModeSetup state is only transitioned to if there changes have been /// made to mode-specific settings (while the mode was paused) that require /// one or more mode setup phases to be rerun. /// ModeResuming = 7, /// /// The connection is internally processing a change to a /// mode-specific setting that will require one or more mode setup phases /// to be rerun. /// /// /// /// The connection will automatically transition to the ModeSetup state when it /// has finished internally processing the mode-specific settings change. /// ProcessingModeSettingsChange = 8, /// /// The connection is closed and should be cleaned up and destroyed. /// /// /// /// In this state, client code may call GetConnectionCloseReason() to /// determine why the connection was closed. /// /// In this state client code may call GetConnectionCloseAction() and /// then optionally perform the requested action. /// Closed = 9, /// /// An error has occurred and the connection is no longer usable. /// /// /// /// In this state, client code may call GetConnectionError() to /// determine the type of error that occurred. /// Error = 10, } /// /// Defines the possible zView connection close actions. /// /// /// /// When closing a connection by calling CloseConnection(), one of these /// actions must be specified as the action that the remote zView node should /// take after the connection is closed. /// /// Once a connection enters the ConnectionState.Closed state, the close /// action for the connection can be queried by calling GetConnectionCloseAction(). /// public enum ConnectionCloseAction { /// /// The application hosting the zView node should not perform any /// additional action after the connection is closed. /// None = 0, /// /// The application hosting the zView node should exit after the /// connection is closed. /// /// /// /// zView nodes may not perform this action is they do not support the /// Capability.RemoteApplicationExit capability. /// ExitApplication = 1, } /// /// Defines the possible reasons why a zView connection was closed. /// /// /// /// When closing a connection by calling CloseConnection(), one of these /// reasons must be specified to indicate why the connection is being closed. /// /// Once a connection enters the ConnectionState.Closed state, the close /// reason for the connection can be queried by calling /// GetConnectionCloseReason(). /// public enum ConnectionCloseReason { /// /// The connection was closed for an unknown reason. /// Unknown = 0, /// /// The connection was closed because the remote zView node's zView /// API context was shut down. /// ShutDown = 1, /// /// The connection was closed because a user requested it to be /// closed. /// UserRequested = 2, /// /// The connection was closed because is was rejected by one of the /// zView nodes involved in the connection. /// ConnectionRejected = 3, } /// /// Defines the possible phases that the setup of a zView mode can go /// through. /// /// /// /// In this version of the zView API, all modes use all of the mode setup /// phases defined by this enum. However, future versions of the zView API may /// introduce mode setup phases that are only used by some modes. /// public enum ModeSetupPhase { /// /// Mode setup is initializing. /// /// /// /// When in this mode setup phase, client code must set any settings that /// the remote node will need to complete mode setup. Exactly which /// settings must be set depends on the current mode. Client code may also /// begin performing other setup tasks related to the current mode during /// this setup phase (e.g. client code might begin creating or loading /// resources needed for the current mode). /// Initialization = 0, /// /// Mode setup is completing. /// /// /// /// When in this mode setup phase, client code must finish any setup that /// is necessary prior to the current mode becoming active. Exactly what /// setup must be performed depends on the current mode. /// Completion = 1, } /// /// Defines the possible states that a connection setting can be in. /// /// /// /// A setting's state can be queried by calling GetSettingState(). /// public enum SettingState { /// /// Setting's value is up to date. /// UpToDate = 0, /// /// Setting's value was changed during the most recent call to /// LateUpdate(). State will transition to UpToDate on the next /// frame's LateUpdate(). /// Changed = 1, /// /// Setting's value was changed locally, but the change has not /// yet been accepted by the other side of the connection. /// ChangePending = 2, } /// /// Defines the keys for all possible zView connection settings. /// public enum SettingKey { /// /// The width, in pixels, of the primary images for the connection's /// current mode. /// Datatype: UInt16. /// /// /// /// In standard mode family modes, this should be set by the presenter node /// during the ModeSetupPhase.Initialization mode setup phase. In /// augmented reality mode family modes, this should be set by the viewer /// node during the ModeSetupPhase.Initialization mode setup phase. /// /// If this setting is set after the ModeSetupPhase.Initialization /// mode setup phase (i.e. in a later mode setup phase or while the mode is /// active or paused), then the connection will automatically transition /// back to the ConnectionState.ModeSetup state in the /// ModeSetupPhase.Completion mode setup phase in order to allow /// both nodes to take into account the new setting value (e.g. by /// reallocating image buffers to use the new width). /// /// This setting should generally be set in a batch (by calling /// BeginSettingsBatch() and EndSettingsBatch()) with the the /// ImageHeight setting. Doing this ensures that remote /// nodes will see image width and height changes at the same time (instead /// of possibly seeing one of these settings change during one frame and /// then the other change in the next frame). /// ImageWidth = 0, /// /// The height, in pixels, of the primary images for the connection's current mode. /// Datatype: UInt16. /// /// /// /// In standard mode family modes, this should be set by the presenter node /// during the ModeSetupPhase.Initialization mode setup phase. In /// augmented reality mode family modes, this should be set by the viewer /// node during the ::ModeSetupPhase.Initialization mode setup phase. /// /// If this setting is set after the ModeSetupPhase.Initialization /// mode setup phase (i.e. in a later mode setup phase or while the mode is /// active or paused), then the connection will automatically transition /// back to the ConnectionState.ModeSetup state in the /// ModeSetupPhase.Completion mode setup phase in order to allow /// both nodes to take into account the new setting value (e.g. by /// reallocating image buffers to use the new height). /// /// This setting should generally be set in a batch (by calling /// BeginSettingsBatch() and EndSettingsBatch()) with the the /// ImageWidth setting. Doing this ensures that remote /// nodes will see image width and height changes at the same time (instead /// of possibly seeing one of these settings change during one frame and /// then the other change in the next frame). /// ImageHeight = 1, /// /// The connection's current video recording quality. /// Datatype: VideoRecordingQuality (get/set as UInt32). /// /// /// /// This setting may only be set if the connection's video recording state /// is currently VideoRecordingState.NotRecording. /// /// Whenever a video recording is started, the current value of this /// setting is used as the quality level for the new video recording. /// VideoRecordingQuality = 2, /// /// The current horizontal offset, in pixels, of the primary image /// overlay displayed by the viewer node (default 0.0f). /// Datatype: float. /// /// /// /// This is only available for augmented reality mode family modes. For /// these modes the viewer node will use this value to offset the position /// of the presenter's color images from the augmented reality mode camera /// video stream images when the two are composited. /// OverlayOffsetX = 3, /// /// The current vertical offset, in pixels, of the primary image /// overlay displayed by the viewer node (default 0.0f). /// Datatype: float. /// /// /// /// This is only available for augmented reality mode family modes. For /// these modes the viewer node will use this value to offset the position /// of the presenter's color images from the augmented reality mode camera /// video stream images when the two are composited. /// OverlayOffsetY = 4, /// /// The current horizontal scale factor for the primary image /// overlay displayed by the viewer node (default 1.0f). /// Datatype: float. /// /// /// /// This is only available for augmented reality mode family modes. For /// these modes the viewer node will use this value to scale the /// presenter's color images before they are composited with the augmented /// reality mode camera video stream images. /// OverlayScaleX = 5, /// /// The current vertical scale factor for the primary image overlay /// displayed by the viewer node (default 1.0f). /// Datatype: float. /// /// /// /// This is only available for augmented reality mode family modes. For /// these modes the viewer node will use this value to scale the /// presenter's color images before they are composited with the augmented /// reality mode camera video stream images. /// OverlayScaleY = 6, } /// /// Defines the possible streams that may be used by a zView mode for /// sending frame data between the nodes involved in a zView connection. /// public enum Stream { /// /// Stream used sending the primary image data between nodes for a /// mode. May also be used to send metadata related to the images being /// sent or data necessary for generating images to be sent. /// Image = 0, } /// /// Defines the keys for all possible pieces of frame data for a zView /// mode. /// public enum FrameDataKey { /// /// The frame's frame number. /// Datatype: UInt64. /// /// /// /// This is used for Stream.Image frames in both standard mode family /// and augmented reality mode family modes. /// FrameNumber = 0, /// /// The camera pose matrix (position and orientation) to use for rendering the current /// mode's primary images. /// Datatype: Matrix4x4. /// /// /// /// This is only used for Stream.Image frames sent from the viewer /// node to the presenter node in augmented reality mode family modes. /// CameraPose = 1, /// /// The camera focal length to use for rendering the current mode's /// primary images. /// Datatype: float. /// /// /// /// This is only used for Stream.Image frames sent from the viewer /// node to the presenter node in augmented reality mode family modes. /// CameraFocalLength = 2, /// /// The horizontal offset of the camera's principal point to use for /// rendering the current mode's primary images. /// Datatype: float. /// /// /// /// This is only used for Stream.Image frames sent from the viewer /// node to the presenter node in augmented reality mode family modes. /// CameraPrincipalPointOffsetX = 3, /// /// The vertical offset of the camera's principal point to use for /// rendering the current mode's primary images. /// Datatype: float. /// /// /// /// This is only used for Stream.Image frames sent from the viewer /// node to the presenter node in augmented reality mode family modes. /// CameraPrincipalPointOffsetY = 4, /// /// The camera pixel aspect ratio to use for rendering the current /// mode's primary images. /// Datatype: float. /// /// /// /// This is only used for Stream.Image frames sent from the viewer /// node to the presenter node in augmented reality mode family modes. /// CameraPixelAspectRatio = 5, /// /// The camera axis skew to use for rendering the current mode's /// primary images. /// Datatype: float. /// /// /// /// This is only used for Stream.Image frames sent from the viewer /// node to the presenter node in augmented reality mode family modes. /// CameraAxisSkew = 6, } /// /// Defines the keys for all possible frame buffers for a zView mode. /// public enum FrameBufferKey { /// /// Frame buffer for storing the first color image associated with a /// zView mode. /// ImageColor0 = 0, } /// /// Defines the possible zView connection video recording states. /// /// /// /// A connection's current video recording state can be queried by calling /// GetVideoRecordingState(). /// public enum VideoRecordingState { /// /// Video recording capability is not currently available and cannot be used. /// /// /// /// A connection's video recording state will automatically transition from /// this state to the NotRecording state if the connection supports the /// Capability.VideoRecording capability. This transition will occur once the /// connection is fully initialized. /// NotAvailable = 0, /// /// Not actively recording and no current recording exists. /// /// /// /// A video recording can be started by calling StartVideoRecording(). /// This will transition the video recording state to the Starting state. /// NotRecording = 1, /// /// Video recording is in the process of starting. /// /// /// /// A connection's video recording state will automatically transition from /// this state to the Recording state once video recording has fully started. /// Starting = 2, /// /// Acively recording. /// /// /// /// Recording can be finished by calling FinishVideoRecording(), which will /// transition the video recording state to the Finishing state. Recording /// can be paused by calling PauseVideoRecording(), which will transition the /// video recording state to the Pausing state. /// Recording = 3, /// /// Video recording is in the process of finishing. /// /// /// /// A connection's video recording state will automatically transition /// fromthis state to the Finished state once video recording has completed /// finishing. /// Finishing = 4, /// /// Not actively recording; current finished recording exists. /// /// /// /// The finished recording can be saved by calling SaveVideoRecording(), /// which will transition the video recording state to the Saving state. /// The finished recording can be discarded by calling DiscardVideoRecording(), /// which will transition the video recording state to the Discarding state. /// Finished = 5, /// /// Video recording is in the process of pausing. /// /// /// /// A connection's video recording state will automatically transition from /// this state to the Paused state once video recording has completed pausing. /// Pausing = 6, /// /// Not actively recording; current resumable recording exists. /// /// /// /// Recording can be resumed by calling ResumeVideoRecording(), which /// will transition the video recording state to the Resuming state. /// Recording can be finished by calling FinishVideoRecording(), which /// will transition the video recording state to the Finishing state. /// Paused = 7, /// /// Video recording is in the process of resuming. /// /// /// /// A connection's video recording state will automatically transition from /// this state to the Recording state once video recording has completed resuming. /// Resuming = 8, /// /// The current finished video recording is in the process of being /// saved. /// /// /// /// A connection's video recording state will automatically transition from /// this state to the NotRecording state once saving is complete. /// Saving = 9, /// /// The current finished video recording is in the process of being /// discarded. /// /// /// /// A connection's video recording state will automatically transition from /// this state to the NotRecording state once discarding is complete. /// Discarding = 10, /// /// A recoverable video-recording-related error occurred. /// /// /// /// In this state, client code should call ClearVideoRecordingError() to /// clear the error and allow new video recordings to be started. This /// will transition the video recording state to the ClearingError state. /// /// In this state, client code may call GetVideoRecordingError() to /// determine the type of error that occurred. /// Error = 11, /// /// The most recent video recording error is in the process of being /// cleared. /// /// /// /// A connection's video recording state will automatically transition from /// this state to the NotRecording state once clearing of the video recording /// error is complete. /// ClearingError = 12, } /// /// Defines the possible video recording quality levels. /// public enum VideoRecordingQuality { Unknown = -1, /// /// Video recording with 854 x 480 pixel resolution. /// Resolution480p = 0, /// /// Video recording with 1280 x 720 pixel resolution. /// Resolution720p = 1, /// /// Video recording with 1920 x 1080 pixel resolution. /// Resolution1080p = 2, } ////////////////////////////////////////////////////////////////// // Compound Types ////////////////////////////////////////////////////////////////// /// /// Class representing a mode that is supported by a zView node along /// with the current availability of that mode. /// public class SupportedMode { /// /// The handle of the mode that is supported. /// public IntPtr Mode { get; private set; } /// /// The supported mode's current availability. /// public ModeAvailability ModeAvailability { get; private set; } public SupportedMode(IntPtr mode, ModeAvailability modeAvailability) { this.Mode = mode; this.ModeAvailability = modeAvailability; } } ////////////////////////////////////////////////////////////////// // Unity Inspector Fields ////////////////////////////////////////////////////////////////// /// /// Layers to be ignored by the standard mode's default /// virtual camera. /// public LayerMask StandardModeIgnoreLayers; /// /// Layers to be ignored by the augmented reality mode's /// default virtual camera. /// public LayerMask ARModeIgnoreLayers = 0; /// /// Layers to cull out by the augmented reality mode's /// default virtual camera if geometry protrudes into /// negative parallax outside the bounds of the viewport. /// public LayerMask ARModeEnvironmentLayers = 0; /// /// Layer (0 - 31) to be assigned to the augmented reality mode's /// box mask. This layer must be unique and should not be used for /// any objects in the scene other than the box mask. /// public int ARModeMaskLayer = 31; /// /// The render queue priority for the augmented reality mode's /// box mask. This is only used when ARModeEnableTransparency /// is enabled and should generally be assigned values less than /// 2000 (opaque geometry) to ensure that its depth will be rendered /// prior to rendering any opaque geometry. /// public int ARModeMaskRenderQueue = 1900; /// /// The size of the augmented reality mode's box mask in meters. /// public Vector3 ARModeMaskSize = Vector3.one * 2.0f; /// /// Enables debug visualization for the augmented reality mode's /// box mask in the Unity Editor's SceneView window. /// public bool ARModeShowMask = false; /// /// If not enabled, force all non-mask pixels rendered by the augmented /// reality mode's virtual camera to have an alpha value of 1. By default, /// this is disabled due to the fact that most standard shaders associated /// with both opaque and transparent geometry either have incorrect values /// in their alpha channels, or do not write their alpha channels to the /// frame buffer. /// public bool ARModeEnableTransparency = false; /// /// ZView requires a reference to the active ZCamera. ZView will try /// to find an instance of ZCamera on awake if left unassigned. If the /// ZCamera is destroyed during the life of the current scene, this /// value must be assigned manually. /// public ZCamera ActiveZCamera = null; ////////////////////////////////////////////////////////////////// // Public API ////////////////////////////////////////////////////////////////// /// /// Checks whether the GCSeries zView SDK was properly initialized. /// /// /// /// True if initialized. False otherwise. /// public bool IsInitialized() { return GlobalState.Instance.IsInitialized; } /// /// Gets the current version of the GCSeries zView Unity plugin. /// /// /// /// The plugin version in major.minor.patch string format. /// public string GetPluginVersion() { int major = 0; int minor = 0; int patch = 1; return string.Format("{0}.{1}.{2}", major, minor, patch); } /// /// Gets the current runtime version of the GCSeries zView SDK. /// /// /// /// The runtime version in major.minor.patch string format. /// public string GetRuntimeVersion() { int major = 0; int minor = 0; int patch = 1; return string.Format("{0}.{1}.{2}", major, minor, patch); } /// /// Get the node type of the current context. /// /// /// /// The node type of the current context. /// public NodeType GetNodeType() { NodeType type = NodeType.Presenter; return type; } /// /// Get the node ID of the current context. /// /// /// /// The byte buffer to fill with the node ID of the current context. /// public byte[] GetNodeId() { // Get the node id's size in bytes. int size = 4; byte[] id = new byte[size]; Array.Clear(id, 0, size); Debug.LogWarning("GView.GetNodeId():这个函数目前不使用!"); return id; } /// /// Get the node name string associated with the current context. /// /// /// /// The node name string associated with the current context. /// public string GetNodeName() { Debug.LogWarning("GView.GetNodeName():这个函数目前不使用!"); return "UnmannedNode"; } /// /// Set the node name string associated with the current context. /// /// /// /// The new node name to use. /// public void SetNodeName(string name) { Debug.LogWarning("GView.SetNodeName():这个函数目前不使用!name=" + name); } /// /// Get the node status string associated with the current context. /// /// /// /// The node status string associated with the current context. /// public string GetNodeStatus() { Debug.LogWarning("GView.GetNodeStatus():这个函数目前不使用!"); return "OK"; } /// /// Set the node status string associated with the current context. /// /// /// /// The new node status to use. /// public void SetNodeStatus(string status) { Debug.LogWarning("GView.SetNodeStatus():这个函数目前不使用!"); } /// /// Get the number of modes supported by the current context. /// /// /// /// The number of modes supported by the current context. /// public int GetNumSupportedModes() { Debug.LogWarning("GView.GetNumSupportedModes():这个函数目前不使用!"); int numModes = 0; numModes = 1; return numModes; } /// /// Get a supported mode from the list of supported modes for the /// current context. /// /// /// /// The index of the supported mode to get. This must be /// greater than or equal to 0 and less than the number of /// supported modes queried via GetNumSupportedModes(). /// /// /// /// The requested supported mode. /// /// /// /// Thrown if the mode index is out of range. /// public SupportedMode GetSupportedMode(int modeIndex) { Debug.LogWarning("GView.GetSupportedMode():这个函数目前不使用!"); return null; } /// /// Set the modes supported by the current context. /// /// /// /// The list of supported modes. /// /// /// /// Thrown if any supported mode references an invalid mode. /// public void SetSupportedModes(IList modes) { Debug.LogWarning("GView.SetSupportedModes():这个函数目前不使用!"); } /// /// Get the number of capabilities supported by the current context. /// /// /// /// The number of capabilities supported by the current context. /// public int GetNumSupportedCapabilities() { Debug.LogWarning("GView.GetNumSupportedCapabilities():这个函数目前不使用!"); int numCapabilities = 0; return numCapabilities; } /// /// Get a supported capability from the list of supported capabilities for /// the current context. /// /// /// /// The index of the supported capability to get. This must be greater than /// or equal to 0 and less than the number of supported capabilities queried /// via GetNumSupportedCapabilities(). /// /// /// /// The requested supported capability. /// /// /// /// Thrown if the capability index is out of range. /// public Capability GetSupportedCapability(int capabilityIndex) { Debug.LogWarning("GView.GetSupportedCapability():这个函数目前不使用!"); Capability capability = Capability.VideoRecording; return capability; } /// /// Get the value of the specified mode attribute of type UInt32 for the /// specified mode. /// /// /// /// The mode to get the attribute value of. /// /// /// The mode attribute key to get the value of. /// /// /// /// The value associated with specified mode and mode attribute key. /// /// /// /// Thrown if the mode is null (IntPtr.Zero). /// /// /// Thrown if the mode is invalid. /// /// /// Thrown if the mode attribute key is invalid. /// public UInt32 GetModeAttributeUInt32(IntPtr mode, ModeAttributeKey key) { Debug.LogWarning("GView.GetModeAttributeUInt32():这个函数目前不使用!"); UInt32 value = 0; return value; } /// /// Connect to the default viewer using the current context. /// /// /// /// This method performs its work asynchronously. Once a connection /// to the default viewer is created, it will be accessible via /// GetConnection() or GetCurrentActiveConnection() after the next /// LateUpdate(). /// public void ConnectToDefaultViewer() { Debug.Log("GView.ConnectToDefaultViewer():进入!"); IntPtr connection; xxConnectToDefaultViewer(out connection); //因为我们永远连接成功.所以直接赋值 GlobalState.Instance.Connection = connection; //这里是否需要进入一个模式呢? //因为永远是连上的,所以这里发个事件算了 if (this.ConnectionAccepted != null) { this.ConnectionAccepted(this, GlobalState.Instance.Connection); } } /// /// Close the specified connection. /// /// /// /// The close action will be queriable by the remote node /// once the connection has entered the Closed state. Note: The node /// that calls this function for a connection will not be able to query /// the action it specifies via GetConnectionCloseAction(), since the /// action is meant for the remote node. Instead, GetConnectionCloseAction() /// will always return None when called by the node that called this /// method. /// /// /// /// The connection to close. /// /// /// The action that should be performed by the remote node after the /// connection is closed. /// /// /// The reason why the connection is being closed. This will be queriable /// via the GetConnectionCloseReason() function once the connection has /// entered the Closed state. /// /// /// Additional details on the reason why the connection is being closed. /// This is purely for logging purposes and will not be displayed to the /// user. /// /// /// /// Thrown if the connection is null (IntPtr.Zero). /// /// /// Thrown if the connection is invalid. /// /// /// Thrown if the connection is already in a Closed or Error state. /// public void CloseConnection(IntPtr connection, ConnectionCloseAction action, ConnectionCloseReason reason, string reasonDetails) { Debug.Log("GView.CloseConnection():进入!"); CurVirtualCameraMode = IntPtr.Zero; GlobalState.Instance.Connection = IntPtr.Zero;//这里关闭了 } /// /// Get the number of currently visible connections for the current context. /// /// /// /// The number of currently visible connections will change over the lifetime /// of a context. However, the number connections queried by this function /// will only change during LateUpdate() (i.e. the value will remain /// stable between calls to LateUpdate()). /// /// /// /// The number of visible connections for the specified context. /// public int GetNumConnections() { if (GlobalState.Instance.Connection == IntPtr.Zero) { return 0; } else { return 1; } } /// /// Get a connection from the list of currently visible connections for the /// current context. /// /// /// /// The list of currently visible connections will change over the lifetime of /// a context. However, the list of connections that is accessible via this /// function will only change during LateUpdate() (i.e. the list will /// remain stable between calls to LateUpdate()). /// /// /// /// The index of the connection to get. This must be greater than or equal /// to 0 and less than the number of connections queried via GetNumConnections(). /// /// /// /// The requested connection. /// /// /// /// Thrown if the connection index is out of range. /// public IntPtr GetConnection(int connectionIndex) { return GlobalState.Instance.Connection; } /// /// Get the current active connection if it exists. /// /// /// /// The current active connection if it exists. Otherwise IntPtr.Zero. /// public IntPtr GetCurrentActiveConnection() { return GlobalState.Instance.Connection; } /// /// Get the state of the specified connection. /// /// /// /// The state of a connection will change over the lifetime of the connection. /// However, the state queried via this function will only change during /// LateUpdate() (i.e. the state will remain stable between calls to LateUpdate()). /// /// /// /// The connection to get the state of. /// /// /// /// The state of the specified connection. /// /// /// /// Thrown if the connection is null (IntPtr.Zero). /// /// /// Thrown if the connection is invalid. /// public ConnectionState GetConnectionState(IntPtr connection) { return ConnectionState.ModeActive; } /// /// Get the error code associated with the specified connection. /// /// /// /// It is only valid to query the error code associated with a connection when it /// is in the Error state (i.e. through callbacks registered against the /// ConnectionError event). /// /// /// /// The connection to get the error code of. /// /// /// /// The error code associated with the specified connection. /// /// /// /// Thrown if the connection is null (IntPtr.Zero). /// /// /// Thrown if the connection is invalid. /// /// /// Thrown if the connection is not in the Error state. /// public PluginError GetConnectionError(IntPtr connection) { Debug.LogWarning("GView.GetConnectionError():这个函数目前未实现!"); PluginError connectionError = PluginError.Ok; return connectionError; } /// /// Check whether the specified connection was initiated locally or remotely. /// /// /// /// The connection to check whether it was locally initiated. /// /// /// /// Whether the connection was locally initiated. /// /// /// /// Thrown if the connection is null (IntPtr.Zero). /// /// /// Thrown if the connection is invalid. /// public bool WasConnectionLocallyInitiated(IntPtr connection) { Debug.LogWarning("GView.WasConnectionLocallyInitiated():这个函数目前未实现!"); bool wasLocallyInitiated = false; return wasLocallyInitiated; } /// /// Gets the node ID of the remote node that the specified connection is /// connected to. /// /// /// /// The connection to get the remote node ID of. /// /// /// /// The byte buffer to fill with the node ID of the remote node that the /// specified connection is connected to. /// /// /// /// Thrown if the connection is null (IntPtr.Zero). /// /// /// Thrown if the connection is invalid. /// /// /// Thrown if the connection is in the Closed or Error state. /// public byte[] GetConnectedNodeId(IntPtr connection) { Debug.LogWarning("GView.GetConnectedNodeId():这个函数目前未实现!"); // Get the node id's size in bytes. int size = 4; byte[] id = new byte[size]; Array.Clear(id, 0, size); return id; } /// /// Gets the node name string of the remote node that the specified connection /// is connected to. /// /// /// /// The connection to get the remote node name of. /// /// /// /// The node name string of the remote node that the specified connection /// is connected to. /// /// /// /// Thrown if the connection is null (IntPtr.Zero). /// /// /// Thrown if the connection is invalid. /// /// /// Thrown if the connection is in the Closed or Error state. /// public string GetConnectedNodeName(IntPtr connection) { Debug.LogWarning("GView.GetConnectedNodeName():这个函数目前未实现!"); return "unnamed"; } /// /// Gets the node status string of the remote node that the specified /// connection is connected to. /// /// /// /// The connection to get the remote node status of. /// /// /// /// The node status string of the remote node that the specified /// connection is connected to. /// /// /// /// Thrown if the connection is null (IntPtr.Zero). /// /// /// Thrown if the connection is invalid. /// /// /// Thrown if the connection is in the Closed or Error state. /// public string GetConnectedNodeStatus(IntPtr connection) { Debug.LogWarning("GView.GetConnectedNodeStatus():这个函数目前未实现!"); return "OK"; } /// /// Check if the specified connection supports the specified capability. /// /// /// /// The connection to check the capability support of. /// /// /// The capability to check for support of. /// /// /// /// Whether the specified capability is supported by the specified /// connection or not. /// /// /// /// Thrown if the connection is null (IntPtr.Zero). /// /// /// Thrown if the connection is invalid. /// /// /// Thrown if the connection is in the Closed or Error state. /// public bool DoesConnectionSupportCapability(IntPtr connection, Capability capability) { if (capability == Capability.RemoteApplicationExit) { return false; } if (capability == Capability.VideoRecording) { bool isSupported = xxGetVideoRecordingCapability(); return isSupported; } return false; } /// /// Get the number of modes supported by the specified connection. /// /// /// /// The number of modes supported by a connection may change over the lifetime /// of the connection. However, the number of supported modes returned by this /// function will only change during LateUpdate() (i.e. the value will remain /// stable between calls to LateUpdate()). /// /// /// /// The connection to get the number of supported modes for. /// /// /// /// The number of modes supported by the specified connection. /// /// /// /// Thrown if the connection is null (IntPtr.Zero). /// /// /// Thrown if the connection is invalid. /// /// /// Thrown if the connection is in the Closed or Error state. /// public int GetNumConnectionSupportedModes(IntPtr connection) { if (connection != IntPtr.Zero && GlobalState.Instance.Connection == connection) return 3;//支持两个模式 return 0; } /// /// Get a supported mode and associated mode availability information from the /// list of modes supported by the specified connection. /// /// /// /// The list of modes supported by a connection may change over the lifetime of /// the connection. However, the list of supported modes accessible via this /// function will only change during LateUpdate() (i.e. the value will remain /// stable between calls to LateUpdate()). /// /// /// /// The connection to get a supported mode from. /// /// /// The index of the supported mode to get. This must be greater than or equal /// to 0 and less than the number of supported modes queried via the /// GetNumConnectionSupportedModes() function. /// /// /// /// The requested supported mode with associated mode availability information. /// /// /// /// Thrown if the connection is null (IntPtr.Zero) or the supported mode index /// is out of range. /// /// /// Thrown if the connection is invalid. /// /// /// Thrown if the connection is in the Closed or Error state. /// public SupportedMode GetConnectionSupportedMode(IntPtr connection, int supportedModeIndex) { //Debug.LogWarning("GView.GetConnectionSupportedMode():这个函数目前未实现!"); if (connection != IntPtr.Zero) { int screenNum = F3Device.DeviceManager.Instance.AllMonitors.Count; if (supportedModeIndex == 0) { if (screenNum < 2) { return new SupportedMode(GlobalState.Instance.ModeStandard, ModeAvailability.NotAvailable); } return new SupportedMode(GlobalState.Instance.ModeStandard, ModeAvailability.Available); } else if (supportedModeIndex == 1) { if (screenNum < 2) { return new SupportedMode(GlobalState.Instance.ModeThreeD, ModeAvailability.NotAvailable); } return new SupportedMode(GlobalState.Instance.ModeThreeD, ModeAvailability.Available); } else if (supportedModeIndex == 2) { if (screenNum < 2) { return new SupportedMode(GlobalState.Instance.ModeAugmentedReality, ModeAvailability.NotAvailable); } //如果有罗技相机那么返回可用 var devices = WebCamTexture.devices; foreach (var item in devices) { if (item.name.Contains("C920")) { return new SupportedMode(GlobalState.Instance.ModeAugmentedReality, ModeAvailability.Available); } } //如果没有罗技相机那么返回不可用 return new SupportedMode(GlobalState.Instance.ModeAugmentedReality, ModeAvailability.NotAvailableNoWebcam); } } return new SupportedMode(IntPtr.Zero, ModeAvailability.NotAvailable); } /// /// Get the standard mode handle. /// /// /// /// The standard mode handle. /// public IntPtr GetStandardMode() { return GlobalState.Instance.ModeStandard; } /// /// Get the 3D mode handle. /// /// /// /// The 3D mode handle. /// public IntPtr GetThreeDMode() { return GlobalState.Instance.ModeThreeD; } /// /// Get the augmented reality mode handle. /// /// /// /// The augmented reality mode. /// public IntPtr GetAugmentedRealityMode() { return GlobalState.Instance.ModeAugmentedReality; } /// /// Get the current mode of the specified connection. /// /// /// /// The current mode of a connection will change over the lifetime of the /// connection. However, the mode queried via this function will only change /// during LateUpdate() (i.e. the value will remain stable between calls to /// LateUpdate()). /// /// /// /// The connection to set the current mode of. /// /// /// /// The current mode of the specified connection. /// /// /// /// Thrown if the connection is null (IntPtr.Zero). /// /// /// Thrown if the connection is invalid. /// /// /// Thrown if the connection is in the Closed or Error state. /// public IntPtr GetConnectionMode(IntPtr connection) { return this.CurVirtualCameraMode; } /// /// Set the current mode of the specified connection. /// /// /// /// If the current mode of the specified connection is not equal to the mode /// specified when this function is called, then this function will initiate a /// mode switch (the actual mode switch will occur asynchronously and will only /// become visible after the next LateUpdate() is called). /// /// /// /// The connection to set the current mode of. /// /// /// The new mode to use as the current mode of the specified connection. /// Passing IntPtr.Zero for this argument makes it so that there is no current /// mode and transitions the connection into the NodeMode state. /// /// /// /// Thrown if the connection or the mode is null (IntPtr.Zero). Also thrown /// if the mode is not supported or not available. /// /// /// Thrown if the connection is invalid. /// /// /// Thrown if the mode is invalid. /// /// /// Thrown if the connection is in the Closed or Error state. /// public void SetConnectionMode(IntPtr connection, IntPtr mode) { Debug.Log("GView.SetConnectionMode():进入函数!"); if (connection != IntPtr.Zero) { CurVirtualCameraMode = mode; } } /// /// Get the user data associated with the specified connection. /// /// /// /// The connection to get the user data of. /// /// /// /// The user data of the specified connection. /// /// /// /// Thrown if the connection is null (IntPtr.Zero). /// /// /// Thrown if the connection is invalid. /// public IntPtr GetConnectionUserData(IntPtr connection) { Debug.LogWarning("GView.GetConnectionUserData():这个函数目前未实现!"); return IntPtr.Zero; } /// /// Set the user data associated with the specified connection. /// /// /// /// The connection to get the user data of. /// /// /// The user data of the specified connection. /// /// /// /// Thrown if the connection is null (IntPtr.Zero). /// /// /// Thrown if the connection is invalid. /// public void SetConnectionUserData(IntPtr connection, IntPtr userData) { Debug.LogWarning("GView.SetConnectionUserData():这个函数目前未实现!"); } /// /// Get the close action associated with the specified connection. /// /// /// /// The client code should perform this action if possible after a connection /// enters the Closed state. /// /// It is only valid to call this function for a connection that is in the /// Closed state or in a callback registered against the ConnectedClosed event. /// /// /// /// The connection to get the close action of. /// /// /// /// The close action of the specified connection. /// /// /// /// Thrown if the connection is null (IntPtr.Zero). /// /// /// Thrown if the connection is invalid. /// /// /// Thrown if the connection is not in the Closed state. /// public ConnectionCloseAction GetConnectionCloseAction(IntPtr connection) { Debug.LogWarning("GView.GetConnectionCloseAction():这个函数目前未实现!"); return ConnectionCloseAction.None; } /// /// Get the close reason associated with the specified connection. /// /// /// /// It is only valid to call this function for a connection that is in the /// Closed state or in a callback registered against the ConnectedClosed event. /// /// /// /// The connection to get the close reason of. /// /// /// /// The close reason of the specified connection. /// /// /// /// Thrown if the connection is null (IntPtr.Zero). /// /// /// Thrown if the connection is invalid. /// /// /// Thrown if the connection is not in the Closed state. /// public ConnectionCloseReason GetConnectionCloseReason(IntPtr connection) { Debug.LogWarning("GView.GetConnectionCloseReason():这个函数目前未实现!"); ConnectionCloseReason reason = ConnectionCloseReason.Unknown; return reason; } /// /// Request that current mode be paused for the specified connection. /// /// /// /// Pausing will occur asynchronously and eventually become visible after a /// call to LateUpdate(). /// /// It is only valid to call this function for a connection that is in the /// ModeActive state. /// /// /// /// The connection to pause frame sending for. /// /// /// /// Thrown if the connection is null (IntPtr.Zero). /// /// /// Thrown if the connection is invalid. /// /// /// Thrown if the connection is not in the ModeActive state. /// public void PauseMode(IntPtr connection) { Debug.LogWarning("GView.PauseMode():这个函数目前未实现!"); } /// /// Request that the current mode be resumed for the specified connection. /// /// /// /// Resuming will occur asynchronously and eventually become visible after a /// call to LateUpdate(). /// /// It is only valid to call this function for a connection that is in the /// ModePaused state. /// /// /// /// The connection to resume frame sending for. /// /// /// /// Thrown if the connection is null (IntPtr.Zero). /// /// /// Thrown if the connection is invalid. /// /// /// Thrown if the connection is not in the ModePaused state. /// public void ResumeMode(IntPtr connection) { Debug.LogWarning("GView.ResumeMode():这个函数目前未实现!"); } /// /// Begin a settings batch for the specified connection. /// /// /// /// While a settings batch is active for a connection, changes to setting /// values will not be sent over the connection until the settings batch is /// ended (via a call to EndSettingsBatch()). This allows multiple settings /// value changes to be sent as an atomic unit. This is necessary when a group /// of settings are interrelated and changing one setting in the group requires /// other settings in the group to also be changed in order to keep all /// settings in the group in a consistent state. /// /// At most one settings batch can be active at any time for a particular /// connection. Attempting to begin a settings batch for a connection when the /// connection already has an active settings batch will result in an error. /// /// /// /// The connection to begin a settings batch for. /// /// /// /// Thrown if the connection is null (IntPtr.Zero). /// /// /// Thrown if the connection is invalid. /// /// /// Thrown if the connection is in the Closed or Error state. /// public void BeginSettingsBatch(IntPtr connection) { Debug.LogWarning("GView.BeginSettingsBatch():这个函数目前未实现!"); } /// /// End a settings batch for the specified connection. /// /// /// /// Attempting to end a setting batch for a connection that does not have an /// active settings batch will result in an error. /// /// /// /// The connection to end a settings batch for. /// /// /// /// Thrown if the connection is null (IntPtr.Zero). /// /// /// Thrown if the connection is invalid. /// /// /// Thrown if the connection is in the Closed or Error state. /// public void EndSettingsBatch(IntPtr connection) { Debug.LogWarning("GView.EndSettingsBatch():这个函数目前未实现!"); } /// /// Get the value of the specified setting of type bool for the specified /// connection. /// /// /// /// The connection to get the setting value for. /// /// /// The setting key to get the value of. /// /// /// /// The value associated with specified connection and setting key. /// /// /// /// Thrown if the connection is null (IntPtr.Zero). /// /// /// Thrown if the connection is invalid. /// /// /// Thrown if the connection is in the Closed or Error state. /// /// /// Thrown if the setting key is invalid. /// public bool GetSettingBool(IntPtr connection, SettingKey key) { Debug.LogWarning("GView.GetSettingBool():这个函数目前未实现!key=" + key); bool value = false; return value; } /// /// Get the value of the specified setting of type sbyte (Int8) for the /// specified connection. /// /// /// /// The connection to get the setting value for. /// /// /// The setting key to get the value of. /// /// /// /// The value associated with specified connection and setting key. /// /// /// /// Thrown if the connection is null (IntPtr.Zero). /// /// /// Thrown if the connection is invalid. /// /// /// Thrown if the connection is in the Closed or Error state. /// /// /// Thrown if the setting key is invalid. /// public sbyte GetSettingInt8(IntPtr connection, SettingKey key) { Debug.LogWarning("GView.GetSettingInt8():这个函数目前未实现!key=" + key); sbyte value = 0; return value; } /// /// Get the value of the specified setting of type Int16 for the specified /// connection. /// /// /// /// The connection to get the setting value for. /// /// /// The setting key to get the value of. /// /// /// /// The value associated with specified connection and setting key. /// /// /// /// Thrown if the connection is null (IntPtr.Zero). /// /// /// Thrown if the connection is invalid. /// /// /// Thrown if the connection is in the Closed or Error state. /// /// /// Thrown if the setting key is invalid. /// public Int16 GetSettingInt16(IntPtr connection, SettingKey key) { Debug.LogWarning("GView.GetSettingInt16():这个函数目前未实现!key=" + key); Int16 value = 0; return value; } /// /// Get the value of the specified setting of type Int32 for the specified /// connection. /// /// /// /// The connection to get the setting value for. /// /// /// The setting key to get the value of. /// /// /// /// The value associated with specified connection and setting key. /// /// /// /// Thrown if the connection is null (IntPtr.Zero). /// /// /// Thrown if the connection is invalid. /// /// /// Thrown if the connection is in the Closed or Error state. /// /// /// Thrown if the setting key is invalid. /// public Int32 GetSettingInt32(IntPtr connection, SettingKey key) { Debug.LogWarning("GView.GetSettingInt32():这个函数目前未实现!key=" + key); Int32 value = 0; return value; } /// /// Get the value of the specified setting of type Int64 for the specified /// connection. /// /// /// /// The connection to get the setting value for. /// /// /// The setting key to get the value of. /// /// /// /// The value associated with specified connection and setting key. /// /// /// /// Thrown if the connection is null (IntPtr.Zero). /// /// /// Thrown if the connection is invalid. /// /// /// Thrown if the connection is in the Closed or Error state. /// /// /// Thrown if the setting key is invalid. /// public Int64 GetSettingInt64(IntPtr connection, SettingKey key) { Debug.LogWarning("GView.GetSettingInt64():这个函数目前未实现!key=" + key); Int64 value = 0; return value; } /// /// Get the value of the specified setting of type byte (UInt8) for the /// specified connection. /// /// /// /// The connection to get the setting value for. /// /// /// The setting key to get the value of. /// /// /// /// The value associated with specified connection and setting key. /// /// /// /// Thrown if the connection is null (IntPtr.Zero). /// /// /// Thrown if the connection is invalid. /// /// /// Thrown if the connection is in the Closed or Error state. /// /// /// Thrown if the setting key is invalid. /// public byte GetSettingUInt8(IntPtr connection, SettingKey key) { Debug.LogWarning("GView.GetSettingUInt8():这个函数目前未实现!key=" + key); byte value = 0; return value; } /// /// Get the value of the specified setting of type UInt16 for the specified /// connection. /// /// /// /// The connection to get the setting value for. /// /// /// The setting key to get the value of. /// /// /// /// The value associated with specified connection and setting key. /// /// /// /// Thrown if the connection is null (IntPtr.Zero). /// /// /// Thrown if the connection is invalid. /// /// /// Thrown if the connection is in the Closed or Error state. /// /// /// Thrown if the setting key is invalid. /// public UInt16 GetSettingUInt16(IntPtr connection, SettingKey key) { Debug.LogWarning("GView.GetSettingUInt16():这个函数目前未实现!key=" + key); UInt16 value = 0; return value; } /// /// Get the value of the specified setting of type UInt32 for the specified /// connection. /// /// /// /// The connection to get the setting value for. /// /// /// The setting key to get the value of. /// /// /// /// The value associated with specified connection and setting key. /// /// /// /// Thrown if the connection is null (IntPtr.Zero). /// /// /// Thrown if the connection is invalid. /// /// /// Thrown if the connection is in the Closed or Error state. /// /// /// Thrown if the setting key is invalid. /// public UInt32 GetSettingUInt32(IntPtr connection, SettingKey key) { Debug.LogWarning("GView.GetSettingUInt32():这个函数目前未实现!key=" + key); UInt32 value = 0; return value; } /// /// Get the value of the specified setting of type UInt64 for the specified /// connection. /// /// /// /// The connection to get the setting value for. /// /// /// The setting key to get the value of. /// /// /// /// The value associated with specified connection and setting key. /// /// /// /// Thrown if the connection is null (IntPtr.Zero). /// /// /// Thrown if the connection is invalid. /// /// /// Thrown if the connection is in the Closed or Error state. /// /// /// Thrown if the setting key is invalid. /// public UInt64 GetSettingUInt64(IntPtr connection, SettingKey key) { Debug.LogWarning("GView.GetSettingUInt64():这个函数目前未实现!key=" + key); UInt64 value = 0; return value; } /// /// Get the value of the specified setting of type float for the specified /// connection. /// /// /// /// The connection to get the setting value for. /// /// /// The setting key to get the value of. /// /// /// /// The value associated with specified connection and setting key. /// /// /// /// Thrown if the connection is null (IntPtr.Zero). /// /// /// Thrown if the connection is invalid. /// /// /// Thrown if the connection is in the Closed or Error state. /// /// /// Thrown if the setting key is invalid. /// public float GetSettingFloat(IntPtr connection, SettingKey key) { Debug.LogWarning("GView.GetSettingFloat():这个函数目前未实现!key=" + key); float value = 0; return value; } /// /// Get the value of the specified setting of type double for the specified /// connection. /// /// /// /// The connection to get the setting value for. /// /// /// The setting key to get the value of. /// /// /// /// The value associated with specified connection and setting key. /// /// /// /// Thrown if the connection is null (IntPtr.Zero). /// /// /// Thrown if the connection is invalid. /// /// /// Thrown if the connection is in the Closed or Error state. /// /// /// Thrown if the setting key is invalid. /// public double GetSettingDouble(IntPtr connection, SettingKey key) { Debug.LogWarning("GView.GetSettingDouble():这个函数目前未实现!key=" + key); double value = 0; return value; } /// /// Get the value of the specified setting of type Vector3 for the specified /// connection. /// /// /// /// The connection to get the setting value for. /// /// /// The setting key to get the value of. /// /// /// /// The value associated with specified connection and setting key. /// /// /// /// Thrown if the connection is null (IntPtr.Zero). /// /// /// Thrown if the connection is invalid. /// /// /// Thrown if the connection is in the Closed or Error state. /// /// /// Thrown if the setting key is invalid. /// public Vector3 GetSettingVector3(IntPtr connection, SettingKey key) { Debug.LogWarning("GView.GetSettingVector3():这个函数目前未实现!key=" + key); return Vector3.zero; } /// /// Get the value of the specified setting of type Matrix4x4 for the specified /// connection. /// /// /// /// The connection to get the setting value for. /// /// /// The setting key to get the value of. /// /// /// /// The value associated with specified connection and setting key. /// /// /// /// Thrown if the connection is null (IntPtr.Zero). /// /// /// Thrown if the connection is invalid. /// /// /// Thrown if the connection is in the Closed or Error state. /// /// /// Thrown if the setting key is invalid. /// public Matrix4x4 GetSettingMatrix4x4(IntPtr connection, SettingKey key) { Debug.LogWarning("GView.GetSettingMatrix4x4():这个函数目前未实现!key=" + key); return Matrix4x4.zero; } /// /// Set the value of the specified setting of type bool for the specified /// connection. /// /// /// /// When the value of a setting is set, its state will transition to /// ChangePending until the new value has been accepted by the other side /// of the associated connection. /// /// /// /// The connection to set the setting value for. /// /// /// The setting key to set the value of. /// /// /// The new value for the specified setting key for the specified connection. /// /// /// /// Thrown if the connection is null (IntPtr.Zero). /// /// /// Thrown if the connection is invalid. /// /// /// Thrown if the connection is in the Closed or Error state. /// /// /// Thrown if the setting key is invalid. /// public void SetSetting(IntPtr connection, SettingKey key, bool value) { Debug.LogWarning("GView.SetSetting():这个函数目前未实现!key=" + key + ",value=" + value); } /// /// Set the value of the specified setting of type sbyte (Int8) for the /// specified connection. /// /// /// /// When the value of a setting is set, its state will transition to /// ChangePending until the new value has been accepted by the other side /// of the associated connection. /// /// /// /// The connection to set the setting value for. /// /// /// The setting key to set the value of. /// /// /// The new value for the specified setting key for the specified connection. /// /// /// /// Thrown if the connection is null (IntPtr.Zero). /// /// /// Thrown if the connection is invalid. /// /// /// Thrown if the connection is in the Closed or Error state. /// /// /// Thrown if the setting key is invalid. /// public void SetSetting(IntPtr connection, SettingKey key, sbyte value) { Debug.LogWarning("GView.SetSetting():这个函数目前未实现!key=" + key + ",value=" + value); } /// /// Set the value of the specified setting of type Int16 for the specified /// connection. /// /// /// /// When the value of a setting is set, its state will transition to /// ChangePending until the new value has been accepted by the other side /// of the associated connection. /// /// /// /// The connection to set the setting value for. /// /// /// The setting key to set the value of. /// /// /// The new value for the specified setting key for the specified connection. /// /// /// /// Thrown if the connection is null (IntPtr.Zero). /// /// /// Thrown if the connection is invalid. /// /// /// Thrown if the connection is in the Closed or Error state. /// /// /// Thrown if the setting key is invalid. /// public void SetSetting(IntPtr connection, SettingKey key, Int16 value) { Debug.LogWarning("GView.SetSetting():这个函数目前未实现!key=" + key + ",value=" + value); } /// /// Set the value of the specified setting of type Int32 for the specified /// connection. /// /// /// /// When the value of a setting is set, its state will transition to /// ChangePending until the new value has been accepted by the other side /// of the associated connection. /// /// /// /// The connection to set the setting value for. /// /// /// The setting key to set the value of. /// /// /// The new value for the specified setting key for the specified connection. /// /// /// /// Thrown if the connection is null (IntPtr.Zero). /// /// /// Thrown if the connection is invalid. /// /// /// Thrown if the connection is in the Closed or Error state. /// /// /// Thrown if the setting key is invalid. /// public void SetSetting(IntPtr connection, SettingKey key, Int32 value) { Debug.LogWarning("GView.SetSetting():这个函数目前未实现!key=" + key + ",value=" + value); } /// /// Set the value of the specified setting of type Int64 for the specified /// connection. /// /// /// /// When the value of a setting is set, its state will transition to /// ChangePending until the new value has been accepted by the other side /// of the associated connection. /// /// /// /// The connection to set the setting value for. /// /// /// The setting key to set the value of. /// /// /// The new value for the specified setting key for the specified connection. /// /// /// /// Thrown if the connection is null (IntPtr.Zero). /// /// /// Thrown if the connection is invalid. /// /// /// Thrown if the connection is in the Closed or Error state. /// /// /// Thrown if the setting key is invalid. /// public void SetSetting(IntPtr connection, SettingKey key, Int64 value) { Debug.LogWarning("GView.SetSetting():这个函数目前未实现!key=" + key + ",value=" + value); } /// /// Set the value of the specified setting of type byte (UInt8) for the /// specified connection. /// /// /// /// When the value of a setting is set, its state will transition to /// ChangePending until the new value has been accepted by the other side /// of the associated connection. /// /// /// /// The connection to set the setting value for. /// /// /// The setting key to set the value of. /// /// /// The new value for the specified setting key for the specified connection. /// /// /// /// Thrown if the connection is null (IntPtr.Zero). /// /// /// Thrown if the connection is invalid. /// /// /// Thrown if the connection is in the Closed or Error state. /// /// /// Thrown if the setting key is invalid. /// public void SetSetting(IntPtr connection, SettingKey key, byte value) { Debug.LogWarning("GView.SetSetting():这个函数目前未实现!key=" + key + ",value=" + value); } /// /// Set the value of the specified setting of type UInt16 for the specified /// connection. /// /// /// /// When the value of a setting is set, its state will transition to /// ChangePending until the new value has been accepted by the other side /// of the associated connection. /// /// /// /// The connection to set the setting value for. /// /// /// The setting key to set the value of. /// /// /// The new value for the specified setting key for the specified connection. /// /// /// /// Thrown if the connection is null (IntPtr.Zero). /// /// /// Thrown if the connection is invalid. /// /// /// Thrown if the connection is in the Closed or Error state. /// /// /// Thrown if the setting key is invalid. /// public void SetSetting(IntPtr connection, SettingKey key, UInt16 value) { Debug.LogWarning("GView.SetSetting():这个函数目前未实现!key=" + key + ",value=" + value); } /// /// Set the value of the specified setting of type UInt32 for the specified /// connection. /// /// /// /// When the value of a setting is set, its state will transition to /// ChangePending until the new value has been accepted by the other side /// of the associated connection. /// /// /// /// The connection to set the setting value for. /// /// /// The setting key to set the value of. /// /// /// The new value for the specified setting key for the specified connection. /// /// /// /// Thrown if the connection is null (IntPtr.Zero). /// /// /// Thrown if the connection is invalid. /// /// /// Thrown if the connection is in the Closed or Error state. /// /// /// Thrown if the setting key is invalid. /// public void SetSetting(IntPtr connection, SettingKey key, UInt32 value) { Debug.LogWarning("GView.SetSetting():这个函数目前未实现!key=" + key + ",value=" + value); } /// /// Set the value of the specified setting of type UInt64 for the specified /// connection. /// /// /// /// When the value of a setting is set, its state will transition to /// ChangePending until the new value has been accepted by the other side /// of the associated connection. /// /// /// /// The connection to set the setting value for. /// /// /// The setting key to set the value of. /// /// /// The new value for the specified setting key for the specified connection. /// /// /// /// Thrown if the connection is null (IntPtr.Zero). /// /// /// Thrown if the connection is invalid. /// /// /// Thrown if the connection is in the Closed or Error state. /// /// /// Thrown if the setting key is invalid. /// public void SetSetting(IntPtr connection, SettingKey key, UInt64 value) { Debug.LogWarning("GView.SetSetting():这个函数目前未实现!key=" + key + ",value=" + value); } /// /// Set the value of the specified setting of type float for the specified /// connection. /// /// /// /// When the value of a setting is set, its state will transition to /// ChangePending until the new value has been accepted by the other side /// of the associated connection. /// /// /// /// The connection to set the setting value for. /// /// /// The setting key to set the value of. /// /// /// The new value for the specified setting key for the specified connection. /// /// /// /// Thrown if the connection is null (IntPtr.Zero). /// /// /// Thrown if the connection is invalid. /// /// /// Thrown if the connection is in the Closed or Error state. /// /// /// Thrown if the setting key is invalid. /// public void SetSetting(IntPtr connection, SettingKey key, float value) { Debug.LogWarning("GView.SetSetting():这个函数目前未实现!key=" + key + ",value=" + value); } /// /// Set the value of the specified setting of type double for the specified /// connection. /// /// /// /// When the value of a setting is set, its state will transition to /// ChangePending until the new value has been accepted by the other side /// of the associated connection. /// /// /// /// The connection to set the setting value for. /// /// /// The setting key to set the value of. /// /// /// The new value for the specified setting key for the specified connection. /// /// /// /// Thrown if the connection is null (IntPtr.Zero). /// /// /// Thrown if the connection is invalid. /// /// /// Thrown if the connection is in the Closed or Error state. /// /// /// Thrown if the setting key is invalid. /// public void SetSetting(IntPtr connection, SettingKey key, double value) { Debug.LogWarning("GView.SetSetting():这个函数目前未实现!key=" + key + ",value=" + value); } /// /// Set the value of the specified setting of type Vector3 for the specified /// connection. /// /// /// /// When the value of a setting is set, its state will transition to /// ChangePending until the new value has been accepted by the other side /// of the associated connection. /// /// /// /// The connection to set the setting value for. /// /// /// The setting key to set the value of. /// /// /// The new value for the specified setting key for the specified connection. /// /// /// /// Thrown if the connection is null (IntPtr.Zero). /// /// /// Thrown if the connection is invalid. /// /// /// Thrown if the connection is in the Closed or Error state. /// /// /// Thrown if the setting key is invalid. /// public void SetSetting(IntPtr connection, SettingKey key, Vector3 value) { Debug.LogWarning("GView.SetSetting():这个函数目前未实现!key=" + key + ",value=" + value); } /// /// Set the value of the specified setting of type Matrix4x4 for the specified /// connection. /// /// /// /// When the value of a setting is set, its state will transition to /// ChangePending until the new value has been accepted by the other side /// of the associated connection. /// /// /// /// The connection to set the setting value for. /// /// /// The setting key to set the value of. /// /// /// The new value for the specified setting key for the specified connection. /// /// /// /// Thrown if the connection is null (IntPtr.Zero). /// /// /// Thrown if the connection is invalid. /// /// /// Thrown if the connection is in the Closed or Error state. /// /// /// Thrown if the setting key is invalid. /// public void SetSetting(IntPtr connection, SettingKey key, Matrix4x4 value) { Debug.LogWarning("GView.SetSetting():这个函数目前未实现!key=" + key + ",value=" + value); } /// /// Get the state of the specified setting for the specified connection /// /// /// /// The connection to get the setting state for. /// /// /// The setting key to get the state of. /// /// /// /// The state of the specified setting state for the specified connection. /// /// /// /// Thrown if the connection is null (IntPtr.Zero). /// /// /// Thrown if the connection is invalid. /// /// /// Thrown if the connection is in the Closed or Error state. /// public SettingState GetSettingState(IntPtr connection, SettingKey key) { Debug.LogWarning("GView.GetSettingState():这个函数目前未实现!key=" + key); SettingState state; state = SettingState.UpToDate; return state; } /// /// Get the value of the specified frame data of type bool for the /// specified frame. /// /// /// /// The frame to get frame data from. /// /// /// The frame data key to get the value of. /// /// /// /// The value associated with specified frame and frame data key. /// /// /// /// Thrown if the frame is null (IntPtr.Zero). /// /// /// Thrown if the frame is invalid. /// /// /// Thrown if the frame data key is invalid. /// public bool GetFrameDataBool(IntPtr frame, FrameDataKey key) { Debug.LogWarning("GView.GetFrameDataBool():这个函数目前未实现!key=" + key); bool value = false; return value; } /// /// Get the value of the specified frame data of type sbyte (Int8) for the /// specified frame. /// /// /// /// The frame to get frame data from. /// /// /// The frame data key to get the value of. /// /// /// /// The value associated with specified frame and frame data key. /// /// /// /// Thrown if the frame is null (IntPtr.Zero). /// /// /// Thrown if the frame is invalid. /// /// /// Thrown if the frame data key is invalid. /// public sbyte GetFrameDataInt8(IntPtr frame, FrameDataKey key) { Debug.LogWarning("GView.GetFrameDataInt8():这个函数目前未实现!key=" + key); sbyte value = 0; return value; } /// /// Get the value of the specified frame data of type Int16 for the /// specified frame. /// /// /// /// The frame to get frame data from. /// /// /// The frame data key to get the value of. /// /// /// /// The value associated with specified frame and frame data key. /// /// /// /// Thrown if the frame is null (IntPtr.Zero). /// /// /// Thrown if the frame is invalid. /// /// /// Thrown if the frame data key is invalid. /// public Int16 GetFrameDataInt16(IntPtr frame, FrameDataKey key) { Debug.LogWarning("GView.GetFrameDataInt16():这个函数目前未实现!key=" + key); Int16 value = 0; return value; } /// /// Get the value of the specified frame data of type Int32 for the /// specified frame. /// /// /// /// The frame to get frame data from. /// /// /// The frame data key to get the value of. /// /// /// /// The value associated with specified frame and frame data key. /// /// /// /// Thrown if the frame is null (IntPtr.Zero). /// /// /// Thrown if the frame is invalid. /// /// /// Thrown if the frame data key is invalid. /// public Int32 GetFrameDataInt32(IntPtr frame, FrameDataKey key) { Debug.LogWarning("GView.GetFrameDataInt32():这个函数目前未实现!key=" + key); Int32 value = 0; return value; } /// /// Get the value of the specified frame data of type Int64 for the /// specified frame. /// /// /// /// The frame to get frame data from. /// /// /// The frame data key to get the value of. /// /// /// /// The value associated with specified frame and frame data key. /// /// /// /// Thrown if the frame is null (IntPtr.Zero). /// /// /// Thrown if the frame is invalid. /// /// /// Thrown if the frame data key is invalid. /// public Int64 GetFrameDataInt64(IntPtr frame, FrameDataKey key) { Debug.LogWarning("GView.GetFrameDataInt64():这个函数目前未实现!key=" + key); Int64 value = 0; return value; } /// /// Get the value of the specified frame data of type byte (UInt8) for the /// specified frame. /// /// /// /// The frame to get frame data from. /// /// /// The frame data key to get the value of. /// /// /// /// The value associated with specified frame and frame data key. /// /// /// /// Thrown if the frame is null (IntPtr.Zero). /// /// /// Thrown if the frame is invalid. /// /// /// Thrown if the frame data key is invalid. /// public byte GetFrameDataUInt8(IntPtr frame, FrameDataKey key) { Debug.LogWarning("GView.GetFrameDataUInt8():这个函数目前未实现!key=" + key); byte value = 0; return value; } /// /// Get the value of the specified frame data of type UInt16 for the /// specified frame. /// /// /// /// The frame to get frame data from. /// /// /// The frame data key to get the value of. /// /// /// /// The value associated with specified frame and frame data key. /// /// /// /// Thrown if the frame is null (IntPtr.Zero). /// /// /// Thrown if the frame is invalid. /// /// /// Thrown if the frame data key is invalid. /// public UInt16 GetFrameDataUInt16(IntPtr frame, FrameDataKey key) { Debug.LogWarning("GView.GetFrameDataUInt16():这个函数目前未实现!key=" + key); UInt16 value = 0; return value; } /// /// Get the value of the specified frame data of type UInt32 for the /// specified frame. /// /// /// /// The frame to get frame data from. /// /// /// The frame data key to get the value of. /// /// /// /// The value associated with specified frame and frame data key. /// /// /// /// Thrown if the frame is null (IntPtr.Zero). /// /// /// Thrown if the frame is invalid. /// /// /// Thrown if the frame data key is invalid. /// public UInt32 GetFrameDataUInt32(IntPtr frame, FrameDataKey key) { Debug.LogWarning("GView.GetFrameDataUInt32():这个函数目前未实现!key=" + key); UInt32 value = 0; return value; } /// /// Get the value of the specified frame data of type UInt64 for the /// specified frame. /// /// /// /// The frame to get frame data from. /// /// /// The frame data key to get the value of. /// /// /// /// The value associated with specified frame and frame data key. /// /// /// /// Thrown if the frame is null (IntPtr.Zero). /// /// /// Thrown if the frame is invalid. /// /// /// Thrown if the frame data key is invalid. /// public UInt64 GetFrameDataUInt64(IntPtr frame, FrameDataKey key) { Debug.LogWarning("GView.GetFrameDataUInt64():这个函数目前未实现!key=" + key); UInt64 value = 0; return value; } /// /// Get the value of the specified frame data of type float for the /// specified frame. /// /// /// /// The frame to get frame data from. /// /// /// The frame data key to get the value of. /// /// /// /// The value associated with specified frame and frame data key. /// /// /// /// Thrown if the frame is null (IntPtr.Zero). /// /// /// Thrown if the frame is invalid. /// /// /// Thrown if the frame data key is invalid. /// public float GetFrameDataFloat(IntPtr frame, FrameDataKey key) { Debug.LogWarning("GView.GetFrameDataFloat():这个函数目前未实现!key=" + key); float value = 0; return value; } /// /// Get the value of the specified frame data of type double for the /// specified frame. /// /// /// /// The frame to get frame data from. /// /// /// The frame data key to get the value of. /// /// /// /// The value associated with specified frame and frame data key. /// /// /// /// Thrown if the frame is null (IntPtr.Zero). /// /// /// Thrown if the frame is invalid. /// /// /// Thrown if the frame data key is invalid. /// public double GetFrameDataDouble(IntPtr frame, FrameDataKey key) { Debug.LogWarning("GView.GetFrameDataDouble():这个函数目前未实现!key=" + key); double value = 0; return value; } /// /// Get the value of the specified frame data of type Vector3 for the /// specified frame. /// /// /// /// The frame to get frame data from. /// /// /// The frame data key to get the value of. /// /// /// /// The value associated with specified frame and frame data key. /// /// /// /// Thrown if the frame is null (IntPtr.Zero). /// /// /// Thrown if the frame is invalid. /// /// /// Thrown if the frame data key is invalid. /// public Vector3 GetFrameDataVector3(IntPtr frame, FrameDataKey key) { Debug.LogWarning("GView.GetFrameDataVector3():这个函数目前未实现!key=" + key); //ZSVector3 value; return Vector3.zero; } /// /// Get the value of the specified frame data of type Matrix4x4 for the /// specified frame. /// /// /// /// The frame to get frame data from. /// /// /// The frame data key to get the value of. /// /// /// /// The value associated with specified frame and frame data key. /// /// /// /// Thrown if the frame is null (IntPtr.Zero). /// /// /// Thrown if the frame is invalid. /// /// /// Thrown if the frame data key is invalid. /// public Matrix4x4 GetFrameDataMatrix4x4(IntPtr frame, FrameDataKey key) { Debug.LogWarning("GView.GetFrameDataMatrix4x4():这个函数目前未实现!key=" + key); //ZSMatrix4 value; return Matrix4x4.zero; } /// /// Get the current video recording state of the specified connection. /// /// /// /// The connection to get the video recording state of. /// /// /// /// The video recording state of the specified connection. /// /// /// /// Thrown if the connection is null (IntPtr.Zero). /// /// /// Thrown if the connection is invalid. /// public VideoRecordingState GetVideoRecordingState(IntPtr connection) { VideoRecordingState state = VideoRecordingState.NotAvailable; if (connection == GlobalState.Instance.Connection) { try { xxGetVideoRecordingState(out state); } catch (Exception) { } } return state; } /// /// Get the current video recording error code of the specified connection. /// /// /// /// Calling this method will fail unless the current video recording state is /// Error. /// /// /// /// The connection to get the video recording error code of. /// /// /// /// The video recording error code of the specified connection. /// /// /// /// Thrown if the connection is null (IntPtr.Zero). /// /// /// Thrown if the connection is invalid. /// /// /// Thrown if the connection is in the Closed or Error state. /// /// /// Thrown if the connection does not support the video recording capability. /// /// /// Thrown if the video recording is not in the Error state. /// public PluginError GetVideoRecordingError(IntPtr connection) { Debug.LogWarning("GView.GetVideoRecordingError():这个函数目前未实现!"); PluginError videoRecordingError = PluginError.Ok; return videoRecordingError; } /// /// Clear the video recording error code of the specified connection. /// /// /// /// Transitions the video recording state of the connection from Error to some /// other non-error state. Exactly which video recording state is transitioned /// to depends on the video recording state that the connection was in prior to /// it entering the Error state. In most cases, this function will transition the /// video recording state to NotRecording. A notable exception is when the /// video recording state of the connection was Saving prior to it entering the /// Error state. In this case, the video recording state may transition back to /// Finished after calling this function if a recoverable save error occurred and /// it is still possible that the current video recording could be saved (e.g. with /// a different file name or after some disk space has been freed). /// /// Calling this function will fail unless the current video recording state is /// Error. /// /// /// /// The connection to clear the video recording error code of. /// /// /// /// Thrown if the connection is null (IntPtr.Zero). /// /// /// Thrown if the connection is invalid. /// /// /// Thrown if the connection is in the Closed or Error state. /// /// /// Thrown if the connection does not support the video recording capability. /// /// /// Thrown if the video recording is not in the Error state. /// public void ClearVideoRecordingError(IntPtr connection) { Debug.LogWarning("GView.ClearVideoRecordingError():这个函数目前未实现!"); } /// /// Start video recording on the specified connection. /// /// /// /// Transitions the video recording state of the connection to Recording. While the /// video recording state transition is taking place, the video recording state will be /// Starting. /// /// Calling this function will fail unless the current video recording state is /// NotRecording. /// /// /// /// The connection to start video recording on. /// /// /// /// Thrown if the connection is null (IntPtr.Zero). /// /// /// Thrown if the connection is invalid. /// /// /// Thrown if the connection is in the Closed or Error state. /// /// /// Thrown if the connection does not support the video recording capability. /// /// /// Thrown if the video recording is not in the NotRecording state. /// public void StartVideoRecording(IntPtr connection) { Debug.Log("GView.StartVideoRecording():启动录屏!"); try { Debug.Log("GView.StartVideoRecording():临时文件路径:" + tempRecFile); FARError err = xxStartScreenRec(tempRecFile); if (err != FARError.Ok) { Debug.LogError("GView.StartVideoRecording():启动录屏失败! err=" + err); } } catch (Exception e) { Debug.LogError("GView.StartVideoRecording():启动录屏异常e=" + e.Message); } } /// /// Finish video recording on the specified connection. /// /// /// /// Transitions the video recording state of the connection to Finished. While /// the video recording state transition is taking place, the video recording state /// will be Finishing. /// /// Calling this function will fail unless the current video recording state is /// Recording or Paused. /// /// /// /// The connection to finish video recording on. /// /// /// /// Thrown if the connection is null (IntPtr.Zero). /// /// /// Thrown if the connection is invalid. /// /// /// Thrown if the connection is in the Closed or Error state. /// /// /// Thrown if the connection does not support the video recording capability. /// /// /// Thrown if the video recording is not in the Recording or Paused state. /// public void FinishVideoRecording(IntPtr connection) { Debug.Log("GView.FinishVideoRecording():停止录屏!"); try { FARError err = xxStopScreenRec(); if (err != FARError.Ok) { Debug.LogError("GView.FinishVideoRecording():停止录屏失败! err=" + err); } } catch (Exception e) { Debug.LogError("GView.FinishVideoRecording():停止录屏异常e=" + e.Message); } } /// /// Pause video recording on the specified connection. /// /// /// /// Transitions the video recording state of the connection to Paused. While the /// video recording state transition is taking place, the video recording state will /// be Pausing. /// /// Calling this function will fail unless the current video recording state is /// Recording. /// /// /// /// The connection to pause video recording on. /// /// /// /// Thrown if the connection is null (IntPtr.Zero). /// /// /// Thrown if the connection is invalid. /// /// /// Thrown if the connection is in the Closed or Error state. /// /// /// Thrown if the connection does not support the video recording capability. /// /// /// Thrown if the video recording is not in the Recording state. /// public void PauseVideoRecording(IntPtr connection) { Debug.LogWarning("GView.PauseVideoRecording():这个函数目前未实现!"); } /// /// Resume video recording on the specified connection. /// /// /// /// Transitions the video recording state of the connection to Recording. While the /// video recording state transition is taking place, the video recording state will be /// Resuming. /// /// Calling this function will fail unless the current video recording state is /// Paused. /// /// /// /// The connection to resume video recording on. /// /// /// /// Thrown if the connection is null (IntPtr.Zero). /// /// /// Thrown if the connection is invalid. /// /// /// Thrown if the connection is in the Closed or Error state. /// /// /// Thrown if the connection does not support the video recording capability. /// /// /// Thrown if the video recording is not in the Paused state. /// public void ResumeVideoRecording(IntPtr connection) { Debug.LogWarning("GView.ResumeVideoRecording():这个函数目前未实现!"); } /// /// Begin saving the specified connection's current video recording to the /// specified file name. /// /// /// /// Transitions the video recording state of the connection to Saving. Saving occurs /// asynchronously and the video recording state of the connection will automatically /// transition to NotRecording if saving finishes successfully. If saving fails, then /// the video recording state will automatically transition to Error. /// /// Calling this function will fail unless the current video recording state is /// Finished. /// /// /// /// The connection to save the current video recording of. /// /// /// The file name to save the video recording to. /// /// /// /// Thrown if the connection is null (IntPtr.Zero). /// /// /// Thrown if the connection is invalid. /// /// /// Thrown if the connection is in the Closed or Error state. /// /// /// Thrown if the connection does not support the video recording capability. /// /// /// Thrown if the video recording is not in the Finished state. /// public void SaveVideoRecording(IntPtr connection, string fileName) { if (!File.Exists(tempRecFile)) { Debug.LogWarning("GView.SaveVideoRecording():不存在录屏的临时文件,无法作移动!临时文件路径:" + tempRecFile); return; } if (File.Exists(fileName)) { Debug.Log("GView.SaveVideoRecording():移动路径上已经存在文件,删除!"); File.Delete(fileName); } try { //注意这里实际上需要等待ffmpeg.exe完成退出才能移动这个文件. Debug.Log("GView.SaveVideoRecording():移动临时录屏文件到" + fileName); File.Move(tempRecFile, fileName); xxSaveVideoRecording(fileName); } catch (Exception e) { Debug.LogError("GView.SaveVideoRecording():移动文件异常e=" + e.Message); } } /// /// Begin discarding the specified connection's current video recording. /// /// /// /// Transitions the video recording state of the connection to Discarding. /// Discarding occurs asynchronously and the video recording state of the connection /// will automatically transition to Recording when discarding is finished. /// /// Calling this function will fail unless the current video recording state is /// Finished. /// /// /// /// Transitions the video recording state of the connection to Discarding. /// Discarding occurs asynchronously and the video recording state of the /// connection will automatically transition to NotRecording when discarding is /// finished. /// /// Calling this function will fail unless the current video recording state is /// Finished. /// /// /// /// Thrown if the connection is null (IntPtr.Zero). /// /// /// Thrown if the connection is invalid. /// /// /// Thrown if the connection is in the Closed or Error state. /// /// /// Thrown if the connection does not support the video recording capability. /// /// /// Thrown if the video recording is not in the Finished state. /// public void DiscardVideoRecording(IntPtr connection) { Debug.Log("GView.DiscardVideoRecording():中止录屏!"); try { FARError err = xxStopScreenRec(); if (err != FARError.Ok) { Debug.LogError("GView.FinishVideoRecording():中止录屏! err=" + err); } //删除已经存在的录制文件 if (!File.Exists(tempRecFile)) { File.Delete(tempRecFile); } xxDiscardVideoRecording(); } catch (Exception e) { Debug.Log("GView.DiscardVideoRecording():异常e=" + e.Message); } } /// /// Get the amount of time that has elapsed, in milliseconds, since the /// specified connection's current video recording began. /// /// /// /// The connection to get the current video recording time of. /// /// /// /// The current video recording time of the specified connection, /// in milliseconds. /// /// /// /// Thrown if the connection is null (IntPtr.Zero). /// /// /// Thrown if the connection is invalid. /// /// /// Thrown if the connection is in the Closed or Error state. /// /// /// Thrown if the connection does not support the video recording capability. /// /// /// Thrown if the video recording is in the NotAvailable, NotRecording, Starting, /// Error, or ClearingError state. /// public UInt64 GetVideoRecordingTime(IntPtr connection) { Debug.LogWarning("GView.GetVideoRecordingTime():这个函数目前未实现!"); UInt64 timeInMilliseconds = 0; return timeInMilliseconds; } /// /// Set the specified mode's current active virtual camera. /// /// /// /// If null is specified for the virtual camera, the mode's virtual camera /// will be reset to its default implementation. /// /// /// /// The mode to specify the virtual camera. /// /// /// The virtual camera associated with the specified mode. /// public void SetVirtualCamera(IntPtr mode, GVirtualCamera virtualCamera) { Debug.LogWarning("GView.SetVirtualCamera():这个函数目前未实现!"); } /// /// Get the current active virtual camera associated with the specified mode. /// /// /// /// The mode to get the virtual camera for. /// /// /// /// The current active virtual camera associated with the specified mode. /// public GVirtualCamera GetVirtualCamera(IntPtr mode) { GVirtualCamera virtualCamera = null; if (!_virtualCameras.TryGetValue(mode, out virtualCamera)) { Debug.LogError(string.Format("Failed to find virtual camera for mode: {0}.", mode)); } return virtualCamera; } /// /// Start ignoring (i.e. not processing) any connections with the /// specified user data. /// /// /// The user data for which to ignore connections for. /// public void RegisterConnectionUserDataToIgnore(IntPtr userData) { Debug.Log("GView.RegisterConnectionUserDataToIgnore():进入!"); _connectionUserDatasToIgnore.Add(userData); } /// /// Stop ignoring (i.e. not processing) any connections with the /// specified user data. /// /// /// The user data for which to no longer ignore connections for. /// public void UnregisterConnectionUserDataToIgnore(IntPtr userData) { Debug.Log("GView.UnregisterConnectionUserDataToIgnore():进入!"); _connectionUserDatasToIgnore.Remove(userData); } ////////////////////////////////////////////////////////////////// // Private Compound Types ////////////////////////////////////////////////////////////////// private class ConnectionInfo { public IntPtr Connection { get; private set; } public ConnectionState ConnectionState { get; set; } public IntPtr Mode { get; set; } public IntPtr ReceivedFrame { get; set; } public IntPtr FrameToSend { get; set; } public VideoRecordingState VideoRecordingState { get; set; } public VideoRecordingQuality VideoRecordingQuality { get; set; } public ConnectionInfo(IntPtr connection) { this.Connection = connection; this.ConnectionState = ConnectionState.Error; this.Mode = IntPtr.Zero; this.ReceivedFrame = IntPtr.Zero; this.FrameToSend = IntPtr.Zero; this.VideoRecordingState = VideoRecordingState.NotAvailable; this.VideoRecordingQuality = VideoRecordingQuality.Unknown; } } ////////////////////////////////////////////////////////////////// // Private Members ////////////////////////////////////////////////////////////////// // private static readonly Matrix4x4 s_flipHandednessMap = Matrix4x4.Scale(new Vector4(1.0f, 1.0f, -1.0f)); // private Dictionary _connectionInfos = new Dictionary(); private Dictionary _defaultVirtualCameras = new Dictionary(); private Dictionary _virtualCameras = new Dictionary(); private HashSet _connectionUserDatasToIgnore = new HashSet(); // private bool _wasFullScreen = false; ////////////////////////////////////////////////////////////////// // Unity Monobehaviour Callbacks ////////////////////////////////////////////////////////////////// //void Awake() //{ // // Force initialization of the global state. // GlobalState globalState = GlobalState.Instance; // if (globalState == null || !globalState.IsInitialized) // { // Debug.LogWarning("Failed to initialize global state. Disabling zView GameObject."); // this.gameObject.SetActive(false); // return; // } // // Continue initialization. // this.InitializeVirtualCameras(); // // Initialize whether the application is in windowed or fullscreen mode. // _wasFullScreen = Screen.fullScreen; // // Kick off the end of frame update coroutine. // this.StartCoroutine(EndOfFrameUpdate()); //} //void Start() //{ // // Handle transitioning from a zView-enabled scene while there // // is currently an active connection. // this.HandleSceneTransition(); //} // void LateUpdate() // { // // Cache whether the application is in windowed or fullscreen mode. // _wasFullScreen = Screen.fullScreen; // } void OnDrawGizmos() { // Draw the bounds of the AR mode box mask. if (this.ARModeShowMask) { if (this.ActiveZCamera == null) return; // Cache original color and matrix to be restored after // drawing is finished. Color originalGizmosColor = Gizmos.color; Matrix4x4 originalGizmosMatrix = Gizmos.matrix; Gizmos.color = Color.white; // ZCamera's parent represents viewport center and // therefore where we align the box mask to it. // If ZCamera has no parent, then it will align the // box mask to world center as is done with ZCamera. Gizmos.matrix = this.ActiveZCamera.transform.parent?.localToWorldMatrix ?? Matrix4x4.identity; Vector3 center = new Vector3(0.0f, 0.0f, -this.ARModeMaskSize.z * 0.5f); Vector3 size = this.ARModeMaskSize; Gizmos.DrawWireCube(center, size); // Restore original color and matrix. Gizmos.color = originalGizmosColor; Gizmos.matrix = originalGizmosMatrix; } } #region ----------------------------------------------- GC一体机的实现 ----------------------------------------------- /// /// 投屏纹理的宽度 /// public UInt16 imageWidth = 1920; /// /// 投屏纹理高度 /// public UInt16 imageHeight = 1080; /// /// CurVirtualCameraMode属性使用的字段 /// private IntPtr _curVirtualCameraMode = IntPtr.Zero; /// /// 当前的工作模式 /// private IntPtr CurVirtualCameraMode { get { return _curVirtualCameraMode; } set { if (value != _curVirtualCameraMode || value == IntPtr.Zero) { try { Debug.Log("GView.CurVirtualCameraMode():切换相机模式! mode=" + value); GVirtualCamera gVirtualCamera = null; if (_defaultVirtualCameras.TryGetValue(_curVirtualCameraMode, out gVirtualCamera)) { gVirtualCamera.TearDown();//关闭老的相机 } if (_defaultVirtualCameras.TryGetValue(value, out gVirtualCamera)) { gVirtualCamera.SetUp(this, GlobalState.Instance.Connection, ModeSetupPhase.Initialization); _workingCamera = gVirtualCamera;//记录当前相机 FARStartRenderingView(_workingCamera); } else { //None模式这个就找不到 //Debug.LogError($"GView.CurVirtualCameraMode():没找到要打开的新相机,将无法投屏! mode={value}"); _workingCamera = null;//没找到要置空 FARDll.CloseDown(); } } catch (Exception e) { Debug.LogError("GView.CurVirtualCameraMode():异常!Message=" + e.Message); FARDll.CloseDown(); } _curVirtualCameraMode = value; GlobalState.Instance.virtualCameraMode = value;//记录到全局状态中 //事件要在virtualCameraMode值被修改了之后发出 if (this.ConnectionModeSwitched != null) { this.ConnectionModeSwitched(this, GlobalState.Instance.Connection); } } } } //当前工作相机 private GVirtualCamera _workingCamera = null; void Awake() { // Force initialization of the global state. GlobalState globalState = GlobalState.Instance; if (globalState == null || !globalState.IsInitialized) { Debug.LogWarning("Failed to initialize global state. Disabling zView GameObject."); this.gameObject.SetActive(false); return; } // Get the first found instance of ZCamera if a reference has not // been manually assigned. if (this.ActiveZCamera == null) { this.ActiveZCamera = GameObject.FindObjectOfType(); if (this.ActiveZCamera == null) { Debug.LogWarning("No instance of ZCamera has been found " + "in the scene. ZView will not work correctly unless " + "ZView.Instance.ActiveZCamera is not null"); } } InitializeVirtualCameras(); //从streamingAssets里面寻找辅助exe string ffmpegPath = Path.Combine(Application.streamingAssetsPath, "ffmpeg.exe"); FARError err = xxSetEXE(ffmpegPath); if (err != FARError.Ok) { //去调试路径里拿一个 err = xxSetEXE("C:\\Test\\ffmpeg.exe"); } if (err != FARError.Ok) { Debug.LogError("GView.Awake():设置录屏辅助程序路径失败!"); } } void Start() { HandleSceneTransition(); } void Update() { if (_workingCamera != null) { _workingCamera.Render(this, IntPtr.Zero, IntPtr.Zero); } VideoRecordingState videoRecordingState = GetVideoRecordingState(GlobalState.Instance.Connection); if (videoRecordingState != GlobalState.Instance.videoRecordingState) { switch (videoRecordingState) { case VideoRecordingState.NotRecording: if (this.VideoRecordingInactive != null) { this.VideoRecordingInactive(this, GlobalState.Instance.Connection); } break; case VideoRecordingState.Recording: if (this.VideoRecordingActive != null) { this.VideoRecordingActive(this, GlobalState.Instance.Connection); } break; case VideoRecordingState.Finished: if (this.VideoRecordingFinished != null) { this.VideoRecordingFinished(this, GlobalState.Instance.Connection); } break; case VideoRecordingState.Paused: if (this.VideoRecordingPaused != null) { this.VideoRecordingPaused(this, GlobalState.Instance.Connection); } break; case VideoRecordingState.Error: if (this.VideoRecordingError != null) { this.VideoRecordingError(this, GlobalState.Instance.Connection); } break; default: break; } GlobalState.Instance.videoRecordingState = videoRecordingState; } } void OnDestroy() { _virtualCameras.Clear(); _defaultVirtualCameras.Clear(); _workingCamera = null; } void OnApplicationQuit() { this.CloseConnection( this.GetCurrentActiveConnection(), GView.ConnectionCloseAction.None, GView.ConnectionCloseReason.UserRequested, string.Empty); GlobalState.DestroyInstance(); FARDll.CloseDown(); } IntPtr _hViewClient = IntPtr.Zero; FARDll.FAR_Status status = FARDll.FAR_Status.FAR_NotInitialized; /// ///通过f-ar接口读取屏幕信息后设置窗口位置 /// ///投屏窗口句柄 ///是否为3D预览窗口 public void UpdateWindowPos(IntPtr farwin) { F3Device.Screen.Monitor monitor = F3Device.DeviceManager.Instance.FindProjectionMonitor(F3DService.Instance.mainWindowHandle); if (monitor != null) { F3Device.Screen.RECT rect = monitor.m_MonitorInfo.rcMonitor; FARDll.MoveWindow(farwin, rect.Left, rect.Top, rect.Width, rect.Height, true); } else { UnityEngine.Debug.Log("Direct3DWin.UpdateWindows 没有找到投屏目标显示器"); } } private IEnumerator CreateFARWindow(GVirtualCamera virtualCamera) { yield return new WaitForEndOfFrame(); _hViewClient = FARDll.FindWindow(null, "ClientWinCpp"); status = FARDll.FAR_Status.FAR_NotInitialized; if (_hViewClient == IntPtr.Zero) { string _path = Path.Combine(Application.streamingAssetsPath, "ClientWin.exe"); System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo(); startInfo.FileName = _path; FARDll.viewProcess = new System.Diagnostics.Process(); FARDll.viewProcess.StartInfo = startInfo; FARDll.viewProcess.Start(); FARDll.viewProcess.WaitForInputIdle(); _hViewClient = FARDll.FindWindow(null, "ClientWinCpp"); } if (FARDll.viewProcess != null) { if (_hViewClient != IntPtr.Zero) { //全屏到非GC显示器 UpdateWindowPos(_hViewClient); int RTcount = 0; RenderTexture[] tempRTs = virtualCamera.GetRenderTexture(out RTcount); if (RTcount == 1) { status = (FARDll.FAR_Status)FARDll.StartView(_hViewClient, tempRTs[0].GetNativeTexturePtr(), IntPtr.Zero); } else if (RTcount == 2) { FARDll.SwitchProjector(FARDll.ProjectorType.LeftRight); status = (FARDll.FAR_Status)FARDll.StartView(_hViewClient, tempRTs[0].GetNativeTexturePtr(), tempRTs[1].GetNativeTexturePtr()); } } } else status = FARDll.FAR_Status.FAR_GraphicsCardUnsupported; if (status <= 0) { UnityEngine.Debug.LogError("Direct3DWin.CreateFARWindow 投屏启动失败" + status); FARDll.CloseDown(); } if (_GLIssueHandle != null) this.StopCoroutine(_GLIssueHandle); _GLIssueHandle = this.StartCoroutine(CallPluginAtEndOfFrames()); } private Coroutine _GLIssueHandle; private IEnumerator CallPluginAtEndOfFrames() { while (true) { yield return new WaitForEndOfFrame(); GL.IssuePluginEvent(FARDll.GetRenderEventFunc(), 1); } } /// /// 启动FAR投屏窗口 /// /// 投屏单张纹理或两张纹理 private void FARStartRenderingView(GVirtualCamera virtualCamera) { StartCoroutine(CreateFARWindow(virtualCamera)); } /// /// 初始化两个相机 /// private void InitializeVirtualCameras() { //CameraMode.Fixed, CameraMode目前都是固定的,不是跟踪头部的 _virtualCameras.Clear(); _defaultVirtualCameras.Clear(); _workingCamera = null; // Create the default virtual camera for standard mode. GameObject virtualCameraStandardObject = new GameObject("GVirtualCameraStandard"); virtualCameraStandardObject.transform.parent = this.transform; _cameraStandard = virtualCameraStandardObject.AddComponent(); _defaultVirtualCameras[GlobalState.Instance.ModeStandard] = _cameraStandard; _virtualCameras[GlobalState.Instance.ModeStandard] = _cameraStandard; GameObject virtualCameraThreeDObject = new GameObject("GVirtualCameraThreeD"); virtualCameraThreeDObject.transform.parent = this.transform; _cameraThreeD = virtualCameraThreeDObject.AddComponent(); _defaultVirtualCameras[GlobalState.Instance.ModeThreeD] = _cameraThreeD; _virtualCameras[GlobalState.Instance.ModeThreeD] = _cameraThreeD; // Create the default virtual camera for AR mode. GameObject virtualCameraARObject = new GameObject("GVirtualCameraAR"); virtualCameraARObject.transform.parent = this.transform; _cameraAR = virtualCameraARObject.AddComponent(); _defaultVirtualCameras[GlobalState.Instance.ModeAugmentedReality] = _cameraAR; _virtualCameras[GlobalState.Instance.ModeAugmentedReality] = _cameraAR; } /// /// Set up the current mode's virtual camera if there is /// a connection in the ModeActive state. This logic is necessary /// for the purpose of handling scene transitions between two zView-enabled /// scenes while a connection is currently active. /// private void HandleSceneTransition() { IntPtr connection = GlobalState.Instance.Connection; if (connection == IntPtr.Zero) { return; } CurVirtualCameraMode = GlobalState.Instance.virtualCameraMode; } private GVirtualCameraStandard _cameraStandard = null; private GVirtualCameraThreeD _cameraThreeD = null; private GVirtualCameraAR _cameraAR = null; /// /// 默认的录屏临时文件存放目录放桌面算了 /// private string tempRecFile { get { return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory), "FARRecording.mp4"); } } public enum FARError { Unknown = -1, Ok = 0, NoCalib = 1, // 没标定 NoLicense = 2, // 没证书 NoFFmpeg = 3, //没有ffmpeg程序 NoSendsignal = 4 //没有Sendsignal程序 } [DllImport("zCoreUnity", CallingConvention = CallingConvention.StdCall)] public static extern FARError xxGetARCameraPose(out Matrix4x4 matrix); [DllImport("zCoreUnity", CallingConvention = CallingConvention.StdCall)] private static extern FARError xxConnectToDefaultViewer(out IntPtr connect); /// /// 设置辅助exe的路径,其中ffmpeg用来开启录屏进程,sendsignal用来关闭录屏进程. /// 注,目前sendsignal.exe已经不需要了. /// /// ffmpeg.exe的路径 /// sendsignal.exe的路径 /// [DllImport("zCoreUnity", CallingConvention = CallingConvention.StdCall)] private static extern FARError xxSetEXE(string ffmpeg, string sendsignal = "sendsignal.exe"); [DllImport("zCoreUnity", CallingConvention = CallingConvention.StdCall)] private static extern bool xxGetVideoRecordingCapability(); [DllImport("zCoreUnity", CallingConvention = CallingConvention.StdCall)] private static extern FARError xxGetVideoRecordingState(out VideoRecordingState state); [DllImport("zCoreUnity", CallingConvention = CallingConvention.StdCall)] private static extern FARError xxStartScreenRec(string filePath); [DllImport("zCoreUnity", CallingConvention = CallingConvention.StdCall)] private static extern FARError xxStopScreenRec(); [DllImport("zCoreUnity", CallingConvention = CallingConvention.StdCall)] private static extern FARError xxSaveVideoRecording(string filePath); [DllImport("zCoreUnity", CallingConvention = CallingConvention.StdCall)] private static extern FARError xxDiscardVideoRecording(); #endregion } }