{"record":{"id":"c13e0abaa000239a","repo":"pion/webrtc","slug":"invalid-channel-mapping","errorCode":null,"errorMessage":"invalid channel mapping","messagePattern":"invalid channel mapping","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/media/oggwriter/oggwriter.go","lineNumber":57,"sourceCode":"func validateChannelMappingFamily(family uint8) error {\n\tswitch family {\n\tcase channelMappingFamily1, channelMappingFamily2, channelMappingFamily255:\n\t\treturn nil\n\tdefault:\n\t\treturn fmt.Errorf(\"%w: unsupported family %d\", errInvalidChannelMap, family)\n\t}\n}\n\nfunc validateChannelMappingLayout(streamCount, coupledCount uint8, mapping []byte) error {\n\tif len(mapping) == 0 || len(mapping) > math.MaxUint8 {\n\t\treturn errInvalidChannelCount\n\t}\n\tif streamCount != 1 {\n\t\treturn fmt.Errorf(\"%w: stream count must be one\", errInvalidChannelMap)\n\t}\n\tif coupledCount > streamCount {\n\t\treturn fmt.Errorf(\"%w: coupled count exceeds stream count\", errInvalidChannelMap)\n\t}\n\n\tdecodedChannels := int(streamCount) + int(coupledCount)\n\tfor _, channel := range mapping {\n\t\tif channel != math.MaxUint8 && int(channel) >= decodedChannels {\n\t\t\treturn fmt.Errorf(\"%w: channel map entry is out of range\", errInvalidChannelMap)\n\t\t}\n\t}\n\n\treturn nil\n}","sourceCodeStart":39,"sourceCodeEnd":75,"githubUrl":"https://github.com/pion/webrtc/blob/8c25dc09fa9e7c09aac4309ead88093d760432b0/pkg/media/oggwriter/oggwriter.go#L39-L75","documentation":"errInvalidChannelMap is wrapped by fmt.Errorf in oggwriter's channel-mapping validation helpers for the Opus comment header. It fires when a caller-supplied Opus channel mapping is invalid: an unsupported mapping family (only families 1, 2, and 255 are accepted), stream count not equal to one, coupled count exceeding stream count, or a mapping table entry pointing to a channel outside the decoded channel count.","triggerScenarios":"Thrown at pkg/media/oggwriter/oggwriter.go:57 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use a supported channel mapping family: 1, 2, or 255","Ensure streamCount is 1 and coupledCount <= streamCount","Keep every mapping-table entry either 255 (silent) or an index < streamCount+coupledCount","Build the mapping with the helper API instead of hand-assembling raw values"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"8c25dc09fa9e7c09aac4309ead88093d760432b0","analyzedAt":"2026-09-03T21:56:56.182Z","contentChangedAt":"2026-09-03T21:56:56.182Z","schemaVersion":2},"datasetVersion":"2026-09-11T07:07:21.782Z"}