AkCommunication.h 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. /*******************************************************************************
  2. The content of this file includes portions of the AUDIOKINETIC Wwise Technology
  3. released in source code form as part of the SDK installer package.
  4. Commercial License Usage
  5. Licensees holding valid commercial licenses to the AUDIOKINETIC Wwise Technology
  6. may use this file in accordance with the end user license agreement provided
  7. with the software or, alternatively, in accordance with the terms contained in a
  8. written agreement between you and Audiokinetic Inc.
  9. Apache License Usage
  10. Alternatively, this file may be used under the Apache License, Version 2.0 (the
  11. "Apache License"); you may not use this file except in compliance with the
  12. Apache License. You may obtain a copy of the Apache License at
  13. http://www.apache.org/licenses/LICENSE-2.0.
  14. Unless required by applicable law or agreed to in writing, software distributed
  15. under the Apache License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES
  16. OR CONDITIONS OF ANY KIND, either express or implied. See the Apache License for
  17. the specific language governing permissions and limitations under the License.
  18. Copyright (c) 2023 Audiokinetic Inc.
  19. *******************************************************************************/
  20. /// \file AK/Comm/AkCommunication.h
  21. /// The main communication interface (between the in-game sound engine and
  22. /// authoring tool).
  23. /// \sa
  24. /// - \ref initialization_comm
  25. /// - \ref termination_comm
  26. #ifndef _AK_COMMUNICATION_H
  27. #define _AK_COMMUNICATION_H
  28. #include <AK/SoundEngine/Common/AkTypes.h>
  29. #include <AK/SoundEngine/Common/AkMemoryMgr.h>
  30. #include <AK/Tools/Common/AkPlatformFuncs.h>
  31. #define AK_COMM_SETTINGS_MAX_STRING_SIZE 64
  32. #define AK_COMM_SETTINGS_MAX_URL_SIZE 128
  33. /// Platform-independent initialization settings of communication module between the Wwise sound engine
  34. /// and authoring tool.
  35. /// \sa
  36. /// - AK::Comm::Init()
  37. struct AkCommSettings
  38. {
  39. AkCommSettings()
  40. : commSystem(AkCommSystem_Socket)
  41. {
  42. szAppNetworkName[0] = 0;
  43. szCommProxyServerUrl[0] = 0;
  44. }
  45. /// Ports used for communication between the Wwise authoring application and your game.
  46. /// All of these ports are opened in the game when Wwise communication is enabled.
  47. ///
  48. /// \sa
  49. /// - \ref initialization_comm_ports
  50. /// - AK::Comm::GetDefaultInitSettings()
  51. /// - AK::Comm::Init()
  52. struct Ports
  53. {
  54. /// Constructor
  55. Ports()
  56. : uDiscoveryBroadcast( AK_COMM_DEFAULT_DISCOVERY_PORT )
  57. #if defined( AK_COMM_NO_DYNAMIC_PORTS )
  58. , uCommand( AK_COMM_DEFAULT_DISCOVERY_PORT + 1 )
  59. #else
  60. , uCommand( 0 )
  61. #endif
  62. {
  63. }
  64. /// This is where the authoring application broadcasts "Game Discovery" requests
  65. /// to discover games running on the network. Default value: 24024.
  66. ///
  67. /// \warning Unlike the other port in this structure, this port cannot be dynamic: setting it
  68. /// to 0 will disable discovery. Refer to \ref initialization_comm_ports_discovery_broadcast
  69. /// for more details.
  70. AkUInt16 uDiscoveryBroadcast;
  71. /// Used by the "command" channel.
  72. /// \remark Set to 0 to request a dynamic/ephemeral port.
  73. AkUInt16 uCommand;
  74. };
  75. /// Ports used for communication between the Wwise authoring application and your game.
  76. /// \sa
  77. /// - \ref initialization_comm
  78. /// - AkCommSettings::Ports
  79. /// - AK::Comm::Init()
  80. Ports ports;
  81. /// Allows selecting the communication system used to connect remotely the Authoring tool on the device.
  82. enum AkCommSystem
  83. {
  84. AkCommSystem_Socket, /// The recommended default communication system
  85. AkCommSystem_HTCS /// HTCS when available only, will default to AkCommSystem_Socket if the HTCS system is not available.
  86. };
  87. /// Select the device of the communication system.
  88. /// By default, connecting to the Authoring tool
  89. /// \sa
  90. /// - \ref initialization_comm
  91. /// - AkCommSettings::AkCommSystem
  92. /// - AK::Comm::Init()
  93. AkCommSystem commSystem;
  94. /// Tells if the base console communication library should be initialized.
  95. /// If set to false, the game should load/initialize the console's communication library prior to calling this function.
  96. /// Set to false only if your game already use sockets before the sound engine initialization.
  97. /// Some consoles have critical requirements for initialization, see \ref initialization_comm_console_lib
  98. bool bInitSystemLib;
  99. /// Optional name that will be displayed over network remote connection of Wwise.
  100. /// It must be a NULL terminated string.
  101. char szAppNetworkName[AK_COMM_SETTINGS_MAX_STRING_SIZE];
  102. /// Optional URL of Comm proxy server (only applicable for platforms incapable of acting as raw UDP/TCP servers)
  103. char szCommProxyServerUrl[AK_COMM_SETTINGS_MAX_URL_SIZE];
  104. };
  105. namespace AK
  106. {
  107. namespace Comm
  108. {
  109. ///////////////////////////////////////////////////////////////////////
  110. /// @name Initialization
  111. //@{
  112. /// Initializes the communication module. When this is called, and AK::SoundEngine::RenderAudio()
  113. /// is called periodically, you may use the authoring tool to connect to the sound engine.
  114. ///
  115. /// \warning This function must be called after the sound engine and memory manager have
  116. /// been properly initialized.
  117. ///
  118. ///
  119. /// \remark The AkCommSettings structure should be initialized with
  120. /// AK::Comm::GetDefaultInitSettings(). You can then change some of the parameters
  121. /// before calling this function.
  122. ///
  123. /// \return
  124. /// - AK_Success if initialization was successful.
  125. /// - AK_InvalidParameter if one of the settings is invalid.
  126. /// - AK_InsufficientMemory if the specified pool size is too small for initialization.
  127. /// - AK_Fail for other errors.
  128. ///
  129. /// \sa
  130. /// - \ref initialization_comm
  131. /// - AK::Comm::GetDefaultInitSettings()
  132. /// - AkCommSettings::Ports
  133. AK_EXTERNAPIFUNC( AKRESULT, Init )(
  134. const AkCommSettings & in_settings///< Initialization settings.
  135. );
  136. /// Gets the last error from the OS-specific communication library.
  137. /// \return The system error code. Check the code in the platform manufacturer documentation for details about the error.
  138. AK_EXTERNAPIFUNC(AkInt32, GetLastError());
  139. /// Gets the communication module's default initialization settings values.
  140. /// \sa
  141. /// - \ref initialization_comm
  142. /// - AK::Comm::Init()
  143. AK_EXTERNAPIFUNC( void, GetDefaultInitSettings )(
  144. AkCommSettings & out_settings ///< Returned default initialization settings.
  145. );
  146. /// Terminates the communication module.
  147. /// \warning This function must be called before the memory manager is terminated.
  148. /// \sa
  149. /// - \ref termination_comm
  150. AK_EXTERNAPIFUNC( void, Term )();
  151. /// Terminates and reinitialize the communication module using current settings.
  152. ///
  153. /// \return
  154. /// - AK_Success if initialization was successful.
  155. /// - AK_InvalidParameter if one of the settings is invalid.
  156. /// - AK_InsufficientMemory if the specified pool size is too small for initialization.
  157. /// - AK_Fail for other errors.
  158. ///
  159. /// \sa
  160. /// - \ref AK::SoundEngine::iOS::WakeupFromSuspend()
  161. AK_EXTERNAPIFUNC( AKRESULT, Reset )();
  162. /// Get the initialization settings currently in use by the CommunicationSystem
  163. ///
  164. /// \return
  165. /// - AK_Success if initialization was successful.
  166. AK_EXTERNAPIFUNC( const AkCommSettings&, GetCurrentSettings )();
  167. /// Get the port currently in used by the command channel.
  168. ///
  169. /// \return
  170. /// - Port number.
  171. AK_EXTERNAPIFUNC( AkUInt16, GetCommandPort )();
  172. //@}
  173. }
  174. }
  175. #endif // _AK_COMMUNICATION_H