char/char-rtc-obs

git clone https://git.t4t.associates/char/char-rtc-obs

videogame hackerAdd UI in Tools menu for setup35e5e7d

main
2.7 KiB112 linesraw
1#include "whip-service.h"
2
3struct whip_service_state {
4	char *server;
5	char *bearer_token;
6};
7
8static const char *whip_service_name(void *type_data)
9{
10	UNUSED_PARAMETER(type_data);
11
12	return obs_module_text("Service.Name");
13}
14
15static void whip_service_update(void *data, obs_data_t *settings)
16{
17	struct whip_service_state *service = data;
18
19	bfree(service->server);
20
21	service->server = bstrdup(obs_data_get_string(settings, "server"));
22	service->bearer_token =
23		bstrdup(obs_data_get_string(settings, "bearer_token"));
24}
25
26static void whip_service_destroy(void *data)
27{
28	struct whip_service_state *service = data;
29
30	bfree(service->bearer_token);
31	bfree(service->server);
32	bfree(service);
33}
34
35static void *whip_service_create(obs_data_t *settings, obs_service_t *service)
36{
37	struct whip_service_state *data =
38		bzalloc(sizeof(struct whip_service_state));
39
40	whip_service_update(data, settings);
41
42	UNUSED_PARAMETER(service);
43	return data;
44}
45
46static const char *whip_service_url(void *data)
47{
48	struct whip_service_state *service = data;
49	return service->server;
50}
51
52static obs_properties_t *whip_service_properties(void *data)
53{
54	UNUSED_PARAMETER(data);
55
56	obs_properties_t *ppts = obs_properties_create();
57
58	obs_properties_add_text(ppts, "server", "URL", OBS_TEXT_DEFAULT);
59	obs_properties_add_text(ppts, "bearer_token",
60				obs_module_text("Service.BearerToken"),
61				OBS_TEXT_PASSWORD);
62
63	return ppts;
64}
65
66static const char *whip_service_get_output_type(void *data)
67{
68	UNUSED_PARAMETER(data);
69
70	return "whip_output";
71}
72
73static void whip_service_apply_encoder_settings(void *data,
74						obs_data_t *video_settings,
75						obs_data_t *audio_settings)
76{
77	UNUSED_PARAMETER(data);
78	UNUSED_PARAMETER(audio_settings);
79
80	// For now, ensure maximum compatibility with webrtc peers
81	if (video_settings) {
82		obs_data_set_int(video_settings, "bf", 0);
83		obs_data_set_string(video_settings, "profile", "baseline");
84		obs_data_set_string(video_settings, "rate_control", "CBR");
85		obs_data_set_bool(video_settings, "repeat_headers", true);
86	}
87}
88
89static const char *whip_service_get_key(void *data)
90{
91	struct whip_service_state *service = data;
92
93	return service->bearer_token;
94}
95
96struct obs_service_info whip_service_info = {
97	.id = "whip_custom",
98	.get_name = whip_service_name,
99	.create = whip_service_create,
100	.destroy = whip_service_destroy,
101	.update = whip_service_update,
102	.get_properties = whip_service_properties,
103	.get_url = whip_service_url,
104	.get_output_type = whip_service_get_output_type,
105	.apply_encoder_settings = whip_service_apply_encoder_settings,
106	.get_key = whip_service_get_key,
107};
108
109void whip_register_service()
110{
111	obs_register_service(&whip_service_info);
112}