rtmp-custom.c 1.7 KB

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