Help us shape the future of Go! Take the 2026 Go Developer Survey

media

package
v0.8.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 19, 2026 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Overview

Package media holds the servers of the media and content clusters (ADR 0022): MediaPlayback, KeypadInput, ContentLauncher, ApplicationLauncher, ApplicationBasic, AccountLogin, AudioOutput, Channel, TargetNavigator, MediaInput, LowPower, WakeOnLan, ContentControl and ContentAppObserver. Messages, whose Messages list is fabric-scoped, is cluster/core's [core.Messages].

matter.js has no logic for thirteen of them: each server is the generated behaviour, `export class MediaPlaybackServer extends MediaPlaybackBehavior {}` (packages/node/src/behaviors/media-playback/ MediaPlaybackServer.ts:14 at 0ceb202d) and its siblings; LowPower's `sleep()` emits the `enterLowPowerMode` observable (packages/node/src/behaviors/low-power/LowPowerServer.ts:16-18). A matter.js application implements the commands in a subclass and changes the behaviour's state from them. Here each server is the generated definition (cluster/spec/<name>, ADR 0013) mounted by the standard server (ADR 0017, spec.NewServer) and a typed host port: the host implements the commands; the server decodes the request, calls the port and encodes its answer.

The commands of a cluster with state get the state the attributes report, as a pointer the port may change — matter.js's command implementation writing `this.state`. A command that succeeds commits the change (checked against the definition, a data-version bump and a change report for what moved); one that fails leaves the state as it was, as a matter.js transaction rolls back when its command throws. A change the device makes on its own goes through the server's SetState.

A command answers the port's error as its status: a StatusError with its IM status, any other error FAILURE. A command the cluster's conformance makes optional is accepted only when the port implements it — matter.js leaves an unimplemented command out of AcceptedCommandList and answers it UNSUPPORTED_COMMAND (packages/node/src/node/integration/ ProtocolService.ts:541-545); one the conformance requires and the port does not implement is refused at construction (ErrNotImplemented), as matter.js's ValidatedElements reports "Implementation missing" (packages/node/src/behavior/cluster/ValidatedElements.ts:357-371).

A list- or struct-typed attribute the definition states no default for has no value until the host gives one: a server whose selection serves such an attribute refuses construction without it (ErrMissingState).

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNilPort: the configuration carries no host port.
	ErrNilPort = errors.New("media: a host port is required")
	// ErrMissingState: a served list- or struct-typed attribute without a
	// definition default has no initial value.
	ErrMissingState = errors.New("media: a served attribute has no initial state")
	// ErrNotImplemented: the feature selection requires a command the port
	// does not implement.
	ErrNotImplemented = errors.New("media: the port does not implement a required command")
)

Construction errors; each error a constructor returns wraps one of these or one of spec.NewServer's.

Functions

This section is empty.

Types

type AccountLogin

type AccountLogin interface {
	// GetSetupPIN answers the setup PIN for TempAccountIdentifier (:26-37).
	GetSetupPIN(ctx context.Context, req logindef.GetSetupPinRequest) (logindef.GetSetupPinResponse, error)
	// Login logs the account in with the setup PIN (:39-44); status only.
	Login(ctx context.Context, req logindef.LoginRequest) error
	// Logout logs the account out (:46-49); status only.
	Logout(ctx context.Context, req logindef.LogoutRequest) error
}

AccountLogin is the AccountLogin host port (account-login.element.ts: 26-49). The three commands are fabric-scoped and timed ("F A T", "F O T"): the dispatcher refuses them outside a timed interaction, and the accessing fabric is on ctx (im.LookupFabricFilter).

type AccountLoginConfig

type AccountLoginConfig struct {
	// Port carries out the commands; required.
	Port AccountLogin
	// Events lists the optional events emitted: EventLoggedOut.
	Events []uint32
	// DataVersion is an optional host-owned tracker.
	DataVersion dataVersion
}

AccountLoginConfig carries the construction parameters of an AccountLogin server.

type AccountLoginServer

type AccountLoginServer struct {
	*spec.Server
	// contains filtered or unexported fields
}

AccountLoginServer is an AccountLogin (0x050E) server; the cluster has no attributes beyond the globals.

func NewAccountLogin

func NewAccountLogin(cfg AccountLoginConfig) (*AccountLoginServer, error)

NewAccountLogin builds an AccountLogin server over cfg.Port.

func (*AccountLoginServer) EmitLoggedOut

func (s *AccountLoginServer) EmitLoggedOut(ev logindef.LoggedOutEvent) error

EmitLoggedOut emits LoggedOut (event 0x00, critical; :21-24), which the server emits when cfg.Events lists it.

func (*AccountLoginServer) SetEndpoint

func (e *AccountLoginServer) SetEndpoint(endpoint uint16)

SetEndpoint stamps the endpoint the server's events are addressed to.

type AppBasicConfig

type AppBasicConfig struct {
	// Attributes lists the optional attributes served: AttrVendorName,
	// AttrVendorId, AttrProductId.
	Attributes []uint32
	// Initial is the state the server starts with.
	Initial AppBasicState
	// DataVersion is an optional host-owned tracker.
	DataVersion dataVersion
}

AppBasicConfig carries the construction parameters of an ApplicationBasic server. The cluster has no commands: its state is the host's, set with SetState (the content app's Status as it starts, hides and stops).

type AppBasicServer

type AppBasicServer struct {
	*spec.Server
	// contains filtered or unexported fields
}

AppBasicServer is an ApplicationBasic (0x050D) server.

func NewAppBasic

func NewAppBasic(cfg AppBasicConfig) (*AppBasicServer, error)

NewAppBasic builds an ApplicationBasic server.

func (*AppBasicServer) SetState

func (s *AppBasicServer) SetState(st S) error

SetState commits st, a change the device made: every value is checked against the definition (an error changes nothing), and what moved is reported with one data-version bump.

func (*AppBasicServer) State

func (s *AppBasicServer) State() S

State returns a copy of the committed state.

type AppBasicState

type AppBasicState struct {
	VendorName         string
	VendorID           uint16
	ApplicationName    string
	ProductID          uint16
	Application        *basicdef.ApplicationStruct
	Status             basicdef.ApplicationStatusEnum
	ApplicationVersion string
	AllowedVendorList  []uint16
}

AppBasicState is the ApplicationBasic attribute state (application-basic.element.ts:20-44). The optional VendorName, VendorId and ProductId are served when the configuration lists them. Application and AllowedVendorList are mandatory and have no default: nil refuses construction (ErrMissingState).

type AppLauncher

AppLauncher is the ApplicationLauncher host port: LaunchApp, StopApp and HideApp (:34-50), each answered by LauncherResponse (:51-55). On a content app platform (AP) the Application field names the app; the port makes it current in st and moves the app's ApplicationBasic.Status.

type AppLauncherConfig

type AppLauncherConfig struct {
	// Port carries out the commands; required.
	Port AppLauncher
	// Features is the FeatureMap (AP).
	Features launcherdef.Feature
	// Attributes lists the optional attributes served: AttrCurrentApp.
	Attributes []uint32
	// Initial is the state the server starts with.
	Initial AppLauncherState
	// DataVersion is an optional host-owned tracker.
	DataVersion dataVersion
}

AppLauncherConfig carries the construction parameters of an ApplicationLauncher server.

type AppLauncherServer

type AppLauncherServer struct {
	*spec.Server
	// contains filtered or unexported fields
}

AppLauncherServer is an ApplicationLauncher (0x050C) server.

func NewAppLauncher

func NewAppLauncher(cfg AppLauncherConfig) (*AppLauncherServer, error)

NewAppLauncher builds an ApplicationLauncher server over cfg.Port.

func (*AppLauncherServer) SetState

func (s *AppLauncherServer) SetState(st S) error

SetState commits st, a change the device made: every value is checked against the definition (an error changes nothing), and what moved is reported with one data-version bump.

func (*AppLauncherServer) State

func (s *AppLauncherServer) State() S

State returns a copy of the committed state.

type AppLauncherState

type AppLauncherState struct {
	CatalogList []uint16
	CurrentApp  *launcherdef.ApplicationEPStruct
}

AppLauncherState is the ApplicationLauncher attribute state (application-launcher.element.ts:25-32). CatalogList (ApplicationPlatform, AP) has no default: nil refuses construction with AP (ErrMissingState). CurrentApp (optional, nullable) reads as null while nil.

type ChannelGuide

type ChannelGuide interface {
	GetProgramGuide(ctx context.Context, st *ChannelState, req channeldef.GetProgramGuideRequest) (channeldef.ProgramGuideResponse, error)
}

ChannelGuide is GetProgramGuide, required with ElectronicGuide (EG, :71-98).

type ChannelRecorder

type ChannelRecorder interface {
	RecordProgram(ctx context.Context, st *ChannelState, req channeldef.RecordProgramRequest) error
	CancelRecordProgram(ctx context.Context, st *ChannelState, req channeldef.CancelRecordProgramRequest) error
}

ChannelRecorder is RecordProgram and CancelRecordProgram, required with RecordProgram and ElectronicGuide (RP & EG, :100-126); status only.

type ChannelState

type ChannelState struct {
	ChannelList    []channeldef.ChannelInfoStruct
	Lineup         *channeldef.LineupInfoStruct
	CurrentChannel *channeldef.ChannelInfoStruct
}

ChannelState is the Channel attribute state (channel.element.ts:30-41). ChannelList (ChannelList feature, CL) defaults to the empty list (:31); Lineup (LineupInfo, LI) and CurrentChannel (optional) are nullable and read as null while nil.

type Channels

Channels is the Channel host port. ChangeChannelByNumber and SkipChannel are mandatory (:57-69), status only; ChangeChannel (CL | LI, :43-55) answers ChangeChannelResponse. The port tunes and makes the channel current in st. A port that also implements ChannelGuide takes the ElectronicGuide commands, and ChannelRecorder RecordProgram's.

type ChannelsConfig

type ChannelsConfig struct {
	// Port carries out the commands; required.
	Port Channels
	// Features is the FeatureMap (CL, LI, EG, RP).
	Features channeldef.Feature
	// Attributes lists the optional attributes served: AttrCurrentChannel.
	Attributes []uint32
	// Initial is the state the server starts with.
	Initial ChannelState
	// DataVersion is an optional host-owned tracker.
	DataVersion dataVersion
}

ChannelsConfig carries the construction parameters of a Channel server.

type ChannelsServer

type ChannelsServer struct {
	*spec.Server
	// contains filtered or unexported fields
}

ChannelsServer is a Channel (0x0504) server.

func NewChannels

func NewChannels(cfg ChannelsConfig) (*ChannelsServer, error)

NewChannels builds a Channel server over cfg.Port.

func (*ChannelsServer) SetState

func (s *ChannelsServer) SetState(st S) error

SetState commits st, a change the device made: every value is checked against the definition (an error changes nothing), and what moved is reported with one data-version bump.

func (*ChannelsServer) State

func (s *ChannelsServer) State() S

State returns a copy of the committed state.

type ContentAppObserver

type ContentAppObserver interface {
	ContentAppMessage(ctx context.Context, req observerdef.ContentAppMessageRequest) (observerdef.ContentAppMessageResponse, error)
}

ContentAppObserver is the ContentAppObserver host port: ContentAppMessage with its Data and EncodingHint (content-app-observer.element.ts:22-29), answered by ContentAppMessageResponse (:31-36).

type ContentAppObserverConfig

type ContentAppObserverConfig struct {
	// Port answers ContentAppMessage; required.
	Port ContentAppObserver
	// DataVersion is an optional host-owned tracker.
	DataVersion dataVersion
}

ContentAppObserverConfig carries the construction parameters of a ContentAppObserver server.

type ContentAppObserverServer

type ContentAppObserverServer struct {
	*spec.Server
}

ContentAppObserverServer is a ContentAppObserver (0x0510) server.

func NewContentAppObserver

func NewContentAppObserver(cfg ContentAppObserverConfig) (*ContentAppObserverServer, error)

NewContentAppObserver builds a ContentAppObserver server over cfg.Port.

type ContentControl

type ContentControl interface {
	Enable(ctx context.Context, st *ContentControlState) error
	Disable(ctx context.Context, st *ContentControlState) error
}

ContentControl is the ContentControl host port: Enable and Disable (:87-88), status only. Each feature's commands are a further interface, required with the feature.

type ContentControlApps

type ContentControlApps interface {
	AddBlockApplications(ctx context.Context, st *ContentControlState, req ccdef.AddBlockApplicationsRequest) error
	RemoveBlockApplications(ctx context.Context, st *ContentControlState, req ccdef.RemoveBlockApplicationsRequest) error
}

ContentControlApps is AddBlockApplications and RemoveBlockApplications (BlockApplications, BA, :144-164).

type ContentControlChannels

type ContentControlChannels interface {
	AddBlockChannels(ctx context.Context, st *ContentControlState, req ccdef.AddBlockChannelsRequest) error
	RemoveBlockChannels(ctx context.Context, st *ContentControlState, req ccdef.RemoveBlockChannelsRequest) error
}

ContentControlChannels is AddBlockChannels and RemoveBlockChannels (BlockChannels, BC, :125-142).

type ContentControlConfig

type ContentControlConfig struct {
	// Port carries out the commands; required.
	Port ContentControl
	// Features is the FeatureMap (ST, PM, BU, OCR, SCR, BC, BA, BTW).
	Features ccdef.Feature
	// Initial is the state the server starts with.
	Initial ContentControlState
	// DataVersion is an optional host-owned tracker.
	DataVersion dataVersion
}

ContentControlConfig carries the construction parameters of a ContentControl server.

type ContentControlOnDemandRating

type ContentControlOnDemandRating interface {
	SetOnDemandRatingThreshold(ctx context.Context, st *ContentControlState, req ccdef.SetOnDemandRatingThresholdRequest) error
}

ContentControlOnDemandRating is SetOnDemandRatingThreshold (OnDemandContentRating, OCR, :109-115).

type ContentControlPIN

type ContentControlPIN interface {
	UpdatePin(ctx context.Context, st *ContentControlState, req ccdef.UpdatePinRequest) error
	ResetPin(ctx context.Context, st *ContentControlState) (ccdef.ResetPinResponse, error)
}

ContentControlPIN is UpdatePin and ResetPin (PinManagement, PM, :77-86).

type ContentControlScheduledRating

type ContentControlScheduledRating interface {
	SetScheduledContentRatingThreshold(ctx context.Context, st *ContentControlState, req ccdef.SetScheduledContentRatingThresholdRequest) error
}

ContentControlScheduledRating is SetScheduledContentRatingThreshold (ScheduledContentRating, SCR, :117-123).

type ContentControlScreenTime

type ContentControlScreenTime interface {
	AddBonusTime(ctx context.Context, st *ContentControlState, req ccdef.AddBonusTimeRequest) error
	SetScreenDailyTime(ctx context.Context, st *ContentControlState, req ccdef.SetScreenDailyTimeRequest) error
}

ContentControlScreenTime is AddBonusTime and SetScreenDailyTime (ScreenTime, ST, :89-101).

type ContentControlServer

type ContentControlServer struct {
	*spec.Server
	// contains filtered or unexported fields
}

ContentControlServer is a ContentControl (0x050F) server. Its events (RemainingScreenTimeExpired with ST, EnteringBlockContentTimeWindow with BTW; :75-76) are the host's to raise.

func NewContentControl

func NewContentControl(cfg ContentControlConfig) (*ContentControlServer, error)

NewContentControl builds a ContentControl server over cfg.Port.

func (*ContentControlServer) EmitEnteringBlockContentTimeWindow

func (s *ContentControlServer) EmitEnteringBlockContentTimeWindow() error

EmitEnteringBlockContentTimeWindow emits EnteringBlockContentTimeWindow (event 0x01, info, BlockContentTimeWindow; :76).

func (*ContentControlServer) EmitRemainingScreenTimeExpired

func (s *ContentControlServer) EmitRemainingScreenTimeExpired() error

EmitRemainingScreenTimeExpired emits RemainingScreenTimeExpired (event 0x00, info, ScreenTime; :75).

func (*ContentControlServer) SetEndpoint

func (e *ContentControlServer) SetEndpoint(endpoint uint16)

SetEndpoint stamps the endpoint the server's events are addressed to.

func (*ContentControlServer) SetState

func (s *ContentControlServer) SetState(st S) error

SetState commits st, a change the device made: every value is checked against the definition (an error changes nothing), and what moved is reported with one data-version bump.

func (*ContentControlServer) State

func (s *ContentControlServer) State() S

State returns a copy of the committed state.

type ContentControlState

type ContentControlState struct {
	// Enabled (M).
	Enabled bool
	// OnDemandRatings and OnDemandRatingThreshold: OnDemandContentRating
	// (OCR).
	OnDemandRatings         []ccdef.RatingNameStruct
	OnDemandRatingThreshold string
	// ScheduledContentRatings and ScheduledContentRatingThreshold:
	// ScheduledContentRating (SCR).
	ScheduledContentRatings         []ccdef.RatingNameStruct
	ScheduledContentRatingThreshold string
	// ScreenDailyTime and RemainingScreenTime: ScreenTime (ST).
	ScreenDailyTime     uint32
	RemainingScreenTime uint32
	// BlockUnrated: BlockUnrated (BU).
	BlockUnrated bool
	// BlockChannelList: BlockChannels (BC).
	BlockChannelList []ccdef.BlockChannelStruct
	// BlockApplicationList: BlockApplications (BA).
	BlockApplicationList []ccdef.AppInfoStruct
	// BlockContentTimeWindow: BlockContentTimeWindow (BTW).
	BlockContentTimeWindow []ccdef.TimeWindowStruct
}

ContentControlState is the ContentControl attribute state (content-control.element.ts:35-74); each attribute is served with the feature its conformance names. The lists of a selected feature have no default: nil refuses construction (ErrMissingState).

type ContentControlTimeWindows

type ContentControlTimeWindows interface {
	SetBlockContentTimeWindow(ctx context.Context, st *ContentControlState, req ccdef.SetBlockContentTimeWindowRequest) error
	RemoveBlockContentTimeWindow(ctx context.Context, st *ContentControlState, req ccdef.RemoveBlockContentTimeWindowRequest) error
}

ContentControlTimeWindows is SetBlockContentTimeWindow and RemoveBlockContentTimeWindow (BlockContentTimeWindow, BTW, :166-184).

type ContentControlUnrated

type ContentControlUnrated interface {
	BlockUnratedContent(ctx context.Context, st *ContentControlState) error
	UnblockUnratedContent(ctx context.Context, st *ContentControlState) error
}

ContentControlUnrated is BlockUnratedContent and UnblockUnratedContent (BlockUnrated, BU, :103-107).

type ContentLauncher

ContentLauncher is the ContentLauncher host port: LaunchContent (ContentSearch, CS, :44-54) and LaunchURL (UrlPlayback, UP, :56-65), each answered by LauncherResponse (:67-71). A command whose feature the selection leaves out is not accepted, implemented or not.

type ContentLauncherConfig

type ContentLauncherConfig struct {
	// Port carries out the commands; required.
	Port ContentLauncher
	// Features is the FeatureMap (CS, UP, AS, TT, AT).
	Features launchdef.Feature
	// Initial is the state the server starts with.
	Initial ContentLauncherState
	// DataVersion is an optional host-owned tracker.
	DataVersion dataVersion
}

ContentLauncherConfig carries the construction parameters of a ContentLauncher server.

type ContentLauncherServer

type ContentLauncherServer struct {
	*spec.Server
	// contains filtered or unexported fields
}

ContentLauncherServer is a ContentLauncher (0x050A) server.

func NewContentLauncher

func NewContentLauncher(cfg ContentLauncherConfig) (*ContentLauncherServer, error)

NewContentLauncher builds a ContentLauncher server over cfg.Port.

func (*ContentLauncherServer) SetState

func (s *ContentLauncherServer) SetState(st S) error

SetState commits st, a change the device made: every value is checked against the definition (an error changes nothing), and what moved is reported with one data-version bump.

func (*ContentLauncherServer) State

func (s *ContentLauncherServer) State() S

State returns a copy of the committed state.

type ContentLauncherState

type ContentLauncherState struct {
	AcceptHeader                []string
	SupportedStreamingProtocols launchdef.SupportedProtocolsBitmap
}

ContentLauncherState is the ContentLauncher attribute state (content-launcher.element.ts:31-42), served with UrlPlayback (UP): AcceptHeader, the content types the player takes, defaults to the empty list (:34); SupportedStreamingProtocols to none (:41).

type InputRenamer

type InputRenamer interface {
	RenameInput(ctx context.Context, st *InputState, req inputdef.RenameInputRequest) error
}

InputRenamer is RenameInput, required with NameUpdates (NU, :36-40).

type InputState

type InputState struct {
	InputList    []inputdef.InputInfoStruct
	CurrentInput uint8
}

InputState is the MediaInput attribute state (media-input.element.ts: 25-29). InputList is mandatory and has no default: nil refuses construction (ErrMissingState).

type Inputs

type Inputs interface {
	SelectInput(ctx context.Context, st *InputState, req inputdef.SelectInputRequest) error
	ShowInputStatus(ctx context.Context, st *InputState) error
	HideInputStatus(ctx context.Context, st *InputState) error
}

Inputs is the MediaInput host port: SelectInput, ShowInputStatus and HideInputStatus (:30-35), status only. A port that also implements InputRenamer takes RenameInput.

type InputsConfig

type InputsConfig struct {
	// Port carries out the commands; required.
	Port Inputs
	// Features is the FeatureMap (NU).
	Features inputdef.Feature
	// Initial is the state the server starts with.
	Initial InputState
	// DataVersion is an optional host-owned tracker.
	DataVersion dataVersion
}

InputsConfig carries the construction parameters of a MediaInput server.

type InputsServer

type InputsServer struct {
	*spec.Server
	// contains filtered or unexported fields
}

InputsServer is a MediaInput (0x0507) server.

func NewInputs

func NewInputs(cfg InputsConfig) (*InputsServer, error)

NewInputs builds a MediaInput server over cfg.Port.

func (*InputsServer) SetState

func (s *InputsServer) SetState(st S) error

SetState commits st, a change the device made: every value is checked against the definition (an error changes nothing), and what moved is reported with one data-version bump.

func (*InputsServer) State

func (s *InputsServer) State() S

State returns a copy of the committed state.

type Keypad

type Keypad interface {
	SendKey(ctx context.Context, req keypaddef.SendKeyRequest) (keypaddef.SendKeyResponse, error)
}

Keypad is the KeypadInput host port: SendKey with the CEC key code (keypad-input.element.ts:29-32), answered by SendKeyResponse with its Status (:33-36) — UnsupportedKey or InvalidKeyInCurrentState for a key the device does not take.

type KeypadConfig

type KeypadConfig struct {
	// Port carries out SendKey; required.
	Port Keypad
	// Features is the FeatureMap (NV, LK, NK; :22-27): the key groups the
	// device takes.
	Features keypaddef.Feature
	// DataVersion is an optional host-owned tracker.
	DataVersion dataVersion
}

KeypadConfig carries the construction parameters of a KeypadInput server.

type KeypadServer

type KeypadServer struct {
	*spec.Server
}

KeypadServer is a KeypadInput (0x0509) server; the cluster has no attributes beyond the globals.

func NewKeypad

func NewKeypad(cfg KeypadConfig) (*KeypadServer, error)

NewKeypad builds a KeypadInput server over cfg.Port.

type LowPower

type LowPower interface {
	Sleep(ctx context.Context) error
}

LowPower is the LowPower host port: Sleep (low-power.element.ts:19, status only) puts the device into its low-power mode.

type LowPowerConfig

type LowPowerConfig struct {
	// Port carries out Sleep; required.
	Port LowPower
	// DataVersion is an optional host-owned tracker.
	DataVersion dataVersion
}

LowPowerConfig carries the construction parameters of a LowPower server.

type LowPowerServer

type LowPowerServer struct {
	*spec.Server
}

LowPowerServer is a LowPower (0x0508) server.

Mirrors matter.js packages/node/src/behaviors/low-power/ LowPowerServer.ts:16-18: `sleep()` emits the server's `enterLowPowerMode` observable, the hook through which the application enters the mode, and answers SUCCESS. Here the port is that hook; an error it returns is the command's status.

func NewLowPower

func NewLowPower(cfg LowPowerConfig) (*LowPowerServer, error)

NewLowPower builds a LowPower server over cfg.Port.

type OutputRenamer

type OutputRenamer interface {
	RenameOutput(ctx context.Context, st *OutputState, req outputdef.RenameOutputRequest) error
}

OutputRenamer is RenameOutput, required with NameUpdates (NU, :34-38).

type OutputState

type OutputState struct {
	OutputList    []outputdef.OutputInfoStruct
	CurrentOutput uint8
}

OutputState is the AudioOutput attribute state (audio-output.element.ts: 25-29). OutputList is mandatory and has no default: nil refuses construction (ErrMissingState).

type Outputs

type Outputs interface {
	SelectOutput(ctx context.Context, st *OutputState, req outputdef.SelectOutputRequest) error
}

Outputs is the AudioOutput host port: SelectOutput (:30-33), status only; the port makes the output current in st. A port that also implements OutputRenamer takes RenameOutput.

type OutputsConfig

type OutputsConfig struct {
	// Port carries out the commands; required.
	Port Outputs
	// Features is the FeatureMap (NU).
	Features outputdef.Feature
	// Initial is the state the server starts with.
	Initial OutputState
	// DataVersion is an optional host-owned tracker.
	DataVersion dataVersion
}

OutputsConfig carries the construction parameters of an AudioOutput server.

type OutputsServer

type OutputsServer struct {
	*spec.Server
	// contains filtered or unexported fields
}

OutputsServer is an AudioOutput (0x050B) server.

func NewOutputs

func NewOutputs(cfg OutputsConfig) (*OutputsServer, error)

NewOutputs builds an AudioOutput server over cfg.Port.

func (*OutputsServer) SetState

func (s *OutputsServer) SetState(st S) error

SetState commits st, a change the device made: every value is checked against the definition (an error changes nothing), and what moved is reported with one data-version bump.

func (*OutputsServer) State

func (s *OutputsServer) State() S

State returns a copy of the committed state.

type Playback

Playback is the MediaPlayback host port: the three mandatory transport commands (media-playback.element.ts:96-98), each answering a PlaybackResponse (:115-122). st is the state the attributes report; the port changes it to what the command did. The optional commands are the further interfaces below, accepted when the port implements them.

type PlaybackAudioTracks

type PlaybackAudioTracks interface {
	ActivateAudioTrack(ctx context.Context, st *PlaybackState, req mpdef.ActivateAudioTrackRequest) error
}

PlaybackAudioTracks is ActivateAudioTrack, required with AudioTracks (AT, :141-149); status only.

type PlaybackConfig

type PlaybackConfig struct {
	// Port carries out the commands; required.
	Port Playback
	// Features is the FeatureMap (AS, VS, TT, AT, AA).
	Features mpdef.Feature
	// Events lists the optional events emitted: EventStateChanged.
	Events []uint32
	// Initial is the state the server starts with.
	Initial PlaybackState
	// DataVersion is an optional host-owned tracker.
	DataVersion dataVersion
}

PlaybackConfig carries the construction parameters of a MediaPlayback server.

type PlaybackNext

type PlaybackNext interface {
	Next(ctx context.Context, st *PlaybackState) (mpdef.PlaybackResponse, error)
}

PlaybackNext is Next (optional, :101).

type PlaybackPrevious

type PlaybackPrevious interface {
	Previous(ctx context.Context, st *PlaybackState) (mpdef.PlaybackResponse, error)
}

PlaybackPrevious is Previous (optional, :100).

type PlaybackSeek

type PlaybackSeek interface {
	Seek(ctx context.Context, st *PlaybackState, req mpdef.SeekRequest) (mpdef.PlaybackResponse, error)
}

PlaybackSeek is Seek, required with AdvancedSeek (AS, :136-140).

type PlaybackServer

type PlaybackServer struct {
	*spec.Server
	// contains filtered or unexported fields
}

PlaybackServer is a MediaPlayback (0x0506) server.

func NewPlayback

func NewPlayback(cfg PlaybackConfig) (*PlaybackServer, error)

NewPlayback builds a MediaPlayback server over cfg.Port.

func (*PlaybackServer) EmitStateChanged

func (s *PlaybackServer) EmitStateChanged(ev mpdef.StateChangedEvent) error

EmitStateChanged emits StateChanged (event 0x00, info; :83-95), which the server emits when cfg.Events lists it.

func (*PlaybackServer) SetEndpoint

func (e *PlaybackServer) SetEndpoint(endpoint uint16)

SetEndpoint stamps the endpoint the server's events are addressed to.

func (*PlaybackServer) SetState

func (s *PlaybackServer) SetState(st S) error

SetState commits st, a change the device made: every value is checked against the definition (an error changes nothing), and what moved is reported with one data-version bump.

func (*PlaybackServer) State

func (s *PlaybackServer) State() S

State returns a copy of the committed state.

type PlaybackSkip

type PlaybackSkip interface {
	SkipForward(ctx context.Context, st *PlaybackState, req mpdef.SkipForwardRequest) (mpdef.PlaybackResponse, error)
	SkipBackward(ctx context.Context, st *PlaybackState, req mpdef.SkipBackwardRequest) (mpdef.PlaybackResponse, error)
}

PlaybackSkip is SkipForward and SkipBackward (optional, :123-135).

type PlaybackStartOver

type PlaybackStartOver interface {
	StartOver(ctx context.Context, st *PlaybackState) (mpdef.PlaybackResponse, error)
}

PlaybackStartOver is StartOver (optional, :99).

type PlaybackState

type PlaybackState struct {
	// CurrentState (M).
	CurrentState mpdef.PlaybackStateEnum
	// StartTime, Duration, SampledPosition, PlaybackSpeed, SeekRangeEnd and
	// SeekRangeStart: AdvancedSeek (AS).
	StartTime       *uint64
	Duration        *uint64
	SampledPosition *mpdef.PlaybackPositionStruct
	PlaybackSpeed   float32
	SeekRangeEnd    *uint64
	SeekRangeStart  *uint64
	// ActiveAudioTrack and AvailableAudioTracks: AudioTracks (AT).
	ActiveAudioTrack     *mpdef.TrackStruct
	AvailableAudioTracks []mpdef.TrackStruct
	// ActiveTextTrack and AvailableTextTracks: TextTracks (TT).
	ActiveTextTrack     *mpdef.TrackStruct
	AvailableTextTracks []mpdef.TrackStruct
}

PlaybackState is the MediaPlayback attribute state (matter.js media-playback.element.ts:32-82): the transport the attributes report. A nil pointer or list of a nullable attribute reads as null; an attribute the feature selection does not serve is ignored.

type PlaybackTextTracks

type PlaybackTextTracks interface {
	ActivateTextTrack(ctx context.Context, st *PlaybackState, req mpdef.ActivateTextTrackRequest) error
	DeactivateTextTrack(ctx context.Context, st *PlaybackState) error
}

PlaybackTextTracks is ActivateTextTrack and DeactivateTextTrack, required with TextTracks (TT, :150-158); status only.

type PlaybackVariableSpeed

type PlaybackVariableSpeed interface {
	Rewind(ctx context.Context, st *PlaybackState, req mpdef.RewindRequest) (mpdef.PlaybackResponse, error)
	FastForward(ctx context.Context, st *PlaybackState, req mpdef.FastForwardRequest) (mpdef.PlaybackResponse, error)
}

PlaybackVariableSpeed is Rewind and FastForward, required with VariableSpeed (VS, :102-114).

type StatusError

type StatusError struct {
	// Status is the IM status the invoke answers.
	Status im.StatusCode
	// Err optionally says why; it is not sent.
	Err error
}

StatusError is a port's answer to a command with an IM status other than FAILURE: a command handler returns it, and the invoke answers Status. A cluster-specific status a response command carries (its StatusEnum) is the response's field, not this error.

func (StatusError) Error

func (e StatusError) Error() string

Error implements error.

func (StatusError) MatterStatusCode

func (e StatusError) MatterStatusCode() im.StatusCode

MatterStatusCode implements im.StatusCodeError.

func (StatusError) Unwrap

func (e StatusError) Unwrap() error

Unwrap returns the cause.

type TargetState

type TargetState struct {
	TargetList    []targetdef.TargetInfoStruct
	CurrentTarget uint8
}

TargetState is the TargetNavigator attribute state (target-navigator.element.ts:22-29). TargetList is mandatory and has no default: nil refuses construction (ErrMissingState). CurrentTarget (optional, served when the configuration lists it) is 0xFF — the element's default (:28) — while no target is current.

type Targets

type Targets interface {
	NavigateTarget(ctx context.Context, st *TargetState, req targetdef.NavigateTargetRequest) (targetdef.NavigateTargetResponse, error)
}

Targets is the TargetNavigator host port: NavigateTarget (:41-48), answered by NavigateTargetResponse (:50-54); the port makes the target current in st.

type TargetsConfig

type TargetsConfig struct {
	// Port carries out NavigateTarget; required.
	Port Targets
	// Attributes lists the optional attributes served: AttrCurrentTarget.
	Attributes []uint32
	// Events lists the optional events emitted: EventTargetUpdated.
	Events []uint32
	// Initial is the state the server starts with.
	Initial TargetState
	// DataVersion is an optional host-owned tracker.
	DataVersion dataVersion
}

TargetsConfig carries the construction parameters of a TargetNavigator server.

type TargetsServer

type TargetsServer struct {
	*spec.Server
	// contains filtered or unexported fields
}

TargetsServer is a TargetNavigator (0x0505) server.

func NewTargets

func NewTargets(cfg TargetsConfig) (*TargetsServer, error)

NewTargets builds a TargetNavigator server over cfg.Port.

func (*TargetsServer) EmitTargetUpdated

func (s *TargetsServer) EmitTargetUpdated(ev targetdef.TargetUpdatedEvent) error

EmitTargetUpdated emits TargetUpdated (event 0x00, info; :31-39), which the server emits when cfg.Events lists it.

func (*TargetsServer) SetEndpoint

func (e *TargetsServer) SetEndpoint(endpoint uint16)

SetEndpoint stamps the endpoint the server's events are addressed to.

func (*TargetsServer) SetState

func (s *TargetsServer) SetState(st S) error

SetState commits st, a change the device made: every value is checked against the definition (an error changes nothing), and what moved is reported with one data-version bump.

func (*TargetsServer) State

func (s *TargetsServer) State() S

State returns a copy of the committed state.

type WakeOnLanConfig

type WakeOnLanConfig struct {
	// Attributes lists the optional attributes served: AttrMacAddress,
	// AttrLinkLocalAddress.
	Attributes []uint32
	// Initial is the state the server starts with.
	Initial WakeOnLanState
	// DataVersion is an optional host-owned tracker.
	DataVersion dataVersion
}

WakeOnLanConfig carries the construction parameters of a WakeOnLan server; the cluster has no commands.

type WakeOnLanServer

type WakeOnLanServer struct {
	*spec.Server
	// contains filtered or unexported fields
}

WakeOnLanServer is a WakeOnLan (0x0503) server.

func NewWakeOnLan

func NewWakeOnLan(cfg WakeOnLanConfig) (*WakeOnLanServer, error)

NewWakeOnLan builds a WakeOnLan server.

func (*WakeOnLanServer) SetState

func (s *WakeOnLanServer) SetState(st S) error

SetState commits st, a change the device made: every value is checked against the definition (an error changes nothing), and what moved is reported with one data-version bump.

func (*WakeOnLanServer) State

func (s *WakeOnLanServer) State() S

State returns a copy of the committed state.

type WakeOnLanState

type WakeOnLanState struct {
	MacAddress       string
	LinkLocalAddress []byte
}

WakeOnLanState is the WakeOnLan attribute state (wake-on-lan.element.ts: 15-22), both optional and served when the configuration lists them: MacAddress, the 48-bit MAC as 12 hex digits (max 12), and LinkLocalAddress, the 16-byte IPv6 link-local address.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL