pipewire 1.1.0 → 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +46 -0
- package/examples/event-registry.ts +45 -0
- package/package.json +2 -1
package/README.md
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# node-pipewire
|
|
2
|
+
|
|
3
|
+
Node.js bindings for [PipeWire](https://pipewire.org/) using [koffi](https://koffi.dev/) FFI.
|
|
4
|
+
|
|
5
|
+
## Requirements
|
|
6
|
+
|
|
7
|
+
- Node.js
|
|
8
|
+
- PipeWire (`libpipewire-0.3.so.0`)
|
|
9
|
+
|
|
10
|
+
## Install
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
npm install
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Build
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npm run build
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Usage
|
|
23
|
+
|
|
24
|
+
```ts
|
|
25
|
+
import * as pw from "pipewire";
|
|
26
|
+
|
|
27
|
+
pw.pipewire.pw_init(0, null);
|
|
28
|
+
|
|
29
|
+
const loop = pw.main_loop.pw_main_loop_new(null);
|
|
30
|
+
const context = pw.context.pw_context_new(pw.main_loop.pw_main_loop_get_loop(loop), null, 0);
|
|
31
|
+
const core = pw.core.pw_context_connect(context, null, 0);
|
|
32
|
+
const registry = pw.core.pw_core_get_registry(core, 3, 0);
|
|
33
|
+
|
|
34
|
+
// ...add listeners, then run the main loop
|
|
35
|
+
await new Promise((resolve) => pw.main_loop.pw_main_loop_run.async(loop, resolve));
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
See [`examples/event-registry.ts`](examples/event-registry.ts) for a complete example:
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
npx tsx examples/event-registry.ts
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## License
|
|
45
|
+
|
|
46
|
+
ISC
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import koffi from "koffi";
|
|
2
|
+
import * as pw from "../src/index.js";
|
|
3
|
+
|
|
4
|
+
(async () => {
|
|
5
|
+
pw.pipewire.pw_init(0, null);
|
|
6
|
+
|
|
7
|
+
const loop = pw.main_loop.pw_main_loop_new(null);
|
|
8
|
+
const context = pw.context.pw_context_new(pw.main_loop.pw_main_loop_get_loop(loop), null, 0);
|
|
9
|
+
const core = pw.core.pw_context_connect(context, null, 0);
|
|
10
|
+
const registry = pw.core.pw_core_get_registry(core, 3, 0);
|
|
11
|
+
const registry_listener = Buffer.alloc(koffi.sizeof(pw.hook.spa_hook));
|
|
12
|
+
|
|
13
|
+
const registry_event_global = (
|
|
14
|
+
data: Buffer,
|
|
15
|
+
id: number,
|
|
16
|
+
permissions: number,
|
|
17
|
+
type: string,
|
|
18
|
+
version: number,
|
|
19
|
+
props: Buffer
|
|
20
|
+
) => {
|
|
21
|
+
console.log(`object: id:${id} type:${type}/${version}`);
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const registry_events = {
|
|
25
|
+
version: 0,
|
|
26
|
+
global: koffi.register(registry_event_global, koffi.pointer(pw.core.pw_registry_events_globals)),
|
|
27
|
+
global_remove: null
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
pw.registry.pw_registry_add_listener(registry, registry_listener, registry_events, null);
|
|
31
|
+
|
|
32
|
+
process.on("SIGINT", () => {
|
|
33
|
+
pw.main_loop.pw_main_loop_quit(loop);
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
console.log("Starting PipeWire main loop...");
|
|
37
|
+
await new Promise((resolve) => pw.main_loop.pw_main_loop_run.async(loop, resolve));
|
|
38
|
+
|
|
39
|
+
pw.proxy.pw_proxy_destroy(registry);
|
|
40
|
+
pw.core.pw_core_disconnect(core);
|
|
41
|
+
pw.context.pw_context_destroy(context);
|
|
42
|
+
pw.main_loop.pw_main_loop_destroy(loop);
|
|
43
|
+
|
|
44
|
+
console.log("PipeWire main loop exited, cleanup done.");
|
|
45
|
+
})();
|
package/package.json
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pipewire",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.2",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"build": "tsc"
|
|
8
8
|
},
|
|
9
9
|
"keywords": [],
|
|
10
|
+
"homepage": "https://github.com/Raraph84/node-pipewire",
|
|
10
11
|
"author": "Raraph84",
|
|
11
12
|
"license": "ISC",
|
|
12
13
|
"type": "module",
|