rtmp-custom.c 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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_getstring(settings, "server"));
  15. service->key = bstrdup(obs_data_getstring(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)
  32. {
  33. obs_properties_t ppts = obs_properties_create();
  34. obs_properties_add_text(ppts, "server", "URL", OBS_TEXT_DEFAULT);
  35. obs_properties_add_text(ppts, "key", obs_module_text("StreamKey"),
  36. OBS_TEXT_PASSWORD);
  37. return ppts;
  38. }
  39. static const char *rtmp_custom_url(void *data)
  40. {
  41. struct rtmp_custom *service = data;
  42. return service->server;
  43. }
  44. static const char *rtmp_custom_key(void *data)
  45. {
  46. struct rtmp_custom *service = data;
  47. return service->key;
  48. }
  49. struct obs_service_info rtmp_custom_service = {
  50. .id = "rtmp_custom",
  51. .get_name = rtmp_custom_name,
  52. .create = rtmp_custom_create,
  53. .destroy = rtmp_custom_destroy,
  54. .update = rtmp_custom_update,
  55. .get_properties = rtmp_custom_properties,
  56. .get_url = rtmp_custom_url,
  57. .get_key = rtmp_custom_key
  58. };