NIM Tools API  5.5.0
nim_audio_cpp.h
Go to the documentation of this file.
1 
8 #ifndef _NIM_TOOLS_SDK_CPP_AUDIO_H_
9 #define _NIM_TOOLS_SDK_CPP_AUDIO_H_
10 
11 #include <windows.h>
12 #include <string>
13 #include <list>
14 #include <functional>
15 #include <assert.h>
16 
21 namespace nim_audio
22 {
23 
24 #include "../../nim_tools_c_sdk/audio/nim_audio_def.h"
25 
29 class Audio
30 {
31 
32 public:
39  static bool Init(const std::wstring& user_data_parent_path,const std::wstring& dll_path = L"");
40 
45  static void Cleanup();
46 
55  static bool PlayAudio(const wchar_t* file_path, const char* call_id, const char* res_id, nim_audio_type audio_format);
56 
66  static bool PlayAudio(const wchar_t* file_path, const char* call_id, const char* res_id, nim_audio_type audio_format, int seek);
67 
72  static bool StopPlayAudio();
73 
79  static bool RegStartPlayCb(nim_rescode_id_cb cb);
80 
86  static bool RegStopPlayCb(nim_rescode_id_cb cb);
87 
93  static bool RegStartCaptureCb(nim_rescode_cb cb);
94 
100  static bool RegStopCaptureCb(nim_stop_capture_cb cb);
101 
107  static bool RegCancelAudioCb(nim_rescode_cb cb);
108 
118  static bool StartCapture(const char* call_id, const char* res_id, nim_audio_type audio_format = AAC, int volume = 180, const wchar_t* capture_device = nullptr);
119 
124  static bool StopCapture();
125 
130  static bool CancelAudio(const wchar_t* file_path);
131 
138 
143  static bool EnumCaptureDevice();
144 
145 private:
146  template <typename F>
147  static F Function(const char* function_name)
148  {
149  F f = (F) ::GetProcAddress(instance_audio_, function_name);
150  assert(f);
151  return f;
152  }
153 
154 private:
155  static HINSTANCE instance_audio_;
156 };
157 
158 }
159 
160 #endif //_NIM_TOOLS_SDK_CPP_AUDIO_H_
static void Cleanup()
static bool Init(const std::wstring &user_data_parent_path, const std::wstring &dll_path=L"")
static bool CancelAudio(const wchar_t *file_path)
static bool RegStopCaptureCb(nim_stop_capture_cb cb)
NIM 提供的语音录制和播放接口
Definition: nim_audio_cpp.h:29
static bool RegCancelAudioCb(nim_rescode_cb cb)
static bool RegStartCaptureCb(nim_rescode_cb cb)
NIM提供的语音播放工具
void(* nim_stop_capture_cb)(int rescode, const char *call_id, const char *res_id, const char *file_path, const char *file_ext, long file_size, int audio_duration)
Definition: nim_audio_def.h:62
static bool StopCapture()
static bool EnumCaptureDevice()
void(* nim_rescode_id_cb)(int rescode, const char *file_path, const char *call_id, const char *res_id)
Definition: nim_audio_def.h:49
static bool StopPlayAudio()
void(* nim_rescode_cb)(int)
Definition: nim_audio_def.h:40
static bool PlayAudio(const wchar_t *file_path, const char *call_id, const char *res_id, nim_audio_type audio_format)
static bool RegStopPlayCb(nim_rescode_id_cb cb)
void(* nim_enum_capture_device_cb)(int rescode, const wchar_t *device_list)
Definition: nim_audio_def.h:69
static bool StartCapture(const char *call_id, const char *res_id, nim_audio_type audio_format=AAC, int volume=180, const wchar_t *capture_device=nullptr)
static bool RegEnumCaptureDeviceCb(nim_enum_capture_device_cb cb)
static bool RegStartPlayCb(nim_rescode_id_cb cb)
nim_audio_type
Definition: nim_audio_def.h:30
Definition: nim_audio_def.h:32