ECSDKAudioManager.h 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. #ifndef ECSDKAUDIOMANAGER_H
  2. #define ECSDKAUDIOMANAGER_H
  3. #include "ECSDKTypes.h"
  4. namespace ECSDKFrameWork {
  5. /*!
  6. * \brief The base class of audio player object.
  7. *
  8. * A audio player is used to play audio data from our phone app.
  9. * You need to inherit and implement each interface
  10. *
  11. */
  12. class EC_DLL_EXPORT IECAudioPlayer
  13. {
  14. public:
  15. /*!
  16. * \brief Virtual destructor.
  17. */
  18. virtual ~IECAudioPlayer();
  19. /*!
  20. * \brief Used to start the audio player.
  21. *
  22. * \param type Audio types, including intercom, navigation, VR, music
  23. *
  24. * \param info Format of audio data
  25. *
  26. * \note This interface is called when the phone clicks to play music,
  27. * and you may need to initialize the audio decoder on this interface.
  28. */
  29. virtual void start(ECAudioType type, const ECAudioInfo& info) = 0;
  30. /*!
  31. * \brief Used to stop the audio player.
  32. *
  33. * \param type Audio types, including intercom, navigation, VR, music
  34. *
  35. * \note This interface is called back when the phone clicks to stop playing music.
  36. */
  37. virtual void stop(ECAudioType type) = 0;
  38. /*!
  39. * \brief Used to play the audio data.
  40. *
  41. * \note
  42. * - Before call this, you must ensure the audio player has been initialized successfully.\n
  43. * - A pure virtual function derived class must implement it.
  44. */
  45. virtual void play(ECAudioType type, const void* data, uint32_t len) = 0;
  46. /*!
  47. * \brief Used to set audio's volume.
  48. *
  49. * \param type Audio types, including intercom, navigation, VR, music
  50. *
  51. * \note A pure virtual function derived class must implement it.
  52. */
  53. virtual void setVolume(ECAudioType type, uint32_t vol) = 0;
  54. };
  55. /*!
  56. * \brief The base class of audio recorder object.
  57. *
  58. * A audio recorder is used to record by using the system microphone and upload audio data to our phone app.
  59. *
  60. */
  61. class EC_DLL_EXPORT IECAudioRecorder
  62. {
  63. public:
  64. /*!
  65. * \brief Virtual destructor.
  66. */
  67. virtual ~IECAudioRecorder();
  68. /*!
  69. * \brief Used to start the audio recorder.
  70. *
  71. * \param info Format of audio data
  72. *
  73. * \note When you tap the phone's microphone, this interface is called back,
  74. * and you get to initialize the recording device here
  75. */
  76. virtual void start(const ECAudioInfo& info) = 0;
  77. /**
  78. * @brief Used to provide recording data.
  79. *
  80. * @param data The object that holds the data
  81. *
  82. * @return 0 on successful operation, -1 on the microphone equipment is not ready, -2 on unknown error
  83. *
  84. * @note You need to implement this interface to provide the recording data.When the ECSDKFramework calls start,
  85. * a thread is started to invoke the interface to retrieve the recording data.
  86. *
  87. */
  88. virtual int32_t record(string& data) = 0;
  89. /*!
  90. * \brief Used to stop the audio recorder.
  91. *
  92. * \note A pure virtual function derived class must implement it.
  93. */
  94. virtual void stop() = 0;
  95. };
  96. /**
  97. * @brief The ECSDKAudioPlayer class
  98. */
  99. class EC_DLL_EXPORT ECSDKAudioManager
  100. {
  101. public:
  102. /**
  103. * @brief getInstance
  104. *
  105. * @return ECSDK_OK on success, others on fail.
  106. */
  107. static ECSDKAudioManager *getInstance();
  108. /**
  109. * @brief initialize
  110. * @param AideoPlayerObject
  111. * @return ECSDK_OK on success, others on fail.
  112. */
  113. virtual bool initialize(IECAudioPlayer* audeoPlayerObject, IECAudioRecorder* audioRecorder) = 0;
  114. /**
  115. * @brief release
  116. *
  117. * @return ECSDK_OK on success, others on fail.
  118. */
  119. virtual void release() = 0;
  120. /**
  121. * @brief enableDownloadPhoneAppAudio
  122. *
  123. * @param supportType : The type of audio to be transmitted, for example EC_AUDIO_TYPE_TTS | EC_AUDIO_TYPE_VR
  124. *
  125. * @return ECSDK_OK on success, others on fail.
  126. */
  127. virtual int32_t enableDownloadPhoneAppAudio(uint32_t supportType, bool autoChangeToBT = true) = 0;
  128. /**
  129. * @brief disableDownloadPhoneAppAudio
  130. *
  131. * @return ECSDK_OK on success, others on fail.
  132. */
  133. virtual int32_t disableDownloadPhoneAppAudio() = 0;
  134. /**
  135. * @brief Enable downloading system audio form phone.Current avaliable on iPhone Lighting Mode;
  136. *
  137. * @return EC_OK on success, others on fail.
  138. *
  139. * @note The audio type of the callback is EC_AUDIO_TYPE_MUSIC.
  140. *
  141. */
  142. virtual int32_t enableDownloadSystemAudio() = 0;
  143. /**
  144. * @brief Disable downloading system audio.
  145. *
  146. * @see enableDownloadSystemAudio
  147. */
  148. virtual void disableDownloadSystemAudio() = 0;
  149. /**
  150. * @brief Sets the caching time for audio data to be sent down from the phone. By default, it is not cached.
  151. *
  152. */
  153. virtual void setAudioCacheTime(uint32_t cacheTime) = 0;
  154. /**
  155. * @param enableDelay Whether to enable delay stop
  156. *
  157. * @param additionTime addition delay time
  158. *
  159. * @brief Whether to turn on to increase the stop delay based on the playback time of the data volume.
  160. *
  161. */
  162. virtual void enableAudioDelay(bool enableDelay, uint32_t additionTime = 0) = 0;
  163. /**
  164. * @brief This method will config Speech Enhancement parameters.
  165. *
  166. * @param key referred to EC_SE_PARAM_KEY_
  167. *
  168. * @param value the value to corresponding key.
  169. *
  170. * @note call this method before ECSDKFramework::start, then information with the config
  171. * will be send to connected phone when IECAudioRecorder::start trigered.
  172. * User just need to call this method once. The config will be always valid until next ECSDKFramework::start.
  173. */
  174. virtual int32_t configSEParam(const string& key, const string& value) = 0;
  175. protected:
  176. ECSDKAudioManager ();
  177. virtual ~ECSDKAudioManager();
  178. };
  179. }
  180. #endif // ECSDKAUDIOMANAGER_H