aboutsummaryrefslogtreecommitdiffhomepage
path: root/internal
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2025-11-25 08:34:19 +0900
committerOphestra <cat@gensokyo.uk>2025-11-25 08:34:19 +0900
commit591637264a76771d36531a3e51e7db40ef853421 (patch)
tree65841f27922657c3bcca1fe23aec49dcae997ed6 /internal
parente77652bf89bf1f1e55174cd61a745cf13ca31e48 (diff)
internal/pipewire: implement Core::GetRegistry
This struct is entirely supported, so this change is very straightforward. Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'internal')
-rw-r--r--internal/pipewire/core.go32
-rw-r--r--internal/pipewire/core_test.go9
-rw-r--r--internal/pipewire/header_test.go6
-rw-r--r--internal/pipewire/pipewire_test.go5
-rw-r--r--internal/pipewire/testdata/04-sendmsg00-message02-headerbin0 -> 16 bytes
-rw-r--r--internal/pipewire/testdata/05-sendmsg00-message02-PODbin0 -> 40 bytes
6 files changed, 50 insertions, 2 deletions
diff --git a/internal/pipewire/core.go b/internal/pipewire/core.go
index 9a408e2f..137c9bc5 100644
--- a/internal/pipewire/core.go
+++ b/internal/pipewire/core.go
@@ -68,15 +68,43 @@ const (
// CoreHello is the first message sent by a client.
type CoreHello struct {
- // version number of the client; PW_VERSION_CORE
+ // The version number of the client, usually PW_VERSION_CORE.
Version Int
}
// MarshalBinary satisfies [encoding.BinaryMarshaler] via [MarshalAppend].
-func (c *CoreHello) MarshalBinary() ([]byte, error) { return MarshalAppend(make([]byte, 0, 24), c) }
+func (c *CoreHello) MarshalBinary() ([]byte, error) {
+ return MarshalAppend(make([]byte, 0, 24), c)
+}
// UnmarshalBinary satisfies [encoding.BinaryUnmarshaler] via [Unmarshal].
func (c *CoreHello) UnmarshalBinary(data []byte) error {
_, err := Unmarshal(data, c)
return err
}
+
+// CoreGetRegistry is sent when a client requests to bind to the
+// registry object and list the available objects on the server.
+//
+// Like with all bindings, first the client allocates a new proxy
+// id and puts this as the new_id field. Methods and Events can
+// then be sent and received on the new_id (in the message Id field).
+type CoreGetRegistry struct {
+ // The version of the registry interface used on the client,
+ // usually PW_VERSION_REGISTRY.
+ Version Int
+ // The id of the new proxy with the registry interface,
+ // ends up as [Header.ID] in future messages.
+ NewID Int
+}
+
+// MarshalBinary satisfies [encoding.BinaryMarshaler] via [MarshalAppend].
+func (c *CoreGetRegistry) MarshalBinary() ([]byte, error) {
+ return MarshalAppend(make([]byte, 0, 40), c)
+}
+
+// UnmarshalBinary satisfies [encoding.BinaryUnmarshaler] via [Unmarshal].
+func (c *CoreGetRegistry) UnmarshalBinary(data []byte) error {
+ _, err := Unmarshal(data, c)
+ return err
+}
diff --git a/internal/pipewire/core_test.go b/internal/pipewire/core_test.go
index d8c7cf90..b47c4265 100644
--- a/internal/pipewire/core_test.go
+++ b/internal/pipewire/core_test.go
@@ -13,3 +13,12 @@ func TestCoreHello(t *testing.T) {
}, nil},
}.run(t)
}
+
+func TestCoreGetRegistry(t *testing.T) {
+ encodingTestCases[pipewire.CoreGetRegistry, *pipewire.CoreGetRegistry]{
+ {"sample", []byte(sendmsg00Message02POD), pipewire.CoreGetRegistry{
+ Version: pipewire.PW_VERSION_REGISTRY,
+ NewID: 2,
+ }, nil},
+ }.run(t)
+}
diff --git a/internal/pipewire/header_test.go b/internal/pipewire/header_test.go
index 95f6ce13..2d055088 100644
--- a/internal/pipewire/header_test.go
+++ b/internal/pipewire/header_test.go
@@ -23,6 +23,12 @@ func TestHeader(t *testing.T) {
Size: 0x600, Sequence: 1, FileCount: 0,
}, nil},
+ {"PW_CORE_METHOD_GET_REGISTRY", []byte(sendmsg00Message02Header), pipewire.Header{
+ ID: pipewire.PW_ID_CORE,
+ Opcode: pipewire.PW_CORE_METHOD_GET_REGISTRY,
+ Size: 0x28, Sequence: 2, FileCount: 0,
+ }, nil},
+
{"PW_SECURITY_CONTEXT_METHOD_CREATE", []byte{
// Id
3, 0, 0, 0,
diff --git a/internal/pipewire/pipewire_test.go b/internal/pipewire/pipewire_test.go
index 49f128fc..fe16bb53 100644
--- a/internal/pipewire/pipewire_test.go
+++ b/internal/pipewire/pipewire_test.go
@@ -14,4 +14,9 @@ var (
sendmsg00Message01Header string
//go:embed testdata/03-sendmsg00-message01-POD
sendmsg00Message01POD string
+
+ //go:embed testdata/04-sendmsg00-message02-header
+ sendmsg00Message02Header string
+ //go:embed testdata/05-sendmsg00-message02-POD
+ sendmsg00Message02POD string
)
diff --git a/internal/pipewire/testdata/04-sendmsg00-message02-header b/internal/pipewire/testdata/04-sendmsg00-message02-header
new file mode 100644
index 00000000..c10de62c
--- /dev/null
+++ b/internal/pipewire/testdata/04-sendmsg00-message02-header
Binary files differ
diff --git a/internal/pipewire/testdata/05-sendmsg00-message02-POD b/internal/pipewire/testdata/05-sendmsg00-message02-POD
new file mode 100644
index 00000000..647038e6
--- /dev/null
+++ b/internal/pipewire/testdata/05-sendmsg00-message02-POD
Binary files differ