Initialer Upload neues Unity-Projekt

This commit is contained in:
Daniel Ocks
2025-07-21 09:11:14 +02:00
commit eeca72985b
14558 changed files with 1508140 additions and 0 deletions

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 10a5b9b665ad462cb8d1e8d6cde9bc11
timeCreated: 1630370518

View File

@ -0,0 +1,27 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
* All rights reserved.
*
* Licensed under the Oculus SDK License Agreement (the "License");
* you may not use the Oculus SDK except in compliance with the License,
* which is provided at the time of installation or download, or which
* otherwise accompanies this software in either electronic or hard copy form.
*
* You may obtain a copy of the License at
*
* https://developer.oculus.com/licenses/oculussdk/
*
* Unless required by applicable law or agreed to in writing, the Oculus SDK
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
namespace Oculus.Voice.Bindings.Android
{
public interface IVCBindingEvents
{
void OnServiceNotAvailable(string error, string message);
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: d01044a09129d474caffc360d188bd52
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,78 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
* All rights reserved.
*
* Licensed under the Oculus SDK License Agreement (the "License");
* you may not use the Oculus SDK except in compliance with the License,
* which is provided at the time of installation or download, or which
* otherwise accompanies this software in either electronic or hard copy form.
*
* You may obtain a copy of the License at
*
* https://developer.oculus.com/licenses/oculussdk/
*
* Unless required by applicable law or agreed to in writing, the Oculus SDK
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
using Meta.WitAi.Configuration;
using Oculus.Voice.Core.Bindings.Android;
using UnityEngine;
namespace Oculus.Voice.Bindings.Android
{
public class VoiceSDKBinding : BaseServiceBinding
{
public VoiceSDKBinding(AndroidJavaObject sdkInstance) : base(sdkInstance)
{
}
public bool Active => binding.Call<bool>("isActive");
public bool IsRequestActive => binding.Call<bool>("isRequestActive");
public bool MicActive => binding.Call<bool>("isMicActive");
public bool PlatformSupportsWit => binding.Call<bool>("isSupported");
public void Activate(string text, WitRequestOptions options)
{
binding.Call("activate", text, options.ToJsonString());
}
public void Activate(WitRequestOptions options)
{
binding.Call("activate", options.ToJsonString());
}
public void ActivateImmediately(WitRequestOptions options)
{
binding.Call("activateImmediately", options.ToJsonString());
}
public void Deactivate()
{
binding.Call("deactivate");
}
public void DeactivateAndAbortRequest()
{
binding.Call("deactivateAndAbortRequest");
}
public void SetRuntimeConfiguration(WitRuntimeConfiguration configuration)
{
binding.Call("setRuntimeConfig", new VoiceSDKConfigBinding(configuration).ToJavaObject());
}
public void SetListener(VoiceSDKListenerBinding listener)
{
binding.Call("setListener", listener);
}
public void Connect()
{
binding.Call<bool>("connect");
}
}
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 0d8c1d6d5b8545cfb741ca067158491a
timeCreated: 1630371197

View File

@ -0,0 +1,70 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
* All rights reserved.
*
* Licensed under the Oculus SDK License Agreement (the "License");
* you may not use the Oculus SDK except in compliance with the License,
* which is provided at the time of installation or download, or which
* otherwise accompanies this software in either electronic or hard copy form.
*
* You may obtain a copy of the License at
*
* https://developer.oculus.com/licenses/oculussdk/
*
* Unless required by applicable law or agreed to in writing, the Oculus SDK
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
using Meta.WitAi.Configuration;
using Meta.WitAi;
using UnityEngine;
namespace Oculus.Voice.Bindings.Android
{
public class VoiceSDKConfigBinding
{
private WitRuntimeConfiguration configuration;
public VoiceSDKConfigBinding(WitRuntimeConfiguration config)
{
configuration = config;
}
public AndroidJavaObject ToJavaObject()
{
AndroidJavaObject witConfig =
new AndroidJavaObject("com.oculus.assistant.api.voicesdk.immersivevoicecommands.WitConfiguration");
witConfig.Set("clientAccessToken", configuration.witConfiguration.GetClientAccessToken());
AndroidJavaObject witRuntimeConfig = new AndroidJavaObject("com.oculus.assistant.api.voicesdk.immersivevoicecommands.WitRuntimeConfiguration");
witRuntimeConfig.Set("witConfiguration", witConfig);
witRuntimeConfig.Set("minKeepAliveVolume", configuration.minKeepAliveVolume);
witRuntimeConfig.Set("minKeepAliveTimeInSeconds",
configuration.minKeepAliveTimeInSeconds);
witRuntimeConfig.Set("minTranscriptionKeepAliveTimeInSeconds",
configuration.minTranscriptionKeepAliveTimeInSeconds);
witRuntimeConfig.Set("maxRecordingTime",
configuration.maxRecordingTime);
witRuntimeConfig.Set("soundWakeThreshold",
configuration.soundWakeThreshold);
witRuntimeConfig.Set("sampleLengthInMs",
configuration.sampleLengthInMs);
witRuntimeConfig.Set("micBufferLengthInSeconds",
configuration.micBufferLengthInSeconds);
witRuntimeConfig.Set("sendAudioToWit",
configuration.sendAudioToWit);
witRuntimeConfig.Set("preferredActivationOffset",
configuration.preferredActivationOffset);
witRuntimeConfig.Set("clientName",
WitConstants.CLIENT_NAME);
witRuntimeConfig.Set("serverVersion",
WitConstants.API_VERSION);
return witRuntimeConfig;
}
}
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 114218fd50f24874adaaf0e91a865d75
timeCreated: 1630370973

View File

@ -0,0 +1,286 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
* All rights reserved.
*
* Licensed under the Oculus SDK License Agreement (the "License");
* you may not use the Oculus SDK except in compliance with the License,
* which is provided at the time of installation or download, or which
* otherwise accompanies this software in either electronic or hard copy form.
*
* You may obtain a copy of the License at
*
* https://developer.oculus.com/licenses/oculussdk/
*
* Unless required by applicable law or agreed to in writing, the Oculus SDK
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
using System;
using System.Collections.Generic;
using Meta.Voice;
using Meta.WitAi;
using Meta.WitAi.Configuration;
using Meta.WitAi.Events;
using Meta.WitAi.Interfaces;
using Meta.WitAi.Requests;
using Oculus.Voice.Core.Bindings.Android;
using Oculus.Voice.Interfaces;
using Debug = UnityEngine.Debug;
namespace Oculus.Voice.Bindings.Android
{
public class VoiceSDKImpl : BaseAndroidConnectionImpl<VoiceSDKBinding>,
IPlatformVoiceService, IVCBindingEvents
{
private bool _isServiceAvailable = true;
public Action OnServiceNotAvailableEvent;
private IVoiceService _baseVoiceService;
private bool _isActive;
public VoiceSDKImpl(IVoiceService baseVoiceService) : base(
"com.oculus.assistant.api.unity.immersivevoicecommands.UnityIVCServiceFragment")
{
_baseVoiceService = baseVoiceService;
}
public bool UsePlatformIntegrations
{
get => true;
set => throw new NotImplementedException();
}
public bool PlatformSupportsWit => service.PlatformSupportsWit && _isServiceAvailable;
public bool Active => service.Active && _isActive;
public bool IsRequestActive => service.IsRequestActive;
public bool MicActive => service.MicActive;
public void SetRuntimeConfiguration(WitRuntimeConfiguration configuration)
{
service.SetRuntimeConfiguration(configuration);
}
private VoiceSDKListenerBinding eventBinding;
public HashSet<VoiceServiceRequest> Requests { get; } = new HashSet<VoiceServiceRequest>();
public ITranscriptionProvider TranscriptionProvider { get; set; }
public bool CanActivateAudio()
{
return true;
}
public bool CanSend()
{
return true;
}
public override void Connect(string version)
{
base.Connect(version);
eventBinding = new VoiceSDKListenerBinding(this, this);
eventBinding.VoiceEvents.OnStoppedListening.AddListener(OnStoppedListening);
service.SetListener(eventBinding);
service.Connect();
Debug.Log(
$"Platform integration initialization complete. Platform integrations are {(PlatformSupportsWit ? "active" : "inactive")}");
}
public override void Disconnect()
{
base.Disconnect();
if (null != eventBinding)
{
eventBinding.VoiceEvents.OnStoppedListening.RemoveListener(OnStoppedListening);
}
}
private void OnStoppedListening()
{
_isActive = false;
}
public VoiceServiceRequest Activate(string text, WitRequestOptions requestOptions,
VoiceServiceRequestEvents requestEvents)
{
if (requestOptions == null)
{
requestOptions = new WitRequestOptions();
}
requestOptions.Text = text;
eventBinding.VoiceEvents.OnRequestOptionSetup?.Invoke(requestOptions);
VoiceServiceRequest request = GetRequest(requestOptions, requestEvents, NLPRequestInputType.Text);
request.Send();
return request;
}
public VoiceServiceRequest Activate(WitRequestOptions requestOptions,
VoiceServiceRequestEvents requestEvents)
{
if (_isActive) return null;
_isActive = true;
if (requestOptions == null)
{
requestOptions = new WitRequestOptions();
}
eventBinding.VoiceEvents.OnRequestOptionSetup?.Invoke(requestOptions);
VoiceServiceRequest request = GetRequest(requestOptions, requestEvents, NLPRequestInputType.Audio);
request.ActivateAudio();
return request;
}
public VoiceServiceRequest ActivateImmediately(WitRequestOptions requestOptions,
VoiceServiceRequestEvents requestEvents)
{
if (_isActive) return null;
_isActive = true;
if (requestOptions == null)
{
requestOptions = new WitRequestOptions();
}
eventBinding.VoiceEvents.OnRequestOptionSetup?.Invoke(requestOptions);
VoiceServiceRequest request = GetRequest(requestOptions, requestEvents, NLPRequestInputType.Audio, true);
request.ActivateAudio();
return request;
}
public void Deactivate()
{
_isActive = false;
foreach (var request in Requests)
{
if (request.InputType == NLPRequestInputType.Audio)
{
request.DeactivateAudio();
}
}
}
public void DeactivateAndAbortRequest()
{
_isActive = false;
foreach (var request in Requests)
{
if (request.InputType == NLPRequestInputType.Audio)
{
request.Cancel();
}
}
}
public void DeactivateAndAbortRequest(VoiceServiceRequest request)
{
if (!Requests.Contains(request))
{
return;
}
request.Cancel();
}
public void OnServiceNotAvailable(string error, string message)
{
_isActive = false;
_isServiceAvailable = false;
OnServiceNotAvailableEvent?.Invoke();
}
public VoiceEvents VoiceEvents
{
get => _baseVoiceService.VoiceEvents;
set => _baseVoiceService.VoiceEvents = value;
}
public TelemetryEvents TelemetryEvents
{
get => _baseVoiceService.TelemetryEvents;
set => _baseVoiceService.TelemetryEvents = value;
}
// Obtains a VoiceSDKImplRequest with specified parameters
private VoiceServiceRequest GetRequest(WitRequestOptions requestOptions,
VoiceServiceRequestEvents requestEvents,
NLPRequestInputType inputType,
bool audioImmediate = false)
{
VoiceSDKImplRequest request = new VoiceSDKImplRequest(service, inputType, audioImmediate, requestOptions, requestEvents);
Requests.Add(request);
request.Events.OnCancel.AddListener(OnRequestCanceled);
request.Events.OnFailed.AddListener(OnRequestFailed);
request.Events.OnSuccess.AddListener(OnRequestSuccess);
request.Events.OnComplete.AddListener(OnRequestComplete);
VoiceEvents?.OnRequestInitialized?.Invoke(request);
return request;
}
// Cancelation callback
private void OnRequestCanceled(VoiceServiceRequest request)
{
// Ignore if missing
if (!Requests.Contains(request))
{
return;
}
// Canceled
VLog.D($"Request Canceled\nReason: {request.Results.Message}");
VoiceEvents?.OnCanceled?.Invoke(request.Results.Message);
if (!string.Equals(request.Results.Message, WitConstants.CANCEL_MESSAGE_PRE_SEND))
{
VoiceEvents?.OnAborted?.Invoke();
}
}
// Failure callback
private void OnRequestFailed(VoiceServiceRequest request)
{
// Ignore if missing
if (!Requests.Contains(request))
{
return;
}
// Failed
VLog.D($"Request Failed\nError: {request.Results.Message}");
VoiceEvents?.OnError?.Invoke("HTTP Error " + request.Results.StatusCode, request.Results.Message);
VoiceEvents?.OnRequestCompleted?.Invoke();
}
// Success callback
private void OnRequestSuccess(VoiceServiceRequest request)
{
// Ignore if missing
if (!Requests.Contains(request))
{
return;
}
// Success
VLog.D("Request Success");
VoiceEvents?.OnResponse?.Invoke(request.Results.ResponseData);
VoiceEvents?.OnRequestCompleted?.Invoke();
}
// Request completed
private void OnRequestComplete(VoiceServiceRequest request)
{
// Ignore if missing
if (!Requests.Contains(request))
{
return;
}
// Remove listeners
request.Events.OnCancel.RemoveListener(OnRequestCanceled);
request.Events.OnFailed.RemoveListener(OnRequestFailed);
request.Events.OnSuccess.RemoveListener(OnRequestSuccess);
request.Events.OnComplete.RemoveListener(OnRequestComplete);
// Remove request
Requests.Remove(request);
VoiceEvents?.OnComplete?.Invoke(request);
}
}
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: a3943048f6aa4a49977131e8fb7f677d
timeCreated: 1630370598

View File

@ -0,0 +1,157 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
* All rights reserved.
*
* Licensed under the Oculus SDK License Agreement (the "License");
* you may not use the Oculus SDK except in compliance with the License,
* which is provided at the time of installation or download, or which
* otherwise accompanies this software in either electronic or hard copy form.
*
* You may obtain a copy of the License at
*
* https://developer.oculus.com/licenses/oculussdk/
*
* Unless required by applicable law or agreed to in writing, the Oculus SDK
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
using Meta.Voice;
using Meta.WitAi.Json;
using Meta.WitAi.Configuration;
using Meta.WitAi.Requests;
namespace Oculus.Voice.Bindings.Android
{
/// <summary>
/// A class generated by VoiceSDKImpl to track voice request calls
/// </summary>
public class VoiceSDKImplRequest : VoiceServiceRequest
{
public VoiceSDKBinding Service { get; private set; }
public bool Immediately { get; private set; }
#region CALLS
public VoiceSDKImplRequest(VoiceSDKBinding newService, NLPRequestInputType newInputType, bool newImmediately, WitRequestOptions newOptions,
VoiceServiceRequestEvents newEvents) : base(newInputType, newOptions, newEvents)
{
Service = newService;
Immediately = newImmediately;
}
protected override void HandleAudioActivation()
{
if (Immediately)
{
Service.ActivateImmediately(Options);
}
else
{
Service.Activate(Options);
}
SetAudioInputState(VoiceAudioInputState.On);
}
protected override void HandleAudioDeactivation()
{
Service.Deactivate();
SetAudioInputState(VoiceAudioInputState.Off);
}
protected override void HandleSend()
{
if (InputType == NLPRequestInputType.Text)
{
Service.Activate(Options.Text, Options);
}
}
protected override void HandleCancel()
{
Service.DeactivateAndAbortRequest();
}
#endregion
#region EVENTS
/// <summary>
/// Called audio is now listening
/// </summary>
public void HandleStartListening()
{
//NOT YET IMPLEMENTED
}
/// <summary>
/// Called audio is no longer listening
/// </summary>
public void HandleStopListening()
{
//NOT YET IMPLEMENTED
}
/// <summary>
/// Callback when in progress response data has been received
/// </summary>
/// <param name="responseJson">The unparsed json data</param>
public void HandlePartialResponse(string responseJson)
{
WitResponseNode responseData = WitResponseNode.Parse(responseJson);
HandlePartialNlpResponse(responseData);
}
/// <summary>
/// Called for partial transcription of text
/// </summary>
public void HandlePartialTranscription(string transcription)
{
ApplyTranscription(transcription, false);
}
/// <summary>
/// Called for final transcription of text
/// </summary>
public void HandleFullTranscription(string transcription)
{
ApplyTranscription(transcription, true);
}
/// <summary>
/// Transmission began
/// </summary>
public void HandleTransmissionBegan()
{
if (InputType == NLPRequestInputType.Audio)
{
Send();
}
}
/// <summary>
/// Called when an error message has been received
/// </summary>
public void HandleCanceled()
{
HandleCancel();
}
/// <summary>
/// Called when an error message has been received
/// </summary>
public void HandleError(string error, string message, string errorBody)
{
HandleFailure($"{error} - {message}");
}
/// <summary>
/// Callback when final response data has been received
/// </summary>
/// <param name="responseJson">The unparsed json data</param>
public void HandleResponse(string responseJson)
{
WitResponseNode responseData = WitResponseNode.Parse(responseJson);
HandleFinalNlpResponse(responseData, null);
}
#endregion
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 1f1f000e2fa84594da030e8e2d0b9c3b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,274 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
* All rights reserved.
*
* Licensed under the Oculus SDK License Agreement (the "License");
* you may not use the Oculus SDK except in compliance with the License,
* which is provided at the time of installation or download, or which
* otherwise accompanies this software in either electronic or hard copy form.
*
* You may obtain a copy of the License at
*
* https://developer.oculus.com/licenses/oculussdk/
*
* Unless required by applicable law or agreed to in writing, the Oculus SDK
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
using System;
using System.Collections.Generic;
using System.Linq;
using Meta.WitAi;
using Meta.WitAi.Events;
using Meta.WitAi.Requests;
using UnityEngine;
namespace Oculus.Voice.Bindings.Android
{
public class VoiceSDKListenerBinding : AndroidJavaProxy
{
private IVoiceService _voiceService;
private readonly IVCBindingEvents _bindingEvents;
public VoiceEvents VoiceEvents => _voiceService.VoiceEvents;
public TelemetryEvents TelemetryEvents => _voiceService.TelemetryEvents;
public enum StoppedListeningReason : int {
NoReasonProvided = 0,
Inactivity = 1,
Timeout = 2,
Deactivation = 3,
}
public VoiceSDKListenerBinding(IVoiceService voiceService, IVCBindingEvents bindingEvents) : base(
"com.oculus.assistant.api.voicesdk.immersivevoicecommands.IVCEventsListener")
{
_voiceService = voiceService;
_bindingEvents = bindingEvents;
}
// Get request for a specified request id
private VoiceServiceRequest GetRequest(string requestId)
{
HashSet<VoiceServiceRequest> requests = _voiceService.Requests;
if (requests == null || requests.Count == 0)
{
return null;
}
foreach (var request in requests)
{
string checkRequestId = request?.Options?.RequestId;
if (string.Equals(requestId, checkRequestId))
{
return request;
}
}
return requests.First();
}
/// <summary>
/// Callback for listening start
/// </summary>
public void onStartListening(string requestId)
{
// Event callbacks
VoiceEvents.OnStartListening?.Invoke();
}
public void onStartListening() => onStartListening(null);
/// <summary>
/// Callback for listening completion
/// </summary>
public void onStoppedListening(int reason, string requestId)
{
// Request callbacks
var request = GetRequest(requestId);
// Event callbacks
VoiceEvents.OnStoppedListening?.Invoke();
switch((StoppedListeningReason)reason){
case StoppedListeningReason.NoReasonProvided:
break;
case StoppedListeningReason.Inactivity:
VoiceEvents.OnStoppedListeningDueToInactivity?.Invoke();
request.Cancel();
break;
case StoppedListeningReason.Timeout:
VoiceEvents.OnStoppedListeningDueToTimeout?.Invoke();
request.Cancel();
break;
case StoppedListeningReason.Deactivation:
VoiceEvents.OnStoppedListeningDueToDeactivation?.Invoke();
request.Cancel();
break;
}
}
public void onStoppedListening(int reason) => onStoppedListening(reason, null);
/// <summary>
/// Request submission callback
/// </summary>
/// <param name="requestId">The associated unique request identifier</param>
public void onRequestCreated(string requestId)
{
// Request callbacks
var request = GetRequest(requestId);
if (request is VoiceSDKImplRequest implRequest)
{
implRequest.HandleTransmissionBegan();
}
// Event callbacks
#pragma warning disable CS0618
VoiceEvents.OnRequestCreated?.Invoke(null);
VoiceEvents.OnSend?.Invoke(null);
}
private void onRequestCreated() => onRequestCreated(null);
/// <summary>
/// Partial transcription set
/// </summary>
/// <param name="transcription"></param>
/// <param name="requestId"></param>
public void onPartialTranscription(string transcription, string requestId)
{
// Request callbacks
var request = GetRequest(requestId);
if (request is VoiceSDKImplRequest implRequest)
{
implRequest.HandlePartialTranscription(transcription);
}
// Partial transcription callback
VoiceEvents.OnPartialTranscription?.Invoke(transcription);
}
public void onPartialTranscription(string transcription) => onPartialTranscription(transcription, null);
/// <summary>
/// Final transcription received
/// </summary>
/// <param name="transcription"></param>
/// <param name="requestId"></param>
public void onFullTranscription(string transcription, string requestId)
{
// Request callbacks
var request = GetRequest(requestId);
if (request is VoiceSDKImplRequest implRequest)
{
implRequest.HandleFullTranscription(transcription);
}
// Transcription callback
VoiceEvents.OnFullTranscription?.Invoke(transcription);
}
public void onFullTranscription(string transcription) => onFullTranscription(transcription, null);
/// <summary>
/// Callback when early response data has been received
/// </summary>
/// <param name="responseJson">The unparsed json data</param>
/// <param name="requestId">The associated unique request identifier</param>
public void onPartialResponse(string responseJson, string requestId)
{
var request = GetRequest(requestId);
if (request is VoiceSDKImplRequest implRequest)
{
implRequest.HandlePartialResponse(responseJson);
}
}
public void onPartialResponse(string responseJson) => onPartialResponse(responseJson, null);
/// <summary>
/// Called when user request cancellation has occured
/// </summary>
/// <param name="requestId">The associated unique request identifier</param>
public void onAborted(string requestId)
{
var request = GetRequest(requestId);
if (request is VoiceSDKImplRequest implRequest)
{
implRequest.HandleCanceled();
}
}
public void onAborted() => onAborted(null);
/// <summary>
/// Called when an error message has been received
/// </summary>
/// <param name="error">The error itself</param>
/// <param name="message">The error message</param>
/// <param name="errorBody">The full body of the message</param>
/// <param name="requestId">The associated unique request identifier</param>
public void onError(string error, string message, string errorBody, string requestId)
{
var request = GetRequest(requestId);
if (request is VoiceSDKImplRequest implRequest)
{
implRequest.HandleError(error, message, errorBody);
}
}
public void onError(string error, string message, string errorBody) => onError(error, message, errorBody, null);
/// <summary>
/// Callback when response data has been received
/// </summary>
/// <param name="responseJson">The unparsed json data</param>
/// <param name="requestId">The associated unique request identifier</param>
public void onResponse(string responseJson, string requestId)
{
var request = GetRequest(requestId);
if (request is VoiceSDKImplRequest implRequest)
{
implRequest.HandleResponse(responseJson);
}
}
public void onResponse(string responseJson) => onResponse(responseJson, null);
public void onMicLevelChanged(float level, string requestId)
{
VoiceEvents.OnMicLevelChanged?.Invoke(level);
}
public void onMicLevelChanged(float level) => onMicLevelChanged(level, null);
public void onMicDataSent(string requestId)
{
VoiceEvents.OnMicDataSent?.Invoke();
}
public void onMicDataSent() => onMicDataSent(null);
public void onMinimumWakeThresholdHit(string requestId)
{
VoiceEvents.OnMinimumWakeThresholdHit?.Invoke();
}
public void onMinimumWakeThresholdHit() => onMinimumWakeThresholdHit(null);
public void onRequestCompleted(string requestId)
{
}
public void onRequestCompleted() => onRequestCompleted(null);
public void onServiceNotAvailable(string error, string message)
{
VLog.W($"Platform service is not available: {error} - {message}");
_bindingEvents.OnServiceNotAvailable(error, message);
}
public void onAudioDurationTrackerFinished(long timestamp, double duration)
{
long ticksElapsed = NativeTimestampToDateTime(timestamp).Ticks / TimeSpan.TicksPerMillisecond;
TelemetryEvents.OnAudioTrackerFinished?.Invoke(ticksElapsed, duration);
}
private DateTime NativeTimestampToDateTime(long javaTimestamp)
{
// Java timestamp is milliseconds past epoch
DateTime dateTime = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);
return dateTime.AddMilliseconds(javaTimestamp);
}
}
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: c4812e4a88b84256a571c7253e27799f
timeCreated: 1630371293