rtmp-custom.c 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. #include <obs-module.h>
  2. struct rtmp_custom {
  3. char *server, *key;
  4. };
  5. static const char *rtmp_custom_name(const char *locale)
  6. {
  7. UNUSED_PARAMETER(locale);
  8. /* TODO: locale */
  9. return "Custom Streaming Server";
  10. }
  11. static void rtmp_custom_update(void *data, obs_data_t settings)
  12. {
  13. struct rtmp_custom *service = data;
  14. bfree(service->server);
  15. bfree(service->key);
  16. service->server = bstrdup(obs_data_getstring(settings, "server"));
  17. service->key = bstrdup(obs_data_getstring(settings, "key"));
  18. }
  19. static void rtmp_custom_destroy(void *data)
  20. {
  21. struct rtmp_custom *service = data;
  22. bfree(service->server);
  23. bfree(service->key);
  24. bfree(service);
  25. }
  26. static void *rtmp_custom_create(obs_data_t settings, obs_service_t service)
  27. {
  28. struct rtmp_custom *data = bzalloc(sizeof(struct rtmp_custom));
  29. rtmp_custom_update(data, settings);
  30. UNUSED_PARAMETER(service);
  31. return data;
  32. }
  33. static obs_properties_t rtmp_custom_properties(const char *locale)
  34. {
  35. obs_properties_t ppts = obs_properties_create(locale);
  36. /* TODO: locale */
  37. obs_properties_add_text(ppts, "server", "URL", OBS_TEXT_DEFAULT);
  38. obs_properties_add_text(ppts, "key", "Stream Key", OBS_TEXT_PASSWORD);
  39. return ppts;
  40. }
  41. static const char *rtmp_custom_url(void *data)
  42. {
  43. struct rtmp_custom *service = data;
  44. return service->server;
  45. }
  46. static const char *rtmp_custom_key(void *data)
  47. {
  48. struct rtmp_custom *service = data;
  49. return service->key;
  50. }
  51. struct obs_service_info rtmp_custom_service = {
  52. .id = "rtmp_custom",
  53. .getname = rtmp_custom_name,
  54. .create = rtmp_custom_create,
  55. .destroy = rtmp_custom_destroy,
  56. .update = rtmp_custom_update,
  57. .properties = rtmp_custom_properties,
  58. .get_url = rtmp_custom_url,
  59. .get_key = rtmp_custom_key
  60. };