{"record":{"id":"cda2fe99a053e84c","repo":"AlexxIT/go2rtc","slug":"errcantgettrack","errorCode":"ErrCantGetTrack","errorMessage":"can't get track","messagePattern":"can't get track","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/core/track.go","lineNumber":10,"sourceCode":"package core\n\nimport (\n\t\"encoding/json\"\n\t\"errors\"\n\n\t\"github.com/pion/rtp\"\n)\n\nvar ErrCantGetTrack = errors.New(\"can't get track\")\n\ntype Receiver struct {\n\tNode\n\n\t// Deprecated: should be removed\n\tMedia *Media `json:\"-\"`\n\t// Deprecated: should be removed\n\tID byte `json:\"-\"` // Channel for RTSP, PayloadType for MPEG-TS\n\n\tBytes   int `json:\"bytes,omitempty\"`\n\tPackets int `json:\"packets,omitempty\"`\n}\n\nfunc NewReceiver(media *Media, codec *Codec) *Receiver {\n\tr := &Receiver{\n\t\tNode:  Node{id: NewID(), Codec: codec},\n\t\tMedia: media,\n\t}","sourceCodeStart":1,"sourceCodeEnd":28,"githubUrl":"https://github.com/AlexxIT/go2rtc/blob/c245815e75e2a5fd60b4290f12bfc04e55a984d3/pkg/core/track.go#L1-L28","documentation":"core.ErrCantGetTrack (\"can't get track\", pkg/core/track.go:10) is the sentinel returned when a media producer cannot supply a Receiver for the requested Media/Codec combination. Several backends (e.g. pkg/alsa/playback_linux.go GetTrack, pkg/doorbird/backchannel.go GetTrack) unconditionally return it because they simply do not support producing a track. It signals an unsupported/unavailable media track, not a transport failure.","triggerScenarios":"Calling GetTrack(media, codec) on a backend that has no track for the given media/codec — including ALSA playback and Doorbird backchannel, which always return ErrCantGetTrack.","commonSituations":"Requesting two-way audio (backchannel) from a Doorbird camera whose integration doesn't support it; requesting a track from a sink that only consumes (ALSA playback); asking for a codec the device doesn't emit; consumer code not checking for the sentinel and treating it as transient.","solutions":["Check support with errors.Is(err, core.ErrCantGetTrack) and skip/disable that track in your application instead of retrying.","Pick a backend/device that supports the requested direction (e.g. use a speaker-capable integration for backchannel).","Request only tracks the device actually produces (inspect Media/Codec from GetMedias first).","Implement the track in the backend if you own the driver code; the stub returns nil, ErrCantGetTrack by design."],"exampleFix":"// before\ntrack, err := producer.GetTrack(media, codec)\nif err != nil {\n    return err // aborts whole pipeline on unsupported backchannel\n}\n// after\ntrack, err := producer.GetTrack(media, codec)\nif errors.Is(err, core.ErrCantGetTrack) {\n    return nil // no track available; continue without it\n}","handlingStrategy":"type-guard","validationCode":"// check the device offers the media before asking for a track\nif len(media.GetVideo()) == 0 && isVideoRequest {\n    return nil // nothing to request\n}","typeGuard":"func trackAvailable(err error) bool {\n    return !errors.Is(err, core.ErrCantGetTrack)\n}","tryCatchPattern":"track, err := producer.GetTrack(media, codec)\nif errors.Is(err, core.ErrCantGetTrack) {\n    log.Info(\"track not supported by backend; continuing without it\")\n    return nil\n}","preventionTips":["Always compare with errors.Is against the sentinel","Enumerate the device's advertised medias before GetTrack","Document which backends are stubs (ALSA playback, Doorbird backchannel)","Design pipelines that tolerate missing tracks"],"tags":["media","track","unsupported","sentinel-error"],"backgroundTag":"resource-not-found","analyzedSha":"c245815e75e2a5fd60b4290f12bfc04e55a984d3","analyzedAt":"2026-09-07T11:47:02.965Z","contentChangedAt":"2026-09-07T11:47:02.965Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}