AlexxIT/go2rtc · error

not implemented

Error message

not implemented

What it means

MimeType() maps go2rtc core codec identifiers to WebRTC MIME type strings. The switch has no default case, so any codec constant that is not explicitly mapped reaches the trailing panic("not implemented"). This is an intentional fail-fast guard for codec mappings the library does not support in WebRTC.

Solutions

  1. Check the stream's actual codec (via the streams API or logs) and re-encode/transcode the source to a supported audio codec (PCM, Opus, or G722)
  2. Upgrade go2rtc - newer versions add more codec mappings
  3. If adding a codec in code, extend the switch in MimeType with the new core.Codec case returning the corresponding webrtc.MimeType constant

Example fix

// before
case core.CodecG722:
    return webrtc.MimeTypeG722
}
panic("not implemented")
// after
case core.CodecG722:
    return webrtc.MimeTypeG722
case core.CodecH264:
    return webrtc.MimeTypeH264
default:
    return ""
}
Defensive patterns

Strategy: validation

Validate before calling

var supported = map[core.Codec]bool{
    core.CodecPCMA: true, core.CodecOpus: true, core.CodecG722: true,
}
if !supported[trackCodec] {
    return fmt.Errorf("codec %v not supported for webrtc", trackCodec)
}

Type guard

func webrtcSupported(c core.Codec) bool {
    return c == core.CodecPCMA || c == core.CodecOpus || c == core.CodecG722
}

Prevention

When it happens

Trigger: Calling GetTrack (which calls MimeType) with a stream whose codec is one not listed in the switch (e.g. CodecH264 vs PCM/Opus/G722 variants, or a future/unknown codec constant).

Common situations: WebRTC sessions negotiated over an audio stream encoded with an audio codec go2rtc doesn't map here (like MP3, AAC, or an unknown codec byte); config misconfiguration selecting an unsupported audio codec for a webrtc consumer.

Related errors


AI-assisted analysis of AlexxIT/go2rtc@c245815e75 (2026-09-07). Data as JSON: /api/errors/8a93962731d0f7cc. Report an issue: GitHub.

Appendix: source

Thrown at pkg/webrtc/helpers.go:274

		return webrtc.MimeTypeH264
	case core.CodecH265:
		return webrtc.MimeTypeH265
	case core.CodecVP8:
		return webrtc.MimeTypeVP8
	case core.CodecVP9:
		return webrtc.MimeTypeVP9
	case core.CodecAV1:
		return webrtc.MimeTypeAV1
	case core.CodecPCMU:
		return webrtc.MimeTypePCMU
	case core.CodecPCMA:
		return webrtc.MimeTypePCMA
	case core.CodecOpus:
		return webrtc.MimeTypeOpus
	case core.CodecG722:
		return webrtc.MimeTypeG722
	}
	panic("not implemented")
}

func CandidateICE(network, host, port string, priority uint32) string {
	// 1. Foundation
	// 2. Component, always 1 because RTP
	// 3. "udp" or "tcp"
	// 4. Priority
	// 5. Host - IP4 or IP6 or domain name
	// 6. Port
	// 7. "typ host"
	foundation := crc32.ChecksumIEEE([]byte("host" + host + network + "4"))
	s := fmt.Sprintf("candidate:%d 1 %s %d %s %s typ host", foundation, network, priority, host, port)
	if network == "tcp" {
		return s + " tcptype passive"
	}
	return s
}

View on GitHub (pinned to c245815e75)