package emby

import "testing"

func TestDirectPlayVideoCodecsIncludeHEVCOnlyForCapableClient(t *testing.T) {
	if got := directPlayVideoCodecs(false); got != "h264" {
		t.Fatalf("baseline codecs = %q", got)
	}
	if got := directPlayVideoCodecs(true); got != "h264,hevc" {
		t.Fatalf("HEVC codecs = %q", got)
	}
}

func TestAndroidTVProfileConstrainsCodecLevelAndResolution(t *testing.T) {
	profile := androidTVDeviceProfile(PlaybackCapabilities{
		H264Profiles: []string{"baseline", "main", "high"},
		H264Level:    52, H264MaxWidth: 3840, H264MaxHeight: 2160,
		HEVC: true, HEVCMain: true, HEVCMain10: true,
		HEVCMainLevel: 153, HEVCMain10Level: 153,
		HEVCMaxWidth: 3840, HEVCMaxHeight: 2160,
	})
	direct := profile["DirectPlayProfiles"].([]map[string]string)
	if direct[0]["VideoCodec"] != "h264,hevc" {
		t.Fatalf("direct video codecs = %q", direct[0]["VideoCodec"])
	}
	transcode := profile["TranscodingProfiles"].([]map[string]string)
	if transcode[0]["VideoCodec"] != "h264,hevc" {
		t.Fatalf("stream-copy codecs = %q", transcode[0]["VideoCodec"])
	}
	codecProfiles := profile["CodecProfiles"].([]map[string]any)
	if len(codecProfiles) < 6 {
		t.Fatalf("codec profiles = %#v", codecProfiles)
	}
}
