diff --git a/internal/pipewire/client_test.go b/internal/pipewire/client_test.go index d7f723e..378112b 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 e5b6abb..75d2b76 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 661dc39..1dc6327 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 fb13be1..5ac5910 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/testdata/11-recvmsg00-message01-header b/internal/pipewire/testdata/11-recvmsg00-message01-header new file mode 100644 index 0000000..ba89297 Binary files /dev/null and b/internal/pipewire/testdata/11-recvmsg00-message01-header differ diff --git a/internal/pipewire/testdata/12-recvmsg00-message01-POD b/internal/pipewire/testdata/12-recvmsg00-message01-POD new file mode 100644 index 0000000..60d1d53 Binary files /dev/null and b/internal/pipewire/testdata/12-recvmsg00-message01-POD differ