/// <summary>
 /// Sets the license server for DRM videos (should not be called)
 /// </summary>
 /// <param name="licenseServer">(unused) URL of the License Server</param>
 public void SetLicenseServer(string licenseServer)
 {
     if (!string.IsNullOrEmpty(licenseServer))
     {
         MLPluginLog.Warning("MLMediaPlayerEditor.SetLicenseServer failed, editor version of MLMediaPlayer does not support DRM.");
     }
 }
 /// <summary>
 /// Sets a custom function to custom parse the license response.
 /// The default implementation, setting this to null, will treat the entire response as the raw license data.
 /// </summary>
 /// <param name="responseParser">
 /// (unused) Function to parse license response.
 /// First parameter is the DRM track being processed, either Video or Audio.
 /// Second parameter is the byte[] containing the response we received from the license server.
 /// Return is the byte[] which will be the raw license data, base64 decoding if necessary.
 /// </param>
 public void SetCustomLicenseResponseParser(MLMediaPlayer.MediaPlayerCustomLicenseDelegate responseParser)
 {
     if (responseParser != null)
     {
         MLPluginLog.Warning("MLMediaPlayerEditor.SetCustomLicenseResponseParser failed, editor version of MLMediaPlayer does not support DRM.");
     }
 }
 /// <summary>
 /// Set custom key request key-value pair parameters used when generating default key request.
 /// </summary>
 /// <param name="messageData">(unused) Dictionary of optional key-value pair parameters</param>
 public void SetCustomLicenseMessageData(Dictionary <string, string> messageData)
 {
     if (messageData != null)
     {
         MLPluginLog.Warning("MLMediaPlayerEditor.SetCustomLicenseMessageData failed, editor version of MLMediaPlayer does not support DRM.");
     }
 }
            /// <summary>
            /// ReleaseClientCredentials releases all resources associated with the
            /// MLTokenAgentClientCredentials structure that was returned by the library.
            /// </summary>
            /// <param name="clientCredentials">Reference to the clientCredentials object.</param>
            public static void CleanupClientCredentialsMemory(MLTokenAgent.ClientCredentials clientCredentials)
            {
                if (clientCredentials.CurrentRequest != null)
                {
                    MLPluginLog.Warning("This client has an ongoing request and cannot have it's memory released.");
                }

                IntPtr clientCredentialsPtr = clientCredentialsPtrMap.ContainsKey(clientCredentials) ? clientCredentialsPtrMap[clientCredentials] : IntPtr.Zero;

                if (clientCredentialsPtr != IntPtr.Zero)
                {
                    try
                    {
                        MLResult.Code resultCode = MLTokenAgent.NativeBindings.MLTokenAgentReleaseClientCredentials(clientCredentialsPtr);

                        if (resultCode != MLResult.Code.Ok)
                        {
                            MLPluginLog.ErrorFormat("MLTokenAgent.CleanupClientCredentialsMemory failed. Reason: {0}", resultCode);
                        }
                    }
                    catch (EntryPointNotFoundException)
                    {
                        MLPluginLog.Error("MLTokenAgent.CleanupClientCredentialsMemory failed. Reason: API symbols not found.");
                    }
                }
            }
            /// <summary>
            /// Invokes the MLTokenAgentGetClientCredentials() function asynchronously (in a different thread).
            /// </summary>
            /// <param name="clientCredentials">Reference to the clientCredentials object.</param>
            /// <returns>
            /// MLResult.Result will be <c>MLResult.Code.Ok</c> if the operation completed successfully.
            /// MLResult.Result will be <c>MLResult.Code.UnspecifiedFailure</c> if the operation failed with an unspecified error.
            /// MLResult.Result will be <c>MLResult.Code.InvalidParam</c> if the profile or out_future were 0 (null).
            /// MLResult.Result will be <c>MLResult.Code.AllocFailed</c> if the operation failed to allocate memory.
            /// MLResult.Result will be <c>MLResult.Code.PrivilegeDenied</c> if the caller does not have the ClientCredentialsRead privilege.
            /// MLResult.Result will be <c>MLResult.Code.TokenAgent*</c> if a token specific failure occurred during the operation.
            /// </returns>
            public static MLResult.Code RequestClientCredentialsAsync(MLTokenAgent.ClientCredentials clientCredentials)
            {
                IntPtr clientCredentialsFuturePtr = clientCredentialsFuturePtrMap.ContainsKey(clientCredentials) ? clientCredentialsFuturePtrMap[clientCredentials] : IntPtr.Zero;

                try
                {
                    MLResult.Code resultCode = MLTokenAgent.NativeBindings.MLTokenAgentGetClientCredentialsAsync(ref clientCredentialsFuturePtr);

                    if (MLResult.IsOK(resultCode))
                    {
                        clientCredentialsFuturePtrMap.Remove(clientCredentials);
                        clientCredentialsFuturePtrMap.Add(clientCredentials, clientCredentialsFuturePtr);
                    }
                    else if (resultCode == MLResult.Code.PrivilegeDenied)
                    {
                        MLPluginLog.Warning("MLTokenAgent.NativeBindings.RequestClientCredentialsAsync failed. Reason: Caller does not have IdentityRead Privilege.");
                    }
                    else
                    {
                        MLPluginLog.ErrorFormat("MLTokenAgent.NativeBindings.RequestClientCredentialsAsync failed. Reason: {0}", resultCode);
                    }

                    return(resultCode);
                }
                catch (EntryPointNotFoundException)
                {
                    MLPluginLog.Error("MLTokenAgent.NativeBindings.RequestClientCredentialsAsync failed. Reason: API symbols not found.");
                    return(MLResult.Code.UnspecifiedFailure);
                }
            }
Ejemplo n.º 6
0
        /// <summary>
        /// Returns a list of all the PCFs of the types provided by the typesMask inside the current map.
        /// </summary>
        /// <param name="pcfList">Stores the resulting list of PCFs.</param>
        /// <param name="maxResults">The max number of PCFs to get.</param>
        /// <param name="typesMask">The bitmask of which PCF types to consider.</param>
        /// <param name="update">Determines if the PCFs should have their pose updated.</param>
        /// <returns>
        /// MLResult.Result will be <c>MLResult.Code.Ok</c> if all the PCFs from the current map have been found successfully.
        /// MLResult.Result will be <c>MLResult.Code.PrivilegeDenied</c> if necessary privilege is missing.
        /// MLResult.Result will be <c>MLResult.Code.UnspecifiedFailure</c> if failed due to other internal error.
        /// MLResult.Result will be <c>MLResult.Code.PassableWorldLowMapQuality</c> if map quality is too low for content persistence. Continue building the map.
        /// MLResult.Result will be <c>MLResult.Code.PassableWorldUnableToLocalize</c> if currently unable to localize into any map. Continue building the map.
        /// </returns>
        public static MLResult FindAllPCFs(out List <PCF> pcfList, uint maxResults = int.MaxValue, PCF.Types typesMask = PCF.Types.SingleUserSingleSession | PCF.Types.SingleUserMultiSession | PCF.Types.MultiUserMultiSession, bool update = true)
        {
            pcfList = new List <PCF>();

            if (MLPersistentCoordinateFrames.IsValidInstance())
            {
                QueryFilter queryFilter = QueryFilter.Create();
                queryFilter.TypesMask  = typesMask;
                queryFilter.MaxResults = maxResults;
                queryFilter.Sorted     = false;

                MLResult result = FindPCFsByFilter(queryFilter, out pcfList, update);

                if (!result.IsOk)
                {
                    if (result.Result == MLResult.Code.PassableWorldLowMapQuality || result.Result == MLResult.Code.PassableWorldUnableToLocalize)
                    {
                        MLPluginLog.Warning("Map quality not sufficient enough for MLPersistentCoordinateFrames.FindAllPCFs.");
                    }
                    else
                    {
                        MLPluginLog.ErrorFormat("MLPersistentCoordinateFrames.FindAllPCFs failed. Reason: {0}", result);
                    }
                }

                return(result);
            }
            else
            {
                MLPluginLog.ErrorFormat("MLPersistentCoordinateFrames.FindAllPCFs failed. Reason: No Instance for MLPersistentCoordinateFrames.");
                return(MLResult.Create(MLResult.Code.UnspecifiedFailure, "MLPersistentCoordinateFrames.FindAllPCFs failed. Reason: No Instance for MLPersistentCoordinateFrames."));
            }
        }
        /// <summary>
        /// Retrieves the latest head-pose state.
        /// </summary>
        private void UpdateHeadposeState()
        {
            MLResult result = MLHeadTracking.GetState(out State headTrackingState);

            if (!result.IsOk)
            {
                if (this.headTrackingErrorTimer.LimitPassed)
                {
                    MLPluginLog.ErrorFormat("MLHeadTracking.UpdateHeadposeState failed to get head pose state. Reason: {0}", result);
                    this.headTrackingErrorTimer.Reset();
                }

                return;
            }
            else if (result.IsOk && this.lastHeadTrackingGetStateResult != MLResult.Code.Ok)
            {
                MLPluginLog.Warning("MLHeadTracking.UpdateHeadposeState is able to get head pose state again");
            }

            this.lastHeadTrackingGetStateResult = result.Result;

            bool headTrackingModeChanged = this.lastHeadTrackingState.Mode != headTrackingState.Mode;

            this.lastHeadTrackingState = headTrackingState;

            if (headTrackingModeChanged)
            {
                this.OnHeadTrackingModeChanged?.Invoke(headTrackingState);
            }
        }
Ejemplo n.º 8
0
 /// <summary>
 /// Validates that <c>QueryParams</c> passed in are valid and fixes them otherwise.
 /// </summary>
 /// <param name="queryParams">The <c>QueryParams</c> to verify</param>
 private void ValidateQueryParams(ref QueryParams queryParams)
 {
     if (queryParams.BoundsRotation.x == 0 && queryParams.BoundsRotation.y == 0 &&
         queryParams.BoundsRotation.z == 0 && queryParams.BoundsRotation.w == 0)
     {
         MLPluginLog.Warning("MLPlanes.ValidateQueryParams contained an uninitialized Quaternion for BoundsRotation, setting it to (Quaternion.identity).");
         queryParams.BoundsRotation = Quaternion.identity;
     }
 }
Ejemplo n.º 9
0
        /// <summary>
        /// Requests to change MTU size.
        /// The results of this call are delivered to the MLBluetoohLE.OnBluetoothMTUSizeChanged callback.
        /// </summary>
        /// <param name="mtu">The characteristic to write on the remote device</param>
        /// <returns>Returns <c>MLResult.Code.Ok</c> on success or an error on failure.</returns>
        public static MLResult ChangeMTUSize(int mtu)
        {
            if (mtu < MinMTUSize)
            {
                MLPluginLog.Warning($"MTU size {mtu} is less than the minimum of {MinMTUSize}.");
            }

            else if (mtu > MaxMTUSize)
            {
                MLPluginLog.Warning($"MTU size {mtu} is greater than the maximum of {MaxMTUSize}.");
            }

            return(MLResult.Create(NativeBindings.MLBluetoothGattRequestMtu(Mathf.Clamp(mtu, MinMTUSize, MaxMTUSize))));
        }
            /// <summary>
            /// Having made a call to MLTokenAgentGetClientCredentialsAsync(), the user can call MLTokenAgentGetClientCredentialsWait()
            /// to detect whether the asynchronous call completed and if so, to retrieve the credentials in out_credentials.
            /// </summary>
            /// <param name="clientCredentials">Reference to the clientCredentials object.</param>
            /// <param name="credentials">Reference to the credentials struct of the clientCredentials object.</param>
            /// <param name="tokens">Reference to the tokens struct of the clientCredentials object.</param>
            /// <returns>
            /// MLResult.Result will be <c>MLResult.Code.Ok</c> if the operation completed successfully before the timeout elapsed.
            /// MLResult.Result will be <c>MLResult.Code.Pending</c> if the timeout elapsed before the asynchronous call completed.
            /// MLResult.Result will be <c>MLResult.Code.UnspecifiedFailure</c> if the operation failed with an unspecified error.
            /// MLResult.Result will be <c>MLResult.Code.InvalidParam</c> if the future or out_credentials were 0 (null).
            /// MLResult.Result will be <c>MLResult.Code.AllocFailed</c> if the operation failed to allocate memory.
            /// MLResult.Result will be <c>MLResult.Code.PrivilegeDenied</c> if the caller does not have the ClientCredentialsRead privilege.
            /// MLResult.Result will be <c>MLResult.Code.TokenAgent*</c> if a token specific failure occurred during the operation.
            /// </returns>
            public static MLResult.Code ListenClientCredentialsResponse(MLTokenAgent.ClientCredentials clientCredentials, ref MLTokenAgent.Credentials credentials, ref MLTokenAgent.Tokens tokens)
            {
                try
                {
                    IntPtr clientCredentialsPtr       = clientCredentialsPtrMap.ContainsKey(clientCredentials) ? clientCredentialsPtrMap[clientCredentials] : IntPtr.Zero;
                    IntPtr clientCredentialsFuturePtr = clientCredentialsFuturePtrMap.ContainsKey(clientCredentials) ? clientCredentialsFuturePtrMap[clientCredentials] : IntPtr.Zero;

                    if (clientCredentialsFuturePtr == IntPtr.Zero)
                    {
                        MLPluginLog.Warning("MLTokenAgent.NativeBindings.ListenClientCredentialsResponse failed because a valid future pointer could not be found with the passed request.");
                        return(MLResult.Code.UnspecifiedFailure);
                    }

                    //// Attempt to get data if available, 0 is passed as a timeout to immediately return and never wait for results.
                    MLResult.Code resultCode = MLTokenAgent.NativeBindings.MLTokenAgentGetClientCredentialsWait(clientCredentialsFuturePtr, 0, ref clientCredentialsPtr);

                    // If it succeeded, copy any modifications made to the profile in unmanaged memory by the Identity API to managed memory.
                    if (MLResult.IsOK(resultCode))
                    {
                        clientCredentialsFuturePtrMap.Remove(clientCredentials);

                        clientCredentialsPtrMap.Remove(clientCredentials);
                        clientCredentialsPtrMap.Add(clientCredentials, clientCredentialsPtr);

                        MLTokenAgent.NativeBindings.ClientCredentialsNative clientCredentialsNative = (MLTokenAgent.NativeBindings.ClientCredentialsNative)Marshal.PtrToStructure(clientCredentialsPtr, typeof(MLTokenAgent.NativeBindings.ClientCredentialsNative));
                        credentials = clientCredentialsNative.Credentials;
                        tokens      = clientCredentials.Tokens;
                    }
                    else
                    {
                        credentials = new Credentials();
                        tokens      = new Tokens();
                    }

                    return(resultCode);
                }
                catch (EntryPointNotFoundException)
                {
                    MLPluginLog.Error("MLTokenAgent.NativeBindings.ListenClientCredentialsResponse failed. Reason: API symbols not found.");
                    return(MLResult.Code.UnspecifiedFailure);
                }
            }
        /// <summary>
        /// Starts the image tracker with the specified settings.
        /// </summary>
        /// <param name="customSettings">The settings to start the image tracker with.</param>
        /// <returns>
        /// MLResult.Result will be <c>MLResult.Code.Ok</c> if successful.
        /// MLResult.Result will be <c>MLResult.Code.InvalidParam</c> if failed due to internal invalid input parameter.
        /// MLResult.Result will be <c>MLResult.Code.UnspecifiedFailure</c> if failed due to internal error.
        /// MLResult.Result will be <c>MLResult.Code.PrivilegeDenied</c> if image tracker was not created due to lack of privilege(s).
        /// </returns>
        public static MLResult Start(MLImageTracker.Settings customSettings)
        {
            var  settings = new NativeBindings.MLImageTrackerSettingsNative(customSettings);
            bool hasInstanceWithDifferentSettings = false;

            if ((MLImageTracker._instance != null) && (settings != MLImageTracker.Instance.trackerSettings))
            {
                MLPluginLog.Warning("MLImageTracker.Start, starting image tracking multiple times with different settings. New settings will be ignored.");
                hasInstanceWithDifferentSettings = true;
            }

            CreateInstance();

            if (!hasInstanceWithDifferentSettings)
            {
                MLImageTracker.Instance.trackerSettings = settings;
            }

            return(MLImageTracker.BaseStart(true));
        }
 /// <summary>
 /// Returns dictionary with information for all available tracks, not available for editor.
 /// </summary>
 /// <param name="localMediaPlayerID">(unused) ID of the media player</param>
 /// <returns>
 /// Dictionary of track data for each track.
 /// </returns>
 public Dictionary <long, MLMediaPlayer.TrackData> GetAllTrackInfo(int localMediaPlayerID)
 {
     MLPluginLog.Warning("MLMediaPlayer.GetAllTrackInfo is only available on device");
     return(new Dictionary <long, MLMediaPlayer.TrackData>());
 }
 /// <summary>
 /// Set the unique id on this player.
 /// This function needs to be called before the media player is prepared.
 /// The id should be unique across all media player sessions that are being shared.
 /// Once the id is set, then it can not be changed.
 /// Prepare will give an error if the ID is set and not unique.
 /// </summary>
 /// <param name="localMediaPlayerID">ID of the media player</param>
 /// <param name="ID">Unique ID for this player.</param>
 public void SetID(int localMediaPlayerID, int ID)
 {
     MLPluginLog.Warning("MLMediaPlayerEditor.SetID is only available on device.");
 }
 /// <summary>
 /// Unselects the subtitle track, not available for editor.
 /// </summary>
 /// <param name="localMediaPlayerID">(unused) ID of the media player</param>
 /// <param name="trackID">(unused) track id to be selected</param>
 /// <returns>
 /// <c>MLResult.Result</c> will be <c>MLResult.Code.NotImplemented</c>
 /// </returns>
 public MLResult UnselectSubtitleTrack(int localMediaPlayerID, uint trackID)
 {
     MLPluginLog.Warning("MLMediaPlayer.UnselectSubtitleTrack is only available on device");
     return(MLResult.Create(MLResult.Code.NotImplemented));
 }
 /// <summary>
 /// Sets a threshold to drop video frames if they are older than specified value.
 /// Setting this to 0 will not drop any frames, this is the default behavior.
 /// </summary>
 /// <param name="localMediaPlayerID">(unused) ID of the media player.</param>
 /// <param name="threshold">(unused) New threshold in milliseconds.</param>
 public void SetFrameDropThresholdMs(int localMediaPlayerID, ulong threshold)
 {
     MLPluginLog.Warning("MLMediaPlayerEditor.SetFrameDropThresholdMs is only available on device.");
 }
 /// <summary>
 /// Sets sharing information for the media player being shared and enables only functionality
 /// for synchronize the content playback. Follower setting can only be set before video has been prepared.
 /// </summary>
 /// <param name="localMediaPlayerID">(unused) ID of the media player</param>
 /// <param name="sharedType">(unused) The shared type for the current media player from enum SharedType.</param>
 /// <param name="sessionID">(unused) Unique Identifier of the sharing session in which the media players are being shared.</param>
 /// <param name="isPrepared">(unused) Indicates if the media player has been prepared.</param>
 /// <returns>
 /// <c>MLResult.Result</c> will be <c>MLResult.Code.NotImplemented</c>
 /// </returns>
 public MLResult SetSharingInfo(int localMediaPlayerID, MLMediaPlayer.SharedType sharedType, string sessionID, bool isPrepared)
 {
     MLPluginLog.Warning("MLMediaPlayerEditor.SetSharingInfo is only available on device.");
     return(MLResult.Create(MLResult.Code.NotImplemented));
 }
 /// <summary>
 /// Gets active audio channel count.
 /// </summary>
 /// <param name="localMediaPlayerID">(unused) ID of the media player</param>
 /// <param name="outAudioChannelCount">(unused) Return channel count.</param>
 /// <returns>
 /// <c>MLResult.Result</c> will be <c>MLResult.Code.NotImplemented</c>
 /// </returns>
 public MLResult GetAudioChannelCount(int localMediaPlayerID, out int outAudioChannelCount)
 {
     outAudioChannelCount = 1;
     MLPluginLog.Warning("MLMediaPlayer.GetAudioChannelCount is only available on device");
     return(MLResult.Create(MLResult.Code.NotImplemented));
 }
 /// <summary>
 /// Gets the frame drop threshold.
 /// </summary>
 /// <param name="localMediaPlayerID">(unused) ID of the media player.</param>
 /// <returns>The currently set millisecond threshold.</returns>
 public ulong GetFrameDropThresholdMs(int localMediaPlayerID)
 {
     MLPluginLog.Warning("MLMediaPlayerEditor.GetFrameDropThresholdMs is only available on device.");
     return(long.MaxValue);
 }
 /// <summary>
 /// Sets spatial audio state.
 /// </summary>
 /// <param name="localMediaPlayerID">(unused) ID of the media player</param>
 /// <param name="isEnabled">(unused) Desired state of spatial audio.</param>
 /// <returns>
 /// <c>MLResult.Result</c> will be <c>MLResult.Code.NotImplemented</c>
 /// </returns>
 public MLResult SetSpatialAudio(int localMediaPlayerID, bool isEnabled)
 {
     MLPluginLog.Warning("MLMediaPlayer.SetSpatialAudioEnable is only available on device");
     return(MLResult.Create(MLResult.Code.NotImplemented));
 }
 /// <summary>
 /// Gets spatial audio state.
 /// </summary>
 /// <param name="localMediaPlayerID">(unused) ID of the media player</param>
 /// <param name="outIsEnabled">(unused) Return state of spatial audio.</param>
 /// <returns>
 /// <c>MLResult.Result</c> will be <c>MLResult.Code.NotImplemented</c>
 /// </returns>
 public MLResult GetSpatialAudio(int localMediaPlayerID, out bool outIsEnabled)
 {
     outIsEnabled = false;
     MLPluginLog.Warning("MLMediaPlayer.GetSpatialAudioEnable is only available on device");
     return(MLResult.Create(MLResult.Code.NotImplemented));
 }
 /// <summary>
 /// Get the video track bitrate
 /// </summary>
 /// <param name="localMediaPlayerID">(unused) ID of the media player</param>
 /// <returns>The bitrate of the video track</returns>
 public int GetVideoBitrate(int localMediaPlayerID)
 {
     MLPluginLog.Warning("MLMediaPlayerEditor.GetVideoBitrate failed, editor version of MLMediaPlayer does not support bitrate.");
     return(0);
 }
 /// <summary>
 /// Register a request to get the bytes used for a DRM key request.
 /// </summary>
 /// <param name="drmUUIDBytes">Bytes identifying the desired DRM type.</param>
 /// <param name="callback">Callback to be called when successfully retrieved request data.</param>
 /// <returns>
 /// True if request was successfully registered.
 /// </returns>
 public bool RequestActivationKeyRequest(byte[] drmUUIDBytes, Action <MLResult, byte[], string> callback)
 {
     MLPluginLog.Warning("MLMediaPlayerEditor.RequestActivationKeyRequest failed, editor version of MLMediaPlayer does not support DRM.");
     return(false);
 }
 /// <summary>
 /// Gets world position of requested audio channel.
 /// </summary>
 /// <param name="localMediaPlayerID">(unused) ID of the media player</param>
 /// <param name="channel">(unused) Selects the channel whose position is being read.</param>
 /// <param name="position">(unused) Return selected channel's world position</param>
 /// <returns>
 /// <c>MLResult.Result</c> will be <c>MLResult.Code.NotImplemented</c>
 /// </returns>
 public MLResult GetAudioChannelPosition(int localMediaPlayerID, MLMediaPlayer.AudioChannel channel, out Vector3 position)
 {
     position = new Vector3(0f, 0f, 0f);
     MLPluginLog.Warning("MLMediaPlayer.GetAudioChannelPosition is only available on device");
     return(MLResult.Create(MLResult.Code.NotImplemented));
 }