diff options
Diffstat (limited to 'internal/pipewire/core.go')
| -rw-r--r-- | internal/pipewire/core.go | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/internal/pipewire/core.go b/internal/pipewire/core.go index 80bd217f..6adcac1d 100644 --- a/internal/pipewire/core.go +++ b/internal/pipewire/core.go @@ -572,6 +572,58 @@ func (ctx *Context) GetRegistry() (*Registry, error) { ) } +// CoreCreateObject is sent when the client requests to create a +// new object from a factory of a certain type. +// +// The client allocates a new_id for the proxy. The server will +// allocate a new resource with the same new_id and from then on, +// Methods and Events will be exchanged between the new object of +// the given type. +type CoreCreateObject struct { + // The name of a server factory object to use. + FactoryName String `json:"factory_name"` + // The type of the object to create, this is also the type of + // the interface of the new_id proxy. + Type String `json:"type"` + // Undocumented, assumed to be the local version of the proxy. + Version Int `json:"version"` + // Extra properties to create the object. + Properties *SPADict `json:"props"` + // The proxy id of the new object. + NewID Int `json:"new_id"` +} + +// Opcode satisfies [Message] with a constant value. +func (c *CoreCreateObject) Opcode() byte { return PW_CORE_METHOD_CREATE_OBJECT } + +// FileCount satisfies [Message] with a constant value. +func (c *CoreCreateObject) FileCount() Int { return 0 } + +// Size satisfies [KnownSize] with a value computed at runtime. +func (c *CoreCreateObject) Size() Word { + return SizePrefix + + SizeString[Word](c.FactoryName) + + SizeString[Word](c.Type) + + Size(SizeInt) + + c.Properties.Size() + + Size(SizeInt) +} + +// MarshalBinary satisfies [encoding.BinaryMarshaler] via [Marshal]. +func (c *CoreCreateObject) MarshalBinary() ([]byte, error) { return Marshal(c) } + +// UnmarshalBinary satisfies [encoding.BinaryUnmarshaler] via [Unmarshal]. +func (c *CoreCreateObject) UnmarshalBinary(data []byte) error { return Unmarshal(data, c) } + +// createObject queues a [CoreCreateObject] message for the PipeWire server. +// This is not safe to use directly, callers should use typed wrapper methods on [Registry] instead. +func (core *Core) createObject(factoryName, typeName String, version Int, props SPADict, newId Int) error { + return core.ctx.writeMessage( + PW_ID_CORE, + &CoreCreateObject{factoryName, typeName, version, &props, newId}, + ) +} + // A RegistryGlobal event is emitted to notify a client about a new global object. type RegistryGlobal struct { // The global id. |
