File: tutorial2.c

package info (click to toggle)
pipewire 1.6.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 17,856 kB
  • sloc: ansic: 309,496; cpp: 2,812; xml: 408; python: 243; sh: 214; makefile: 176; pascal: 85
file content (56 lines) | stat: -rw-r--r-- 1,290 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/*
  [title]
  \ref page_tutorial2
  [title]
 */
/* [code] */
#include <pipewire/pipewire.h>

static void registry_event_global(void *data, uint32_t id,
		uint32_t permissions, const char *type, uint32_t version,
		const struct spa_dict *props)
{
	printf("object: id:%u type:%s/%d\n", id, type, version);
}

static const struct pw_registry_events registry_events = {
	PW_VERSION_REGISTRY_EVENTS,
	.global = registry_event_global,
};

int main(int argc, char *argv[])
{
	struct pw_main_loop *loop;
	struct pw_context *context;
	struct pw_core *core;
	struct pw_registry *registry;
	struct spa_hook registry_listener;

	pw_init(&argc, &argv);

	loop = pw_main_loop_new(NULL /* properties */);
	context = pw_context_new(pw_main_loop_get_loop(loop),
			NULL /* properties */,
			0 /* user_data size */);

	core = pw_context_connect(context,
			NULL /* properties */,
			0 /* user_data size */);

	registry = pw_core_get_registry(core, PW_VERSION_REGISTRY,
			0 /* user_data size */);

	spa_zero(registry_listener);
	pw_registry_add_listener(registry, &registry_listener,
				       &registry_events, NULL);

	pw_main_loop_run(loop);

	pw_proxy_destroy((struct pw_proxy*)registry);
	pw_core_disconnect(core);
	pw_context_destroy(context);
	pw_main_loop_destroy(loop);

	return 0;
}
/* [code] */