rtmp-custom.c 1.6 KB

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