aboutsummaryrefslogtreecommitdiffhomepage
path: root/internal/pipewire
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2025-11-25 18:37:50 +0900
committerOphestra <cat@gensokyo.uk>2025-11-25 18:40:19 +0900
commit77f5b89a4180600179d4f0d1683b063b43372811 (patch)
treee805e5654d79c4a8a035c4d18b2849b0e003ad46 /internal/pipewire
parent14e33f17e52f27997380bdf87d12bf5d8121c586 (diff)
internal/pipewire: implement Core::BoundProps
Very straightforward type, everything is already supported. Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'internal/pipewire')
-rw-r--r--internal/pipewire/client_test.go2
-rw-r--r--internal/pipewire/core.go20
-rw-r--r--internal/pipewire/core_test.go29
-rw-r--r--internal/pipewire/header_test.go6
-rw-r--r--internal/pipewire/pipewire_test.go5
-rw-r--r--internal/pipewire/testdata/11-recvmsg00-message01-headerbin0 -> 16 bytes
-rw-r--r--internal/pipewire/testdata/12-recvmsg00-message01-PODbin0 -> 408 bytes
7 files changed, 62 insertions, 0 deletions
diff --git a/internal/pipewire/client_test.go b/internal/pipewire/client_test.go
index d7f723eb..378112be 100644
--- a/internal/pipewire/client_test.go
+++ b/internal/pipewire/client_test.go
@@ -7,6 +7,8 @@ import (
)
func TestClientUpdateProperties(t *testing.T) {
+ t.Parallel()
+
encodingTestCases[pipewire.ClientUpdateProperties, *pipewire.ClientUpdateProperties]{
{"sample", []byte(sendmsg00Message01POD), pipewire.ClientUpdateProperties{Props: &pipewire.SPADict{NItems: 0x1e, Items: []pipewire.SPADictItem{
{Key: "remote.intention", Value: "manager"},
diff --git a/internal/pipewire/core.go b/internal/pipewire/core.go
index e5b6abbb..75d2b768 100644
--- a/internal/pipewire/core.go
+++ b/internal/pipewire/core.go
@@ -111,6 +111,26 @@ func (c *CoreInfo) UnmarshalBinary(data []byte) error {
return err
}
+// The CoreBoundProps event is emitted when a local object ID is bound to a global ID.
+// It is emitted before the global becomes visible in the registry.
+type CoreBoundProps struct {
+ // A proxy id.
+ ID Int
+ // The global_id as it will appear in the registry.
+ GlobalID Int
+ // The properties of the global.
+ Props *SPADict
+}
+
+// MarshalBinary satisfies [encoding.BinaryMarshaler] via [Marshal].
+func (c *CoreBoundProps) MarshalBinary() ([]byte, error) { return Marshal(c) }
+
+// UnmarshalBinary satisfies [encoding.BinaryUnmarshaler] via [Unmarshal].
+func (c *CoreBoundProps) UnmarshalBinary(data []byte) error {
+ _, err := Unmarshal(data, c)
+ return err
+}
+
// CoreHello is the first message sent by a client.
type CoreHello struct {
// The version number of the client, usually PW_VERSION_CORE.
diff --git a/internal/pipewire/core_test.go b/internal/pipewire/core_test.go
index 661dc391..1dc63278 100644
--- a/internal/pipewire/core_test.go
+++ b/internal/pipewire/core_test.go
@@ -7,6 +7,8 @@ import (
)
func TestFooterCoreGeneration(t *testing.T) {
+ t.Parallel()
+
encodingTestCases[pipewire.Footer[pipewire.FooterCoreGeneration], *pipewire.Footer[pipewire.FooterCoreGeneration]]{
{"sample", []byte(recvmsg00Message00Footer), pipewire.Footer[pipewire.FooterCoreGeneration]{
Opcode: pipewire.FOOTER_CORE_OPCODE_GENERATION,
@@ -16,6 +18,8 @@ func TestFooterCoreGeneration(t *testing.T) {
}
func TestCoreInfo(t *testing.T) {
+ t.Parallel()
+
encodingTestCases[pipewire.CoreInfo, *pipewire.CoreInfo]{
{"sample", []byte(recvmsg00Message00POD), pipewire.CoreInfo{
ID: 0,
@@ -61,7 +65,28 @@ func TestCoreInfo(t *testing.T) {
}.run(t)
}
+func TestCoreBoundProps(t *testing.T) {
+ t.Parallel()
+
+ encodingTestCases[pipewire.CoreBoundProps, *pipewire.CoreBoundProps]{
+ {"sample", []byte(recvmsg00Message01POD), pipewire.CoreBoundProps{
+ ID: pipewire.PW_ID_CLIENT,
+ GlobalID: 34,
+ Props: &pipewire.SPADict{NItems: 7, Items: []pipewire.SPADictItem{
+ {Key: "object.serial", Value: "34"},
+ {Key: "module.id", Value: "2"},
+ {Key: "pipewire.protocol", Value: "protocol-native"},
+ {Key: "pipewire.sec.pid", Value: "1443"},
+ {Key: "pipewire.sec.uid", Value: "1000"},
+ {Key: "pipewire.sec.gid", Value: "100"},
+ {Key: "pipewire.sec.socket", Value: "pipewire-0-manager"}},
+ }}, nil},
+ }.run(t)
+}
+
func TestCoreHello(t *testing.T) {
+ t.Parallel()
+
encodingTestCases[pipewire.CoreHello, *pipewire.CoreHello]{
{"sample", []byte(sendmsg00Message00POD), pipewire.CoreHello{
Version: pipewire.PW_VERSION_CORE,
@@ -70,6 +95,8 @@ func TestCoreHello(t *testing.T) {
}
func TestCoreSync(t *testing.T) {
+ t.Parallel()
+
encodingTestCases[pipewire.CoreSync, *pipewire.CoreSync]{
{"sample", []byte(sendmsg00Message03POD), pipewire.CoreSync{
ID: pipewire.PW_ID_CORE,
@@ -79,6 +106,8 @@ func TestCoreSync(t *testing.T) {
}
func TestCoreGetRegistry(t *testing.T) {
+ t.Parallel()
+
encodingTestCases[pipewire.CoreGetRegistry, *pipewire.CoreGetRegistry]{
{"sample", []byte(sendmsg00Message02POD), pipewire.CoreGetRegistry{
Version: pipewire.PW_VERSION_REGISTRY,
diff --git a/internal/pipewire/header_test.go b/internal/pipewire/header_test.go
index fb13be14..5ac59102 100644
--- a/internal/pipewire/header_test.go
+++ b/internal/pipewire/header_test.go
@@ -41,6 +41,12 @@ func TestHeader(t *testing.T) {
Size: 0x6b8, Sequence: 0, FileCount: 0,
}, nil},
+ {"PW_CORE_EVENT_BOUND_PROPS", []byte(recvmsg00Message01Header), pipewire.Header{
+ ID: pipewire.PW_ID_CORE,
+ Opcode: pipewire.PW_CORE_EVENT_BOUND_PROPS,
+ Size: 0x198, Sequence: 1, 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 a5770176..cd190011 100644
--- a/internal/pipewire/pipewire_test.go
+++ b/internal/pipewire/pipewire_test.go
@@ -31,4 +31,9 @@ var (
recvmsg00Message00POD string
//go:embed testdata/10-recvmsg00-message00-footer
recvmsg00Message00Footer string
+
+ //go:embed testdata/11-recvmsg00-message01-header
+ recvmsg00Message01Header string
+ //go:embed testdata/12-recvmsg00-message01-POD
+ recvmsg00Message01POD string
)
diff --git a/internal/pipewire/testdata/11-recvmsg00-message01-header b/internal/pipewire/testdata/11-recvmsg00-message01-header
new file mode 100644
index 00000000..ba89297f
--- /dev/null
+++ b/internal/pipewire/testdata/11-recvmsg00-message01-header
Binary files differ
diff --git a/internal/pipewire/testdata/12-recvmsg00-message01-POD b/internal/pipewire/testdata/12-recvmsg00-message01-POD
new file mode 100644
index 00000000..60d1d538
--- /dev/null
+++ b/internal/pipewire/testdata/12-recvmsg00-message01-POD
Binary files differ