Audio plugin host https://kx.studio/carla
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

70 lines
2.9KB

  1. /*
  2. * Carla REST API Server
  3. * Copyright (C) 2018 Filipe Coelho <falktx@falktx.com>
  4. *
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU General Public License as
  7. * published by the Free Software Foundation; either version 2 of
  8. * the License, or any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * For a full copy of the GNU General Public License see the doc/GPL.txt file.
  16. */
  17. /* NOTE
  18. * Even though Carla is GPL, restbed if AGPL.
  19. * As such, the resulting binary will be AGPL.
  20. * Take this into consideration before deploying it to any servers.
  21. */
  22. #include "common.hpp"
  23. #include "carla-host.cpp"
  24. #include "carla-utils.cpp"
  25. // -------------------------------------------------------------------------------------------------------------------
  26. void make_resource(Service& service,
  27. const char* const path,
  28. const std::function<void (const std::shared_ptr<Session>)>& callback)
  29. {
  30. std::shared_ptr<Resource> resource = std::make_shared<Resource>();
  31. resource->set_path(path);
  32. resource->set_method_handler("GET", callback);
  33. service.publish(resource);
  34. }
  35. // -------------------------------------------------------------------------------------------------------------------
  36. int main(int, const char**)
  37. {
  38. Service service;
  39. // carla-host
  40. make_resource(service, "/get_engine_driver_count", handle_carla_get_engine_driver_count);
  41. make_resource(service, "/get_engine_driver_name/{index: .*}", handle_carla_get_engine_driver_name);
  42. make_resource(service, "/get_engine_driver_device_names/{index: .*}", handle_carla_get_engine_driver_device_names);
  43. make_resource(service, "/get_engine_driver_device_info/{index: .*}/{name: .*}", handle_carla_get_engine_driver_device_info);
  44. // carla-utils
  45. make_resource(service, "/get_complete_license_text", handle_carla_get_complete_license_text);
  46. make_resource(service, "/get_supported_file_extensions", handle_carla_get_supported_file_extensions);
  47. make_resource(service, "/get_supported_features", handle_carla_get_supported_features);
  48. make_resource(service, "/get_cached_plugin_count/{ptype: .*}/{pluginPath: .*}", handle_carla_get_cached_plugin_count);
  49. make_resource(service, "/get_cached_plugin_info/{ptype: .*}/{index: .*}", handle_carla_get_cached_plugin_info);
  50. std::shared_ptr<Settings> settings = std::make_shared<Settings>();
  51. settings->set_port(2228);
  52. settings->set_default_header("Connection", "close");
  53. carla_stdout("Carla REST-API Server started");
  54. service.start(settings);
  55. return 0;
  56. }
  57. // -------------------------------------------------------------------------------------------------------------------