package stream

// codecIDToName converts codec ID to codec name
func codecIDToName(codecID int) string {
	switch codecID {
	case 1: // AV_CODEC_ID_MPEG1VIDEO
		return "mpeg1video"
	case 2: // AV_CODEC_ID_MPEG2VIDEO
		return "mpeg2video"
	case 4: // AV_CODEC_ID_MPEG4
		return "mpeg4"
	case 10: // AV_CODEC_ID_MJPEG
		return "mjpeg"
	case 14: // AV_CODEC_ID_MJPEG2000
		return "jpeg2000"
	case 15: // AV_CODEC_ID_H264
		return "h264"
	case 16: // AV_CODEC_ID_H265 / AV_CODEC_ID_HEVC
		return "hevc"
	case 22: // AV_CODEC_ID_VP8
		return "vp8"
	case 23: // AV_CODEC_ID_VP9
		return "vp9"
	case 27: // AV_CODEC_ID_THEORA
		return "theora"
	case 28: // AV_CODEC_ID_AAC
		return "aac"
	case 34: // AV_CODEC_ID_MP3
		return "mp3"
	case 64: // AV_CODEC_ID_AC3
		return "ac3"
	case 65: // AV_CODEC_ID_DTS
		return "dca"
	case 86: // AV_CODEC_ID_OPUS
		return "opus"
	case 87: // AV_CODEC_ID_VORBIS
		return "vorbis"
	case 88: // AV_CODEC_ID_FLAC
		return "flac"
	default:
		return "unknown"
	}
}

// codecIDToLongName converts codec ID to long name
func codecIDToLongName(codecID int) string {
	switch codecID {
	case 1:
		return "MPEG-1 video"
	case 2:
		return "MPEG-2 video"
	case 4:
		return "MPEG-4 part 2"
	case 15:
		return "H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10"
	case 16:
		return "H.265 / HEVC"
	case 22:
		return "On2 VP8"
	case 23:
		return "Google VP9"
	case 27:
		return "Theora"
	case 28:
		return "AAC (Advanced Audio Coding)"
	case 34:
		return "MP3 (MPEG audio layer 3)"
	case 64:
		return "ATSC A/52A (AC-3)"
	case 65:
		return "DCA (DTS Coherent Acoustics)"
	case 86:
		return "Opus"
	case 87:
		return "Vorbis"
	case 88:
		return "FLAC (Free Lossless Audio Codec)"
	default:
		return "Unknown codec"
	}
}

// pixelFormatToString converts pixel format enum to string
func pixelFormatToString(format int) string {
	switch format {
	case 0:
		return "yuv420p"
	case 1:
		return "yuyv422"
	case 2:
		return "yuv422p"
	case 3:
		return "yuv444p"
	case 4:
		return "yuv410p"
	case 5:
		return "yuv411p"
	case 6:
		return "gray"
	case 12:
		return "yuv420p16le"
	case 13:
		return "yuv420p16be"
	case 14:
		return "yuv422p16le"
	case 15:
		return "yuv422p16be"
	case 23:
		return "yuv420p10le"
	case 24:
		return "yuv420p10be"
	case 30:
		return "rgb24"
	case 31:
		return "bgr24"
	case 35:
		return "rgb0"
	case 36:
		return "bgr0"
	default:
		return "unknown"
	}
}

// channelLayoutToString converts channel layout to string
func channelLayoutToString(layout uint64) string {
	switch layout {
	case 0x1:
		return "mono"
	case 0x3:
		return "stereo"
	case 0x7:
		return "2.1"
	case 0x33:
		return "3.0"
	case 0x3f:
		return "3.1"
	case 0x63:
		return "4.0"
	case 0x107:
		return "4.0"
	case 0x3ff:
		return "5.0"
	case 0x303f:
		return "5.0(side)"
	case 0xc0f:
		return "5.1"
	case 0x18ff:
		return "7.1"
	default:
		return "unknown"
	}
}
