{"record":{"id":"68e0ec0a97894720","repo":"pion/webrtc","slug":"codec-is-already-set","errorCode":null,"errorMessage":"codec is already set","messagePattern":"codec is already set","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/media/ivfwriter/ivfwriter.go","lineNumber":22,"sourceCode":"// WithCodec configures if IVFWriter is writing AV1 or VP8 packets to disk.\nfunc WithCodec(mimeType string) Option {\n\treturn func(i *IVFWriter) error {\n\t\tif i.codec != codecUnset {\n\t\t\treturn errCodecAlreadySet\n\t\t}\n\n\t\tswitch mimeType {\n\t\tcase mimeTypeVP8:\n\t\t\ti.codec = codecVP8\n\t\tcase mimeTypeVP9:\n\t\t\ti.codec = codecVP9\n\t\tcase mimeTypeAV1:\n\t\t\ti.codec = codecAV1\n\t\tdefault:\n\t\t\treturn errNoSuchCodec\n\t\t}\n\t\treturn nil\n\t}\n}","sourceCodeStart":4,"sourceCodeEnd":40,"githubUrl":"https://github.com/pion/webrtc/blob/8c25dc09fa9e7c09aac4309ead88093d760432b0/pkg/media/ivfwriter/ivfwriter.go#L4-L40","documentation":"Returned by the WithCodec option when it is applied to a writer whose codec was already configured. NewWith applies each Option once during construction, so this fires when WithCodec is supplied more than once (e.g. NewWith(buf, WithCodec(mimeTypeAV1), WithCodec(mimeTypeAV1))). Only one codec may be set per writer.","triggerScenarios":"Thrown at pkg/media/ivfwriter/ivfwriter.go:22 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass WithCodec only once in the NewWith option list","Remove duplicate WithCodec options; a single call with the desired mime type is enough","If codec may be chosen conditionally, build the options slice with at most one WithCodec entry"],"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"}