AkWaapiCalls.h 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. /*******************************************************************************
  2. The content of this file includes portions of the proprietary AUDIOKINETIC Wwise
  3. Technology released in source code form as part of the game integration package.
  4. The content of this file may not be used without valid licenses to the
  5. AUDIOKINETIC Wwise Technology.
  6. Note that the use of the game engine is subject to the Unreal(R) Engine End User
  7. License Agreement at https://www.unrealengine.com/en-US/eula/unreal
  8. License Usage
  9. Licensees holding valid licenses to the AUDIOKINETIC Wwise Technology may use
  10. this file in accordance with the end user license agreement provided with the
  11. software or, alternatively, in accordance with the terms contained
  12. in a written agreement between you and Audiokinetic Inc.
  13. Copyright (c) 2023 Audiokinetic Inc.
  14. *******************************************************************************/
  15. /*=============================================================================
  16. UAkWaapiCalls.h
  17. =============================================================================*/
  18. #pragma once
  19. #include "AkInclude.h"
  20. #include "Kismet/BlueprintFunctionLibrary.h"
  21. #include "AkWaapiUri.h"
  22. #include "AkWaapiJsonManager.h"
  23. #include "AkWaapiCalls.generated.h"
  24. /**
  25. * Structure for Field Names
  26. */
  27. USTRUCT(BlueprintType)
  28. struct AKAUDIO_API FAkWaapiSubscriptionId
  29. {
  30. GENERATED_BODY()
  31. FAkWaapiSubscriptionId() {}
  32. FAkWaapiSubscriptionId(const uint64_t& SubscribeId) : SubscriptionId(SubscribeId){}
  33. mutable uint64 SubscriptionId = 0;
  34. };
  35. DECLARE_DYNAMIC_DELEGATE_TwoParams(FOnEventCallback, FAkWaapiSubscriptionId, SubscriptionId, FAKWaapiJsonObject, WaapiJsonObject);
  36. DECLARE_DYNAMIC_DELEGATE(FOnWaapiProjectLoaded);
  37. DECLARE_DYNAMIC_DELEGATE(FOnWaapiConnectionLost);
  38. UCLASS(Within = World, config = Engine, defaultconfig)
  39. class AKAUDIO_API UAkWaapiCalls : public UBlueprintFunctionLibrary
  40. {
  41. GENERATED_BODY()
  42. public:
  43. UAkWaapiCalls(const class FObjectInitializer& ObjectInitializer);
  44. UFUNCTION(BlueprintCallable, Category = "Audiokinetic|WaapiCalls")
  45. static void SetSubscriptionID(const FAkWaapiSubscriptionId& Subscription, int id);
  46. UFUNCTION(BlueprintCallable, Category = "Audiokinetic|WaapiCalls")
  47. static int GetSubscriptionID(const FAkWaapiSubscriptionId& Subscription);
  48. /**
  49. * Subscribe to WAAPI project loaded event. This event will be broadcast whenever the correct Wwise project is loaded (defined by Wwise Project Path in the Wwise Plugin Settings). This should be used to initialize any resources that use WAAPI.
  50. *
  51. * @param Callback the event to call when a connection is established
  52. */
  53. UFUNCTION(BlueprintCallable, Category = "Audiokinetic|WaapiCalls")
  54. static bool RegisterWaapiProjectLoadedCallback(const FOnWaapiProjectLoaded& Callback);
  55. /**
  56. * Subscribe to WAAPI connection lost event. This event will be broadcast when the WAAPI connection is lost. This should be used to clean up any resources that use WAAPI.
  57. *
  58. * @param Callback the event to call when the connection is lost
  59. */
  60. UFUNCTION(BlueprintCallable, Category = "Audiokinetic|WaapiCalls")
  61. static bool RegisterWaapiConnectionLostCallback(const FOnWaapiConnectionLost& Callback);
  62. /**
  63. * Call Waapi and get/set information/parameters according to the uri chosen.
  64. *
  65. * @param WaapiUri The function that will be called when an event that we would be aware of happens.
  66. * @param WaapiArgs The arguments referenced to the in_uri function.
  67. * @param WaapiOptions Optional flag to get more information about the event happened.
  68. * @return out_result A JSON object that contains useful information about the Call process to a specific event, gets an error infos in case the Call fails.
  69. */
  70. UFUNCTION(BlueprintCallable, BlueprintCosmetic, Category = "Audiokinetic|WaapiCalls")
  71. static FAKWaapiJsonObject CallWaapi(const FAkWaapiUri& WaapiUri, const FAKWaapiJsonObject& WaapiArgs, const FAKWaapiJsonObject& WaapiOptions);
  72. /**
  73. * Allows clients to subscribe to notifications according to the event.
  74. *
  75. * @param WaapiUri The reference to the event that we would be aware of when it happens.
  76. * @param WaapiOptions Optional flag to get more information about the event happened.
  77. * @param in_callback A delegate to be executed during the subscription event.
  78. * @param out_subscriptionId Gets the id of this subscription.
  79. * @param out_result A boolean to ensure that the subscription was successfully done.
  80. * @return A JSON object that contains useful information about the subscription process to a specific event, gets an error infos in case the subscription failed.
  81. */
  82. UFUNCTION(BlueprintCallable, BlueprintCosmetic, Category = "Audiokinetic|WaapiCalls")
  83. static FAKWaapiJsonObject SubscribeToWaapi(const FAkWaapiUri& WaapiUri, const FAKWaapiJsonObject& WaapiOptions, const FOnEventCallback& CallBack, FAkWaapiSubscriptionId& SubscriptionId, bool& SubscriptionDone);
  84. /**
  85. * Unsubscribe from an event.
  86. *
  87. * @param SubscriptionId Gets the id of the current subscription to the event from which we want to be unsubscribed.
  88. * @param UnsubscriptionDone A boolean to ensure that the unsubscription was successfully done.
  89. * @return A JSON object that contains useful information about the unsubscription process from a specific event, gets an error infos in case the unsubscription failed.
  90. */
  91. UFUNCTION(BlueprintCallable, BlueprintCosmetic, Category = "Audiokinetic|WaapiCalls")
  92. static FAKWaapiJsonObject Unsubscribe(const FAkWaapiSubscriptionId& SubscriptionId, bool& UnsubscriptionDone);
  93. /** Converts an AkWaapiSubscriptionId value to a string */
  94. UFUNCTION(BlueprintPure, meta = (DisplayName = "ToString (FAkWaapiSubscriptionId)", CompactNodeTitle = "->", BlueprintAutocast), Category = "Utilities|String")
  95. static FString Conv_FAkWaapiSubscriptionIdToString(const FAkWaapiSubscriptionId& INAkWaapiSubscriptionId);
  96. /** Converts an AkWaapiSubscriptionId value to a localizable text */
  97. UFUNCTION(BlueprintPure, meta = (DisplayName = "ToText (FAkWaapiSubscriptionId)", CompactNodeTitle = "->", BlueprintAutocast), Category = "Utilities|Text")
  98. static FText Conv_FAkWaapiSubscriptionIdToText(const FAkWaapiSubscriptionId& INAkWaapiSubscriptionId);
  99. };