SOUND4 x1.CLOUD Library [1.4.5]
sound4.x1.cloud.hpp
Go to the documentation of this file.
1 
4 #pragma once
5 
6 #include <string>
7 #include <exception>
8 #include <thread>
9 #include <functional>
10 #include <memory>
11 #include <array>
12 #include <assert.h>
13 #include <stdexcept>
14 #include <filesystem>
15 #include <string.h>
16 
17 #include "sound4.x1.cloud.h"
18 
19 
20 // Filesystem path char type
21 #ifdef _WIN32
22  #include <stringapiset.h>
23  #include <wchar.h>
25  #define fs_strdup wcsdup
26 #else // !_WIN32
28  #define fs_strdup strdup
29 #endif // !_WIN32
30 
31 // bridge C callbacks to CPresetLoader
32 extern "C" {
33  static char *cloudx1_custom_reader(const fs_char *filename, void* userdata);
34  static void cloudx1_custom_reader_free(char *content, void* userdata);
35  static int cloudx1_custom_writer(const fs_char *filename, const char *content, void* userdata);
36  static int cloudx1_custom_exists(const fs_char *filename, void* userdata);
37  static fs_char** cloudx1_custom_getall(void* userdata);
38  static void cloudx1_custom_getall_free(fs_char** all, void* userdata);
39  static int cloudx1_custom_remove(const fs_char *filename, void* userdata);
40  static int cloudx1_custom_rename(const fs_char *from, const fs_char *to, void* userdata);
41 };
42 
46 namespace sound4 {
50 namespace cloudx1 {
51  static constexpr const char *process_name = "SOUND4 x1.CLOUD";
52  static constexpr const char *process_shortname = "x1";
78 
82  namespace helper {
83  #ifdef _WIN32
89  static inline std::string WStringToUTF8(const std::wstring& wstr) {
90  if (wstr.empty()) return {};
91  int size = WideCharToMultiByte(CP_UTF8, 0, &wstr[0], (int)wstr.size(), NULL, 0, NULL, NULL);
92  std::string str(size, 0);
93  WideCharToMultiByte(CP_UTF8, 0, &wstr[0], (int)wstr.size(), &str[0], size, NULL, NULL);
94  return str;
95  }
101  static inline std::wstring UTF8ToWString(const std::string& str) {
102  if (str.empty()) return std::wstring();
103  int size = MultiByteToWideChar(CP_UTF8, 0, &str[0], (int)str.size(), NULL, 0);
104  std::wstring wstr(size, 0);
105  MultiByteToWideChar(CP_UTF8, 0, &str[0], (int)str.size(), &wstr[0], size);
106  return wstr;
107  }
108  #endif // _WIN32
109 
115  template<typename T>
116  struct SampleFormat {
117  };
118  template<>
119  struct SampleFormat<int16_t> {
121  };
122  template<>
123  struct SampleFormat<int32_t> {
125  };
126  template<>
127  struct SampleFormat<float> {
129  };
130 
131 
136  static inline void AudioConvertFrom(const uint8_t *payload, float *output, size_t nSpl, cloudx1_SampleFormat fmt) {
137  cloudx1_AudioConvertFrom(payload, output, nSpl, fmt);
138  }
139  static inline void AudioConvertTo(const float *input, uint8_t *payload, size_t nSpl, cloudx1_SampleFormat fmt) {
140  cloudx1_AudioConvertTo(input, payload, nSpl, fmt);
141  }
142  static inline void StereoToMono(const float *input, float *output, size_t nSpl) {
143  cloudx1_StereoToMono(input, output, nSpl);
144  }
145  static inline void MonoToStereo(const float *input, float *output, size_t nSpl) {
146  cloudx1_MonoToStereo(input, output, nSpl);
147  }
148  static inline void StereoToMono_Planar(const float *inputL, const float *inputR, float *output, size_t nSpl) {
149  cloudx1_StereoToMono_Planar(inputL, inputR, output, nSpl);
150  }
151  static inline void MonoToStereo_Planar(const float *input, float *outputL, float *outputR, size_t nSpl) {
152  cloudx1_MonoToStereo_Planar(input, outputL, outputR, nSpl);
153  }
154  static inline void AudioMonoFromLiveStereo(const uint8_t *payload, float *output) {
155  cloudx1_AudioMonoFromLiveStereo(payload, output);
156  }
157  static inline void AudioMonoToLiveStereo(const float *input, uint8_t *payload) {
158  cloudx1_AudioMonoToLiveStereo(input, payload);
159  }
160 
161  }; // namespace helper
162 
168  static inline std::string GetVersion()
169  {
170  return std::string(cloudx1_GetVersion());
171  }
172 
183  static inline unsigned int GetChunkSizeInFrames()
184  {
186  }
187 
196  static inline std::vector<unsigned int> GetPossibleChunkSizeInFrames()
197  {
198  std::vector<unsigned int> list;
199  for (unsigned int* src=cloudx1_GetPossibleChunkSizeInFrames();*src;src++) {
200  list.push_back(*src);
201  }
202  return list;
203  }
204 
212  static inline unsigned int GetChannelCount()
213  {
214  return cloudx1_GetChannelCount();
215  }
216 
225  static inline unsigned int GetAudioInputCount()
226  {
228  }
229 
238  static inline unsigned int GetAudioOutputCount()
239  {
241  }
242 
250  static inline unsigned int GetSampleRate()
251  {
252  return cloudx1_GetSampleRate();
253  }
254 
260  static inline void SanityCheck(bool a_bCheckFrames = true)
261  {
262  // Do some sanity checks
264  throw std::runtime_error("Bad library sampling rate");
265  }
266  if (a_bCheckFrames && cloudx1_GetChunkSizeInFrames()!=ChunkFrames) {
267  throw std::runtime_error("Bad library frame size");
268  }
270  throw std::runtime_error("Bad library channel count");
271  }
273  throw std::runtime_error("Bad library input count");
274  }
276  throw std::runtime_error("Bad library output count");
277  }
278  }
279 
286  static inline std::string GetFormatName(const SampleFormat fmt)
287  {
288  return std::string(cloudx1_GetFormatName(fmt));
289  }
290 
297  static inline SampleFormat GetFormatFromName(const std::string& name)
298  {
299  return cloudx1_GetFormatFromName(name.c_str());
300  }
301 
308  static inline unsigned int GetBytesFromFormat(const SampleFormat fmt)
309  {
310  return cloudx1_GetBytesFromFormat(fmt);
311  }
312 
320  using log_cb_t = std::function<void(LogSeverity,const std::string&)>;
321 
325  static log_cb_t _log_cb;
326  extern "C" {
327  static inline void _log_cb_c(cloudx1_LogSeverity severity, const char *c_msg) {
328  _log_cb(severity, std::string(c_msg));
329  }
330  }
334  static inline void SetLogSeverity(LogSeverity severity)
335  {
336  cloudx1_SetLogSeverity(severity);
337  }
341  static inline void SetLoggerCallback(log_cb_t cb)
342  {
343  _log_cb=cb;
344  cloudx1_SetLoggerCallback(&_log_cb_c);
345  }
346 
347 #if CLOUDX1_HAS_CLOUDBUS
348  class CBus {
349  public:
350  CBus()
351  : m_bus(cloudx1_NewBus()) {}
352  ~CBus()
353  {
354  cloudx1_FreeBus(m_bus);
355  m_bus = nullptr;
356  }
357  cloudx1_CBus *Get() const { return m_bus; }
358  private:
359  cloudx1_CBus *m_bus;
360  };
361 #endif // CLOUDX1_HAS_CLOUDBUS
362 
368  public:
369  CPresetLoader() = default;
370  virtual ~CPresetLoader() = default;
371 
372  virtual bool IsReadOnly() = 0;
373  virtual bool Exists(const std::filesystem::path &name) = 0;
374  virtual bool Remove(const std::filesystem::path &name) = 0;
375  virtual bool Rename(const std::filesystem::path &from, const std::filesystem::path &to) = 0;
376  virtual std::vector<std::filesystem::path> GetAll() = 0;
377  virtual std::string Read(const std::filesystem::path &filename) = 0;
378  virtual bool Write(const std::filesystem::path &filename, const std::string &content) =0;
379  };
381 
385  class CInstance {
386  public:
391  {
392  params = cloudx1_NewParameters();
393  if (!params) throw std::bad_alloc();
394  }
395  // non-copyable
396  CInstance( const CInstance& ) = delete;
397  CInstance& operator=( const CInstance& ) = delete;
402  {
403  Stop();
404  if (params) cloudx1_FreeParameters(params);
405  }
409  bool IsOk() const { return instance!=nullptr; }
417  void SetParam(const std::string& name, const std::string& value)
418  {
419  assert(params);
420  cloudx1_SetParameter(params, name.c_str(), value.c_str());
421  }
427  std::string GetParam(const std::string& name)
428  {
429  assert(params);
430  auto c_value=cloudx1_GetParameter(params, name.c_str());
431  std::string ret(c_value);
433  return ret;
434  }
435 
445  void SetPresetManager(CPresetLoader *preset_manager)
446  {
447  if (!preset_manager) return;
448  assert(params);
450  cloudx1_custom_reader,
451  cloudx1_custom_reader_free,
452  cloudx1_custom_writer,
453  cloudx1_custom_exists,
454  cloudx1_custom_getall,
455  cloudx1_custom_getall_free,
456  cloudx1_custom_remove,
457  cloudx1_custom_rename,
458  preset_manager->IsReadOnly(),
459  preset_manager
460  );
461  }
462 
463 #if CLOUDX1_HAS_CLOUDBUS
467  void SetBus(const CBus& bus) {
468  assert(params);
469  cloudx1_SetInstanceBus(params,bus.Get());
470  }
471 #endif // CLOUDX1_HAS_CLOUDBUS
472 
487  bool Create(const std::string& LoginKey, const std::string& RadioName, const std::string& AWS_Access_ID, const std::string& AWS_Access_Secret, const std::filesystem::path& save_path, int json_port = 0, unsigned int frames_per_chunk=64)
488  {
489  assert(!instance);
490  std::string l_save_path;
491  if (!save_path.empty()) {
492  l_save_path = save_path.u8string();
493  }
494  instance = cloudx1_InitProcess3(LoginKey.c_str(), RadioName.c_str(), AWS_Access_ID.c_str(), AWS_Access_Secret.c_str(), l_save_path.c_str(), params, frames_per_chunk);
495  if (!instance) return false;
496  if (!init_metadata.empty()) {
497  for (auto&& [key,value]: init_metadata) {
498  cloudx1_SetMetadata(instance, key.c_str(), value.c_str());
499  }
500  init_metadata.clear();
501  }
502  update_thread = std::thread([this, json_port](){
504  cloudx1_StartUpdateThread(instance, json_port);
506  });
507  int timeout=5000;
508  #ifdef DEBUG
509  timeout=60*1000; // For debugger pauses
510  #endif
511  if (cloudx1_WaitUpdateThreadReady(instance, timeout)<0) {
512  return false;
513  }
514  return true;
515  }
516 
524  unsigned int GetChunkFrames() {
525  if (instance) {
526  return cloudx1_GetProcessChunkFrames(instance);
527  }
528  return 0;
529  }
530 
538  void PresetManager_InformChange(const std::filesystem::path& relative_path, PresetChange_Kind change_kind)
539  {
540  cloudx1_PresetManager_InformChange(instance, relative_path.c_str(), (cloudx1_PresetChange_Kind) change_kind);
541  }
542 
554  void SetMetadata(const std::string& key, const char* value)
555  {
556  if (instance) {
557  cloudx1_SetMetadata(instance, key.c_str(), value);
558  } else {
559  init_metadata.push_back( {key, value} );
560  }
561  }
562 
568  std::vector< std::tuple<std::string,std::string> > GetMetadataInfos()
569  {
570  std::vector< std::tuple<std::string,std::string> > values;
571  const char** c_values = cloudx1_GetMetadataInfos(instance);
572  if (c_values) {
573  for (const char** c_value=c_values; *c_value; ) {
574  std::string key(*c_value);
575  c_value++;
576  if (*c_value) {
577  std::string descr(*c_value);
578  c_value++;
579  values.push_back( {key,descr} );
580  }
581  }
582  cloudx1_FreeMetadataInfos(instance, c_values);
583  }
584  return values;
585  }
586 
587  // Can be overloaded, called at start of UpdateThread in the thread
588  virtual void OnUpdateThreadStart() {}
589  // Can be overloaded to call at end of UpdateThread in the thread
590  virtual void OnUpdateThreadStop() {}
591 
592 #if CLOUDX1_HAS_WEBSERVER
598  bool StartWebServer(int http_port, int https_port=0)
599  {
600  assert(instance);
601  assert(webserver==SOUND4_INVALID_WEBSERVER_ID);
602  webserver = cloudx1_Webserver(http_port,https_port,instance);
603  if (webserver==SOUND4_INVALID_WEBSERVER_ID) {
604  return false;
605  }
606  int web_status=cloudx1_Webserver_Status(webserver);
607  if (http_port && (web_status & SOUND4_WEBSERVER_HTTP_OK) == 0) {
608  return false;
609  }
610  if (https_port && (web_status & SOUND4_WEBSERVER_HTTPS_OK) == 0) {
611  return false;
612  }
613  return true;
614  }
621  {
622  if (webserver != SOUND4_INVALID_WEBSERVER_ID) {
623  cloudx1_Webserver_Stop(webserver, 1000);
624  webserver = SOUND4_INVALID_WEBSERVER_ID;
625  }
626  }
627 #endif // CLOUDX1_HAS_WEBSERVER
628 
635  int Terminate()
636  {
637  if (!instance) return 0;
638  return cloudx1_TerminateProcess(instance);
639  }
640 
646  void Stop()
647  {
648  if (!instance) return;
649 #if CLOUDX1_HAS_WEBSERVER
650  StopWebServer();
651 #endif // CLOUDX1_HAS_WEBSERVER
652  if (update_thread.joinable()) {
653  cloudx1_StopUpdateThread(instance); // this will exit the update thread
654  update_thread.join();
655  }
656  cloudx1_ExitProcess(instance);
657  instance=nullptr;
658  }
659 
665  unsigned int GetEstimatedDelay()
666  {
667  assert(instance);
668  return cloudx1_GetEstimatedDelay(instance);
669  }
670 
681  std::array<float,InputSampleSize>& GetBufferIn()
682  {
683  assert(instance);
684  float *buf=cloudx1_GetBufferIn(instance);
685  return reinterpret_cast< std::array<float,InputSampleSize>& >(*buf);
686 
687  }
698  std::array<float,OutputSampleSize>& GetBufferOut()
699  {
700  assert(instance);
701  float *buf= cloudx1_GetBufferOut(instance);
702  return reinterpret_cast< std::array<float,OutputSampleSize>& >(*buf);
703  }
710  {
711  assert(instance);
712  cloudx1_ProcessAudio(instance, cloudx1_GetBufferIn(instance), cloudx1_GetBufferOut(instance));
713  }
727  // void ProcessAudio_Planar(const std::array< const std::array<const float,ChunkFrames>, InputChannels>& input, std::array< std::array<float,ChunkFrames>, OutputChannels>& output)
728  void ProcessAudio_Planar(float const * const *input, float * const *output)
729  {
730  assert(instance);
731  cloudx1_ProcessAudio_Planar(instance, input, output);
732  }
733 
745  template<typename T>
746  std::vector<T> ProcessAnyAudio(const std::vector<T> input)
747  {
748  assert(instance);
749  std::vector<T> output;
750  unsigned int out_offset=0;
751  unsigned int in_offset=0;
752  unsigned int todo = input.size();
753  while (todo>0) {
754  unsigned int left = AddAudio(&input[in_offset], todo);
755  unsigned int out_avail = cloudx1_GetOutputCount(instance);
756  output.resize(out_offset + out_avail);
757  GetAudio(&output[out_offset], out_avail);
758  out_offset+=out_avail;
759  in_offset += todo-left;
760  todo=left;
761  }
762  return output;
763  }
764 
770  class CClient {
771  public:
773  {
774  assert(instance);
775  client=cloudx1_NewClient(instance);
776  if (!client) throw std::bad_alloc();
777  }
778  // non-copyable
779  CClient( const CInstance& ) = delete;
780  CClient& operator=( const CInstance& ) = delete;
782  {
783  if (client) {
784  cloudx1_DeleteClient(client);
785  client=nullptr;
786  }
787  }
795  std::string ProcessJson(const std::string &request, bool *NeedSave = nullptr)
796  {
797  assert(client);
798  int need_save=0;
799  const char *canswer = cloudx1_ProcessJson(client, request.c_str(), &need_save);
800  if (!canswer) return {};
801  std::string answer(canswer);
802  cloudx1_FreeJsonAnswer (canswer);
803  if (NeedSave) {
804  *NeedSave=(need_save!=0);
805  }
806  return answer;
807  }
808  private:
809  cloudx1_CClientInstance *client = nullptr;
810  };
818  std::shared_ptr<CClient> NewClient()
819  {
820  assert(instance);
821  return std::make_shared<CClient>(instance);
822  }
823 
824  protected:
825  template<typename T>
826  unsigned int AddAudio(const T* payload, unsigned int nFrame)
827  {
828  assert(instance);
829  return cloudx1_AddAudio(instance, reinterpret_cast<const T*>(payload), nFrame, helper::SampleFormat<T>::format);
830  }
831  template<typename T>
832  unsigned int GetAudio(T* payload, unsigned int max_nFrame)
833  {
834  assert(instance);
835  return cloudx1_GetAudio(instance, reinterpret_cast<T*>(payload), max_nFrame, helper::SampleFormat<T>::format);
836  }
837 
838  private:
839  cloudx1_CParameters* params = nullptr;
840  cloudx1_CInstance* instance = nullptr;
841  std::thread update_thread;
842  std::vector< std::pair<std::string,std::string> > init_metadata;
843 #if CLOUDX1_HAS_WEBSERVER
844  uint64_t webserver = SOUND4_INVALID_WEBSERVER_ID;
845 #endif // CLOUDX1_HAS_WEBSERVER
846  };
847 
848 }; // namespace cloudx1
849 }; // namespace sound4
850 
851 // bridge C callbacks to CPresetLoader
852 extern "C" {
853  static char *cloudx1_custom_reader(const fs_char *filename, void* userdata) {
854  sound4::cloudx1::CPresetLoader *preset_loader=reinterpret_cast<sound4::cloudx1::CPresetLoader*>(userdata);
855  std::string content=preset_loader->Read(filename);
856  return strdup(content.c_str());
857  }
858  static void cloudx1_custom_reader_free(char *content, void* userdata) {
859  if (!content) return;
860  free(content);
861  }
862  static int cloudx1_custom_writer(const fs_char *filename, const char *content, void* userdata) {
863  sound4::cloudx1::CPresetLoader *preset_loader=reinterpret_cast<sound4::cloudx1::CPresetLoader*>(userdata);
864  auto res=preset_loader->Write(filename,content);
865  return res?0:-1;
866  }
867  static int cloudx1_custom_exists(const fs_char *filename, void* userdata) {
868  sound4::cloudx1::CPresetLoader *preset_loader=reinterpret_cast<sound4::cloudx1::CPresetLoader*>(userdata);
869  auto res=preset_loader->Exists(filename);
870  return res?0:-1;
871  }
872  static fs_char** cloudx1_custom_getall(void* userdata) {
873  sound4::cloudx1::CPresetLoader *preset_loader=reinterpret_cast<sound4::cloudx1::CPresetLoader*>(userdata);
874  auto res=preset_loader->GetAll();
875  fs_char**all=(fs_char**)malloc((res.size()+1)*sizeof(const fs_char*));
876  for (size_t n=0;n<res.size();n++) {
877  all[n]=fs_strdup(res[n].c_str());
878  }
879  all[res.size()]=nullptr;
880  return all;
881  }
882  static void cloudx1_custom_getall_free(fs_char** all, void* userdata) {
883  if (!all) return;
884  for (fs_char** one=all;*one;one++) {
885  free(*one);
886  }
887  free(all);
888  }
889  static int cloudx1_custom_remove(const fs_char *filename, void* userdata) {
890  sound4::cloudx1::CPresetLoader *preset_loader=reinterpret_cast<sound4::cloudx1::CPresetLoader*>(userdata);
891  auto res=preset_loader->Remove(filename);
892  return res?0:-1;
893  }
894  static int cloudx1_custom_rename(const fs_char *from, const fs_char *to, void* userdata) {
895  sound4::cloudx1::CPresetLoader *preset_loader=reinterpret_cast<sound4::cloudx1::CPresetLoader*>(userdata);
896  auto res=preset_loader->Rename(from,to);
897  return res?0:-1;
898  }
899 
900 };
std::string ProcessJson(const std::string &request, bool *NeedSave=nullptr)
Process a JSON request and returns the answer.
CClient & operator=(const CInstance &)=delete
CClient(cloudx1_CInstance *instance)
CClient(const CInstance &)=delete
CInstance & operator=(const CInstance &)=delete
void PresetManager_InformChange(const std::filesystem::path &relative_path, PresetChange_Kind change_kind)
void ProcessAudio_Planar(float const *const *input, float *const *output)
std::string GetParam(const std::string &name)
std::shared_ptr< CClient > NewClient()
void SetPresetManager(CPresetLoader *preset_manager)
bool StartWebServer(int http_port, int https_port=0)
bool Create(const std::string &LoginKey, const std::string &RadioName, const std::string &AWS_Access_ID, const std::string &AWS_Access_Secret, const std::filesystem::path &save_path, int json_port=0, unsigned int frames_per_chunk=64)
std::array< float, OutputSampleSize > & GetBufferOut()
std::vector< std::tuple< std::string, std::string > > GetMetadataInfos()
std::vector< T > ProcessAnyAudio(const std::vector< T > input)
std::array< float, InputSampleSize > & GetBufferIn()
CInstance(const CInstance &)=delete
unsigned int GetAudio(T *payload, unsigned int max_nFrame)
void SetMetadata(const std::string &key, const char *value)
unsigned int AddAudio(const T *payload, unsigned int nFrame)
void SetParam(const std::string &name, const std::string &value)
virtual bool Exists(const std::filesystem::path &name)=0
virtual std::vector< std::filesystem::path > GetAll()=0
virtual bool Remove(const std::filesystem::path &name)=0
virtual bool Write(const std::filesystem::path &filename, const std::string &content)=0
virtual bool Rename(const std::filesystem::path &from, const std::filesystem::path &to)=0
virtual ~CPresetLoader()=default
virtual std::string Read(const std::filesystem::path &filename)=0
enum cloudx1_SampleFormat cloudx1_GetFormatFromName(const char *name)
cloudx1_SampleFormat
unsigned int cloudx1_GetOutputCount(struct cloudx1_CInstance *instance)
const char * cloudx1_GetFormatName(const enum cloudx1_SampleFormat fmt)
unsigned int cloudx1_AddAudio(struct cloudx1_CInstance *instance, const uint8_t *payload, unsigned int nFrame, enum cloudx1_SampleFormat fmt)
unsigned int cloudx1_GetBytesFromFormat(const enum cloudx1_SampleFormat fmt)
unsigned int cloudx1_GetAudio(struct cloudx1_CInstance *instance, uint8_t *payload, unsigned int max_nFrame, enum cloudx1_SampleFormat fmt)
@ F32_NATIVE
32-bit floating-point, native
@ S16_NATIVE
16-bit signed integer, native
@ S32_NATIVE
32-bit signed integer, native
struct cloudx1_CClientInstance * cloudx1_NewClient(struct cloudx1_CInstance *instance)
void cloudx1_DeleteClient(struct cloudx1_CClientInstance *client)
void cloudx1_FreeJsonAnswer(const char *json_str)
const char * cloudx1_ProcessJson(struct cloudx1_CClientInstance *client, const char *json_str, int *need_save)
void cloudx1_AudioConvertTo(const float *input, uint8_t *payload, size_t nSpl, enum cloudx1_SampleFormat fmt)
void cloudx1_AudioMonoToLiveStereo(const float *input, uint8_t *payload)
void cloudx1_MonoToStereo_Planar(const float *input, float *outputL, float *outputR, size_t nFrame)
void cloudx1_StereoToMono(const float *input, float *output, size_t nFrame)
void cloudx1_AudioConvertFrom(const uint8_t *payload, float *output, size_t nSpl, enum cloudx1_SampleFormat fmt)
void cloudx1_MonoToStereo(const float *input, float *output, size_t nFrame)
void cloudx1_AudioMonoFromLiveStereo(const uint8_t *payload, float *output)
void cloudx1_StereoToMono_Planar(const float *inputL, const float *inputR, float *output, size_t nFrame)
float * cloudx1_GetBufferIn(struct cloudx1_CInstance *instance)
void cloudx1_ProcessAudio_Planar(struct cloudx1_CInstance *instance, float const *const *input, float *const *output)
void cloudx1_ProcessAudio(struct cloudx1_CInstance *instance, const float *input, float *output)
unsigned int cloudx1_GetEstimatedDelay(struct cloudx1_CInstance *instance)
float * cloudx1_GetBufferOut(struct cloudx1_CInstance *instance)
unsigned int cloudx1_GetAudioInputCount()
#define CLOUDX1_AUDIO_INPUT_COUNT
const char * cloudx1_GetVersion()
cloudx1_LogSeverity
unsigned int cloudx1_GetChunkSizeInFrames()
unsigned int * cloudx1_GetPossibleChunkSizeInFrames()
#define CLOUDX1_AUDIOFRAME_COUNT
unsigned int cloudx1_GetAudioOutputCount()
unsigned int cloudx1_GetChannelCount()
void cloudx1_SetLoggerCallback(cloudx1_loggerfn logger)
unsigned int cloudx1_GetSampleRate()
#define CLOUDX1_SAMPLE_RATE
#define CLOUDX1_CHANNEL_COUNT
#define CLOUDX1_AUDIO_OUTPUT_COUNT
void cloudx1_SetLogSeverity(enum cloudx1_LogSeverity severity)
void cloudx1_FreeParameterValue(const char *value)
void cloudx1_ExitProcess(struct cloudx1_CInstance *instance)
void cloudx1_FreeParameters(struct cloudx1_CParameters *params)
struct cloudx1_CParameters * cloudx1_NewParameters()
void cloudx1_SetParameter(struct cloudx1_CParameters *params, const char *name, const char *value)
int cloudx1_TerminateProcess(struct cloudx1_CInstance *instance)
struct cloudx1_CInstance * cloudx1_InitProcess3(const char *LoginKey, const char *RadioName, const char *AWS_Access_ID, const char *AWS_Access_Secret, const char *save_path, const struct cloudx1_CParameters *parameters, unsigned int frames_per_chunk)
const char * cloudx1_GetParameter(struct cloudx1_CParameters *params, const char *name)
unsigned int cloudx1_GetProcessChunkFrames(struct cloudx1_CInstance *instance)
const char ** cloudx1_GetMetadataInfos(struct cloudx1_CInstance *instance)
void cloudx1_SetMetadata(struct cloudx1_CInstance *instance, const char *key, const char *value)
void cloudx1_FreeMetadataInfos(struct cloudx1_CInstance *instance, const char **infos)
cloudx1_PresetChange_Kind
void cloudx1_SetPresetManager(struct cloudx1_CParameters *params, cloudx1_storage_reader reader, cloudx1_storage_reader_free, cloudx1_storage_writer writer, cloudx1_storage_exists exists, cloudx1_storage_getall getall, cloudx1_storage_getall_free getall_free, cloudx1_storage_remove remove, cloudx1_storage_rename rename, int IsReadOnly, void *userdata)
void cloudx1_PresetManager_InformChange(struct cloudx1_CInstance *instance, const fs_char *relative_path, enum cloudx1_PresetChange_Kind change_kind)
wchar_t fs_char
void cloudx1_StartUpdateThread(struct cloudx1_CInstance *instance, unsigned int port)
int cloudx1_WaitUpdateThreadReady(struct cloudx1_CInstance *instance, int milliseconds)
void cloudx1_StopUpdateThread(struct cloudx1_CInstance *instance)
#define SOUND4_WEBSERVER_HTTPS_OK
uint64_t cloudx1_Webserver(unsigned int listenport, unsigned int listenport_secure, struct cloudx1_CInstance *instance)
int cloudx1_Webserver_Status(uint64_t id)
#define SOUND4_WEBSERVER_HTTP_OK
#define SOUND4_INVALID_WEBSERVER_ID
int cloudx1_Webserver_Stop(uint64_t id, int timeout_ms)
const size_t SampleRate
std::function< void(LogSeverity, const std::string &)> log_cb_t
const size_t InputChannels
const size_t OutputSampleSize
cloudx1_LogSeverity LogSeverity
cloudx1_SampleFormat SampleFormat
const size_t InputSampleSize
const size_t ChunkFrames
const size_t OutputChannels
C interface for library.
#define fs_strdup
helper for OS dependant file name copy
Helper for Sample format types.