2020-05-31 10:57:41 +00:00
|
|
|
'Device Capabilities for Roku.
|
2020-07-11 07:52:52 +00:00
|
|
|
'This will likely need further tweaking
|
2020-05-31 10:57:41 +00:00
|
|
|
function getDeviceCapabilities() as object
|
|
|
|
|
|
|
|
return {
|
2021-07-09 20:08:32 +00:00
|
|
|
"PlayableMediaTypes": [
|
|
|
|
"Audio",
|
2023-06-01 03:19:03 +00:00
|
|
|
"Video",
|
|
|
|
"Photo"
|
2021-07-09 20:08:32 +00:00
|
|
|
],
|
|
|
|
"SupportedCommands": [],
|
2023-06-01 04:38:31 +00:00
|
|
|
"SupportsPersistentIdentifier": false,
|
2021-07-09 20:08:32 +00:00
|
|
|
"SupportsMediaControl": false,
|
|
|
|
"DeviceProfile": getDeviceProfile()
|
|
|
|
}
|
2020-05-31 10:57:41 +00:00
|
|
|
end function
|
|
|
|
|
2023-05-27 20:43:05 +00:00
|
|
|
' Send Device Profile information to server
|
|
|
|
sub PostDeviceProfile()
|
2023-06-01 03:19:03 +00:00
|
|
|
profile = getDeviceCapabilities()
|
2023-05-27 20:43:05 +00:00
|
|
|
req = APIRequest("/Sessions/Capabilities/Full")
|
|
|
|
req.SetRequest("POST")
|
2023-06-01 03:19:03 +00:00
|
|
|
print "profile =", profile
|
|
|
|
print "profile.DeviceProfile =", profile.DeviceProfile
|
|
|
|
print "profile.DeviceProfile.CodecProfiles ="
|
|
|
|
for each prof in profile.DeviceProfile.CodecProfiles
|
|
|
|
print prof
|
|
|
|
for each cond in prof.Conditions
|
|
|
|
print cond
|
|
|
|
end for
|
|
|
|
end for
|
|
|
|
print "profile.DeviceProfile.ContainerProfiles =", profile.DeviceProfile.ContainerProfiles
|
|
|
|
print "profile.DeviceProfile.DirectPlayProfiles ="
|
|
|
|
for each prof in profile.DeviceProfile.DirectPlayProfiles
|
|
|
|
print prof
|
|
|
|
end for
|
|
|
|
print "profile.DeviceProfile.SubtitleProfiles ="
|
|
|
|
for each prof in profile.DeviceProfile.SubtitleProfiles
|
|
|
|
print prof
|
|
|
|
end for
|
|
|
|
print "profile.DeviceProfile.TranscodingProfiles ="
|
|
|
|
for each prof in profile.DeviceProfile.TranscodingProfiles
|
|
|
|
print prof
|
|
|
|
end for
|
|
|
|
print "profile.PlayableMediaTypes =", profile.PlayableMediaTypes
|
|
|
|
print "profile.SupportedCommands =", profile.SupportedCommands
|
|
|
|
postJson(req, FormatJson(profile))
|
2023-05-27 20:43:05 +00:00
|
|
|
end sub
|
2020-05-31 10:57:41 +00:00
|
|
|
|
|
|
|
function getDeviceProfile() as object
|
2023-06-01 12:43:27 +00:00
|
|
|
playMpeg2 = m.global.session.user.settings["playback.mpeg2"]
|
|
|
|
playAv1 = m.global.session.user.settings["playback.av1"]
|
2023-06-01 03:19:03 +00:00
|
|
|
di = CreateObject("roDeviceInfo")
|
|
|
|
|
2023-06-02 04:37:22 +00:00
|
|
|
audioChannelIntegers = [
|
|
|
|
2, ' stereo
|
|
|
|
6, ' 5.1 channel
|
|
|
|
8 ' 7.1 channel
|
|
|
|
]
|
|
|
|
transContainers = ["mp4", "hls", "mkv", "ism", "dash", "ts"]
|
|
|
|
supportedVideoCodecs = {}
|
|
|
|
supportedAudioCodecs = {}
|
|
|
|
addH264Profile = false
|
2022-07-07 20:13:30 +00:00
|
|
|
addHevcProfile = false
|
2023-06-02 04:37:22 +00:00
|
|
|
addMpeg2Profile = false
|
|
|
|
addAv1Profile = false
|
|
|
|
addVp9Profile = false
|
|
|
|
|
|
|
|
' AVC / h264
|
|
|
|
h264Profiles = ["main", "high"]
|
|
|
|
h264Levels = ["4.1", "4.2"]
|
2023-06-01 03:19:03 +00:00
|
|
|
|
2023-06-02 04:37:22 +00:00
|
|
|
for each container in transContainers
|
|
|
|
for each profile in h264Profiles
|
|
|
|
for each level in h264Levels
|
|
|
|
if di.CanDecodeVideo({ Codec: "h264", Container: container, Profile: profile, Level: level }).Result
|
|
|
|
addH264Profile = true
|
|
|
|
if supportedVideoCodecs[container] = invalid
|
|
|
|
supportedVideoCodecs[container] = {}
|
|
|
|
end if
|
|
|
|
if supportedVideoCodecs[container]["h264"] = invalid
|
|
|
|
supportedVideoCodecs[container]["h264"] = {}
|
|
|
|
end if
|
|
|
|
if supportedVideoCodecs[container]["h264"][profile] = invalid
|
|
|
|
supportedVideoCodecs[container]["h264"][profile] = []
|
|
|
|
end if
|
|
|
|
supportedVideoCodecs[container]["h264"][profile].push(level)
|
|
|
|
end if
|
|
|
|
end for
|
|
|
|
end for
|
|
|
|
end for
|
2023-06-01 03:19:03 +00:00
|
|
|
|
2023-06-02 04:37:22 +00:00
|
|
|
' HEVC / h265
|
|
|
|
hevcProfiles = ["main", "main 10"]
|
|
|
|
hevcLevels = ["4.1", "5.0", "5.1"]
|
2023-06-01 03:19:03 +00:00
|
|
|
|
2023-06-02 04:37:22 +00:00
|
|
|
for each container in transContainers
|
2023-06-01 03:19:03 +00:00
|
|
|
for each profile in hevcProfiles
|
|
|
|
for each level in hevcLevels
|
2023-06-02 04:37:22 +00:00
|
|
|
if di.CanDecodeVideo({ Codec: "hevc", Container: container, Profile: profile, Level: level }).Result
|
|
|
|
addHevcProfile = true
|
|
|
|
' hevc codec string
|
|
|
|
if supportedVideoCodecs[container] = invalid
|
|
|
|
supportedVideoCodecs[container] = {}
|
|
|
|
end if
|
|
|
|
if supportedVideoCodecs[container]["hevc"] = invalid
|
|
|
|
supportedVideoCodecs[container]["hevc"] = {}
|
|
|
|
end if
|
|
|
|
if supportedVideoCodecs[container]["hevc"][profile] = invalid
|
|
|
|
supportedVideoCodecs[container]["hevc"][profile] = []
|
|
|
|
end if
|
|
|
|
supportedVideoCodecs[container]["hevc"][profile].push(level)
|
|
|
|
' h265 codec string
|
|
|
|
if supportedVideoCodecs[container] = invalid
|
|
|
|
supportedVideoCodecs[container] = {}
|
|
|
|
end if
|
|
|
|
if supportedVideoCodecs[container]["h265"] = invalid
|
|
|
|
supportedVideoCodecs[container]["h265"] = {}
|
|
|
|
end if
|
|
|
|
if supportedVideoCodecs[container]["h265"][profile] = invalid
|
|
|
|
supportedVideoCodecs[container]["h265"][profile] = []
|
2023-06-01 03:19:03 +00:00
|
|
|
end if
|
2023-06-02 04:37:22 +00:00
|
|
|
supportedVideoCodecs[container]["h265"][profile].push(level)
|
|
|
|
end if
|
|
|
|
end for
|
|
|
|
end for
|
|
|
|
end for
|
2023-06-01 03:19:03 +00:00
|
|
|
|
2023-06-02 04:37:22 +00:00
|
|
|
' MPEG2
|
|
|
|
mpeg2Levels = ["main", "high"]
|
|
|
|
if playMpeg2
|
|
|
|
for each container in transContainers
|
|
|
|
for each level in mpeg2Levels
|
|
|
|
if di.CanDecodeVideo({ Codec: "mpeg2", Container: container, Level: level }).Result
|
|
|
|
addMpeg2Profile = true
|
|
|
|
if supportedVideoCodecs[container] = invalid
|
|
|
|
supportedVideoCodecs[container] = {}
|
|
|
|
end if
|
|
|
|
if supportedVideoCodecs[container]["mpeg2"] = invalid
|
|
|
|
supportedVideoCodecs[container]["mpeg2"] = []
|
|
|
|
end if
|
|
|
|
supportedVideoCodecs[container]["mpeg2"].push(level)
|
2023-06-01 03:19:03 +00:00
|
|
|
end if
|
|
|
|
end for
|
|
|
|
end for
|
2023-06-02 04:37:22 +00:00
|
|
|
end if
|
2023-06-01 03:19:03 +00:00
|
|
|
|
2023-06-02 04:37:22 +00:00
|
|
|
' AV1
|
|
|
|
av1Profiles = ["main", "main 10"]
|
|
|
|
av1Levels = ["4.1", "5.0", "5.1"]
|
|
|
|
if playAv1
|
|
|
|
for each container in transContainers
|
|
|
|
for each profile in av1Profiles
|
|
|
|
for each level in av1Levels
|
|
|
|
if di.CanDecodeVideo({ Codec: "av1", Container: container, Profile: profile, Level: level }).Result
|
|
|
|
addAv1Profile = true
|
|
|
|
' av1 codec string
|
|
|
|
if supportedVideoCodecs[container] = invalid
|
|
|
|
supportedVideoCodecs[container] = {}
|
|
|
|
end if
|
|
|
|
if supportedVideoCodecs[container]["av1"] = invalid
|
|
|
|
supportedVideoCodecs[container]["av1"] = {}
|
|
|
|
end if
|
|
|
|
if supportedVideoCodecs[container]["av1"][profile] = invalid
|
|
|
|
supportedVideoCodecs[container]["av1"][profile] = []
|
|
|
|
end if
|
|
|
|
supportedVideoCodecs[container]["av1"][profile].push(level)
|
|
|
|
end if
|
|
|
|
end for
|
|
|
|
end for
|
|
|
|
end for
|
|
|
|
end if
|
|
|
|
|
|
|
|
' VP9
|
|
|
|
vp9Profiles = ["profile 0", "profile 2"]
|
|
|
|
|
|
|
|
for each container in transContainers
|
|
|
|
for each profile in vp9Profiles
|
|
|
|
if di.CanDecodeVideo({ Codec: "vp9", Container: container, Profile: profile }).Result
|
|
|
|
addVp9Profile = true
|
|
|
|
' vp9 codec string
|
|
|
|
if supportedVideoCodecs[container] = invalid
|
|
|
|
supportedVideoCodecs[container] = {}
|
|
|
|
end if
|
|
|
|
if supportedVideoCodecs[container]["vp9"] = invalid
|
|
|
|
supportedVideoCodecs[container]["vp9"] = []
|
|
|
|
end if
|
|
|
|
supportedVideoCodecs[container]["vp9"].push(profile)
|
2023-06-01 03:19:03 +00:00
|
|
|
end if
|
2023-06-02 04:37:22 +00:00
|
|
|
end for
|
|
|
|
end for
|
|
|
|
|
|
|
|
' eac3
|
|
|
|
for each container in transContainers
|
|
|
|
for each audioChannel in audioChannelIntegers
|
|
|
|
if di.CanDecodeAudio({ Codec: "eac3", Container: container, ChCnt: audioChannel }).result
|
|
|
|
if supportedAudioCodecs[container] = invalid
|
|
|
|
supportedAudioCodecs[container] = {}
|
|
|
|
end if
|
|
|
|
|
|
|
|
if supportedAudioCodecs[container]["eac3"] = invalid or audioChannel > supportedAudioCodecs[container]["eac3"]
|
|
|
|
supportedAudioCodecs[container]["eac3"] = audioChannel
|
|
|
|
end if
|
2023-06-01 03:19:03 +00:00
|
|
|
end if
|
|
|
|
end for
|
2023-06-02 04:37:22 +00:00
|
|
|
end for
|
2022-03-29 01:21:02 +00:00
|
|
|
|
2023-06-01 03:19:03 +00:00
|
|
|
|
2023-06-02 04:37:22 +00:00
|
|
|
' ac3
|
|
|
|
for each container in transContainers
|
|
|
|
for each audioChannel in audioChannelIntegers
|
|
|
|
if di.CanDecodeAudio({ Codec: "ac3", Container: container, ChCnt: audioChannel }).result
|
|
|
|
if supportedAudioCodecs[container] = invalid
|
|
|
|
supportedAudioCodecs[container] = {}
|
|
|
|
end if
|
2023-06-01 03:19:03 +00:00
|
|
|
|
2023-06-02 04:37:22 +00:00
|
|
|
if supportedAudioCodecs[container]["ac3"] = invalid or audioChannel > supportedAudioCodecs[container]["ac3"]
|
|
|
|
supportedAudioCodecs[container]["ac3"] = audioChannel
|
2023-06-01 03:19:03 +00:00
|
|
|
end if
|
|
|
|
end if
|
|
|
|
end for
|
2023-06-02 04:37:22 +00:00
|
|
|
end for
|
2021-08-24 01:21:15 +00:00
|
|
|
|
2023-06-02 04:37:22 +00:00
|
|
|
' dts
|
|
|
|
for each container in transContainers
|
|
|
|
for each audioChannel in audioChannelIntegers
|
|
|
|
if di.CanDecodeAudio({ Codec: "dts", Container: container, ChCnt: audioChannel }).result
|
|
|
|
if supportedAudioCodecs[container] = invalid
|
|
|
|
supportedAudioCodecs[container] = {}
|
|
|
|
end if
|
2023-06-01 03:19:03 +00:00
|
|
|
|
2023-06-02 04:37:22 +00:00
|
|
|
if supportedAudioCodecs[container]["dts"] = invalid or audioChannel > supportedAudioCodecs[container]["dts"]
|
|
|
|
supportedAudioCodecs[container]["dts"] = audioChannel
|
|
|
|
end if
|
|
|
|
end if
|
|
|
|
end for
|
|
|
|
end for
|
2023-06-01 03:19:03 +00:00
|
|
|
|
2023-06-02 04:37:22 +00:00
|
|
|
' opus
|
|
|
|
for each container in transContainers
|
|
|
|
for each audioChannel in audioChannelIntegers
|
|
|
|
if di.CanDecodeAudio({ Codec: "opus", Container: container, ChCnt: audioChannel }).result
|
|
|
|
if supportedAudioCodecs[container] = invalid
|
|
|
|
supportedAudioCodecs[container] = {}
|
|
|
|
end if
|
2023-06-01 03:19:03 +00:00
|
|
|
|
2023-06-02 04:37:22 +00:00
|
|
|
if supportedAudioCodecs[container]["opus"] = invalid or audioChannel > supportedAudioCodecs[container]["opus"]
|
|
|
|
supportedAudioCodecs[container]["opus"] = audioChannel
|
|
|
|
end if
|
|
|
|
end if
|
|
|
|
end for
|
|
|
|
end for
|
2021-08-24 01:21:15 +00:00
|
|
|
|
2023-06-02 04:37:22 +00:00
|
|
|
' flac
|
|
|
|
for each container in transContainers
|
|
|
|
for each audioChannel in audioChannelIntegers
|
|
|
|
if di.CanDecodeAudio({ Codec: "flac", Container: container, ChCnt: audioChannel }).result
|
|
|
|
if supportedAudioCodecs[container] = invalid
|
|
|
|
supportedAudioCodecs[container] = {}
|
|
|
|
end if
|
2022-07-07 19:58:01 +00:00
|
|
|
|
2023-06-02 04:37:22 +00:00
|
|
|
if supportedAudioCodecs[container]["flac"] = invalid or audioChannel > supportedAudioCodecs[container]["flac"]
|
|
|
|
supportedAudioCodecs[container]["flac"] = audioChannel
|
|
|
|
end if
|
|
|
|
end if
|
|
|
|
end for
|
|
|
|
end for
|
|
|
|
|
|
|
|
' vorbis
|
|
|
|
for each container in transContainers
|
|
|
|
for each audioChannel in audioChannelIntegers
|
|
|
|
if di.CanDecodeAudio({ Codec: "vorbis", Container: container, ChCnt: audioChannel }).result
|
|
|
|
if supportedAudioCodecs[container] = invalid
|
|
|
|
supportedAudioCodecs[container] = {}
|
|
|
|
end if
|
|
|
|
|
|
|
|
if supportedAudioCodecs[container]["vorbis"] = invalid or audioChannel > supportedAudioCodecs[container]["vorbis"]
|
|
|
|
supportedAudioCodecs[container]["vorbis"] = audioChannel
|
|
|
|
end if
|
|
|
|
end if
|
|
|
|
end for
|
|
|
|
end for
|
|
|
|
|
|
|
|
' aac
|
|
|
|
for each container in transContainers
|
|
|
|
for each audioChannel in audioChannelIntegers
|
|
|
|
if di.CanDecodeAudio({ Codec: "aac", Container: container, ChCnt: audioChannel }).result
|
|
|
|
if supportedAudioCodecs[container] = invalid
|
|
|
|
supportedAudioCodecs[container] = {}
|
|
|
|
end if
|
|
|
|
|
|
|
|
if supportedAudioCodecs[container]["aac"] = invalid or audioChannel > supportedAudioCodecs[container]["aac"]
|
|
|
|
supportedAudioCodecs[container]["aac"] = audioChannel
|
|
|
|
end if
|
|
|
|
end if
|
|
|
|
end for
|
|
|
|
end for
|
|
|
|
|
|
|
|
' mp3
|
|
|
|
for each container in transContainers
|
|
|
|
for each audioChannel in audioChannelIntegers
|
|
|
|
if di.CanDecodeAudio({ Codec: "mp3", Container: container, ChCnt: audioChannel }).result
|
|
|
|
if supportedAudioCodecs[container] = invalid
|
|
|
|
supportedAudioCodecs[container] = {}
|
|
|
|
end if
|
|
|
|
|
|
|
|
if supportedAudioCodecs[container]["mp3"] = invalid or audioChannel > supportedAudioCodecs[container]["mp3"]
|
|
|
|
supportedAudioCodecs[container]["mp3"] = audioChannel
|
|
|
|
end if
|
|
|
|
end if
|
|
|
|
end for
|
|
|
|
end for
|
2021-08-24 01:21:15 +00:00
|
|
|
|
2022-07-07 19:58:01 +00:00
|
|
|
hevcVideoRangeTypes = "SDR"
|
|
|
|
vp9VideoRangeTypes = "SDR"
|
|
|
|
av1VideoRangeTypes = "SDR"
|
|
|
|
|
|
|
|
dp = di.GetDisplayProperties()
|
|
|
|
if dp.Hdr10 ' or dp.Hdr10Plus?
|
2022-10-16 10:45:53 +00:00
|
|
|
hevcVideoRangeTypes = hevcVideoRangeTypes + "|HDR10"
|
|
|
|
vp9VideoRangeTypes = vp9VideoRangeTypes + "|HDR10"
|
|
|
|
av1VideoRangeTypes = av1VideoRangeTypes + "|HDR10"
|
2022-07-07 19:58:01 +00:00
|
|
|
end if
|
|
|
|
if dp.HLG
|
2022-10-16 10:45:53 +00:00
|
|
|
hevcVideoRangeTypes = hevcVideoRangeTypes + "|HLG"
|
|
|
|
vp9VideoRangeTypes = vp9VideoRangeTypes + "|HLG"
|
|
|
|
av1VideoRangeTypes = av1VideoRangeTypes + "|HLG"
|
2022-07-07 19:58:01 +00:00
|
|
|
end if
|
|
|
|
if dp.DolbyVision
|
2022-10-16 10:45:53 +00:00
|
|
|
hevcVideoRangeTypes = hevcVideoRangeTypes + "|DOVI"
|
2022-07-07 19:58:01 +00:00
|
|
|
'vp9VideoRangeTypes = vp9VideoRangeTypes + ",DOVI" no evidence that vp9 can hold DOVI
|
2022-10-16 10:45:53 +00:00
|
|
|
av1VideoRangeTypes = av1VideoRangeTypes + "|DOVI"
|
2022-07-07 19:58:01 +00:00
|
|
|
end if
|
2022-10-16 10:45:53 +00:00
|
|
|
|
2021-10-12 07:13:25 +00:00
|
|
|
DirectPlayProfile = GetDirectPlayProfiles()
|
2021-08-24 01:21:15 +00:00
|
|
|
|
2022-10-16 10:45:53 +00:00
|
|
|
deviceProfile = {
|
2020-05-31 10:57:41 +00:00
|
|
|
"MaxStreamingBitrate": 120000000,
|
|
|
|
"MaxStaticBitrate": 100000000,
|
|
|
|
"MusicStreamingTranscodingBitrate": 192000,
|
2021-10-12 07:13:25 +00:00
|
|
|
"DirectPlayProfiles": DirectPlayProfile,
|
2023-06-02 04:37:22 +00:00
|
|
|
"TranscodingProfiles": [],
|
2020-05-31 10:57:41 +00:00
|
|
|
"ContainerProfiles": [],
|
|
|
|
"CodecProfiles": [
|
2021-10-12 07:13:25 +00:00
|
|
|
{
|
|
|
|
"Type": "VideoAudio",
|
2021-10-12 07:21:31 +00:00
|
|
|
"Codec": DirectPlayProfile[1].AudioCodec, ' Use supported MKV Audio list
|
2021-10-12 07:13:25 +00:00
|
|
|
"Conditions": [
|
|
|
|
{
|
|
|
|
"Condition": "LessThanEqual",
|
|
|
|
"Property": "AudioChannels",
|
2023-06-02 04:37:22 +00:00
|
|
|
"Value": supportedAudioCodecs["mkv"]["flac"].ToStr(),
|
2021-10-12 07:13:25 +00:00
|
|
|
"IsRequired": false
|
|
|
|
}
|
|
|
|
]
|
2020-05-31 10:57:41 +00:00
|
|
|
}
|
|
|
|
],
|
|
|
|
"SubtitleProfiles": [
|
|
|
|
{
|
|
|
|
"Format": "vtt",
|
|
|
|
"Method": "External"
|
|
|
|
},
|
|
|
|
{
|
2020-07-11 07:52:52 +00:00
|
|
|
"Format": "srt",
|
2020-05-31 10:57:41 +00:00
|
|
|
"Method": "External"
|
|
|
|
},
|
|
|
|
{
|
2020-07-11 07:52:52 +00:00
|
|
|
"Format": "ttml",
|
2020-05-31 10:57:41 +00:00
|
|
|
"Method": "External"
|
2022-03-29 19:54:46 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"Format": "sub",
|
|
|
|
"Method": "External"
|
2020-05-31 10:57:41 +00:00
|
|
|
}
|
2020-07-11 07:52:52 +00:00
|
|
|
]
|
|
|
|
}
|
2023-06-02 04:37:22 +00:00
|
|
|
|
|
|
|
' build TranscodingProfiles
|
|
|
|
' create an audio profile for each audio codec supported by the mp4 container
|
|
|
|
for each supportedMp4AudioCodec in supportedAudioCodecs["mp4"]
|
|
|
|
' streaming
|
|
|
|
deviceProfile.TranscodingProfiles.push({
|
|
|
|
"Container": supportedMp4AudioCodec,
|
|
|
|
"Type": "Audio",
|
|
|
|
"AudioCodec": supportedMp4AudioCodec,
|
|
|
|
"Context": "Streaming",
|
|
|
|
"Protocol": "http",
|
|
|
|
"MaxAudioChannels": supportedAudioCodecs["mp4"][supportedMp4AudioCodec].ToStr()
|
|
|
|
})
|
|
|
|
' static
|
|
|
|
deviceProfile.TranscodingProfiles.push({
|
|
|
|
"Container": supportedMp4AudioCodec,
|
|
|
|
"Type": "Audio",
|
|
|
|
"AudioCodec": supportedMp4AudioCodec,
|
|
|
|
"Context": "Static",
|
|
|
|
"Protocol": "http",
|
|
|
|
"MaxAudioChannels": supportedAudioCodecs["mp4"][supportedMp4AudioCodec].ToStr()
|
|
|
|
})
|
|
|
|
end for
|
|
|
|
' create a video profile for each container in transContainers
|
|
|
|
for each container in transContainers
|
|
|
|
audioCodecs = []
|
|
|
|
videoCodecs = []
|
|
|
|
for each codec in supportedAudioCodecs[container]
|
|
|
|
audioCodecs.push(codec)
|
|
|
|
end for
|
|
|
|
for each codec in supportedVideoCodecs[container]
|
|
|
|
videoCodecs.push(codec)
|
|
|
|
end for
|
|
|
|
containerArray = {
|
|
|
|
"Container": container,
|
|
|
|
"Context": "Static",
|
|
|
|
"Type": "Video",
|
|
|
|
"AudioCodec": audioCodecs.join(","),
|
|
|
|
"VideoCodec": videoCodecs.join(",")
|
|
|
|
}
|
|
|
|
' grab max audio channels based on container
|
|
|
|
' order of priority: ac3, aac
|
|
|
|
if supportedAudioCodecs[container]["ac3"] <> invalid
|
|
|
|
containerArray["MaxAudioChannels"] = supportedAudioCodecs[container]["ac3"].ToStr()
|
|
|
|
else
|
|
|
|
containerArray["MaxAudioChannels"] = supportedAudioCodecs[container]["aac"].ToStr()
|
|
|
|
end if
|
|
|
|
|
|
|
|
if container = "ts"
|
|
|
|
containerArray["Context"] = "Streaming"
|
|
|
|
containerArray["Protocol"] = "hls"
|
|
|
|
containerArray["MinSegments"] = "1"
|
|
|
|
containerArray["BreakOnNonKeyFrames"] = true
|
|
|
|
else if container = "mp4"
|
|
|
|
containerArray["Context"] = "Static"
|
|
|
|
containerArray["Protocol"] = "http"
|
|
|
|
end if
|
|
|
|
deviceProfile.TranscodingProfiles.push(containerArray)
|
|
|
|
end for
|
|
|
|
|
|
|
|
' build CodecProfiles
|
|
|
|
if addH264Profile
|
|
|
|
' determine highest level supported
|
|
|
|
h264HighestLevel = 0
|
|
|
|
for each profile in h264Profiles
|
|
|
|
for each level in supportedVideoCodecs["ts"]["h264"][profile]
|
|
|
|
levelFloat = level.ToFloat()
|
|
|
|
if levelFloat > h264HighestLevel
|
|
|
|
h264HighestLevel = levelFloat
|
|
|
|
end if
|
|
|
|
end for
|
|
|
|
end for
|
|
|
|
|
|
|
|
videoProfiles = []
|
|
|
|
for each container in transContainers
|
|
|
|
if supportedVideoCodecs[container]["h264"] <> invalid
|
|
|
|
for each profile in supportedVideoCodecs[container]["h264"]
|
|
|
|
videoProfiles.push(profile)
|
|
|
|
end for
|
|
|
|
exit for
|
|
|
|
end if
|
|
|
|
end for
|
|
|
|
|
|
|
|
deviceProfile.CodecProfiles.push({
|
|
|
|
"Type": "Video",
|
|
|
|
"Codec": "h264",
|
|
|
|
"Conditions": [
|
|
|
|
{
|
|
|
|
"Condition": "EqualsAny",
|
|
|
|
"Property": "VideoProfile",
|
|
|
|
"Value": videoProfiles.join("|"),
|
|
|
|
"IsRequired": false
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"Condition": "LessThanEqual",
|
|
|
|
"Property": "VideoLevel",
|
|
|
|
"Value": (120 * h264HighestLevel).ToStr(),
|
|
|
|
"IsRequired": false
|
|
|
|
},
|
|
|
|
GetBitRateLimit("h264")
|
|
|
|
]
|
|
|
|
})
|
|
|
|
end if
|
2023-06-01 03:19:03 +00:00
|
|
|
if addMpeg2Profile
|
2023-06-02 04:37:22 +00:00
|
|
|
mpeg2Levels = []
|
|
|
|
for each container in transContainers
|
|
|
|
if supportedVideoCodecs[container] <> invalid
|
|
|
|
if supportedVideoCodecs[container]["mpeg2"] <> invalid
|
|
|
|
for each level in supportedVideoCodecs[container]["mpeg2"]
|
|
|
|
mpeg2Levels.push(level)
|
|
|
|
end for
|
2023-06-02 14:26:49 +00:00
|
|
|
if mpeg2Levels.count() > 0 then exit for
|
2023-06-02 04:37:22 +00:00
|
|
|
end if
|
|
|
|
end if
|
|
|
|
end for
|
2023-06-01 03:19:03 +00:00
|
|
|
deviceProfile.CodecProfiles.push({
|
|
|
|
"Type": "Video",
|
|
|
|
"Codec": "mpeg2",
|
|
|
|
"Conditions": [
|
|
|
|
{
|
|
|
|
"Condition": "EqualsAny",
|
|
|
|
"Property": "VideoLevel",
|
2023-06-02 04:37:22 +00:00
|
|
|
"Value": mpeg2Levels.join("|"),
|
2023-06-01 03:19:03 +00:00
|
|
|
"IsRequired": false
|
2023-06-02 04:37:22 +00:00
|
|
|
},
|
|
|
|
GetBitRateLimit("mpeg2")
|
2023-06-01 03:19:03 +00:00
|
|
|
]
|
|
|
|
})
|
|
|
|
end if
|
2023-06-02 04:37:22 +00:00
|
|
|
|
2022-07-07 19:58:01 +00:00
|
|
|
if addAv1Profile
|
2023-06-02 04:37:22 +00:00
|
|
|
' determine highest level supported
|
|
|
|
av1HighestLevel = 0.0
|
|
|
|
for each profile in av1Profiles
|
|
|
|
for each level in supportedVideoCodecs["ts"]["av1"][profile]
|
|
|
|
if level.ToFloat() > av1HighestLevel.ToFloat()
|
|
|
|
h264HighestLevel = level
|
|
|
|
end if
|
|
|
|
end for
|
|
|
|
end for
|
|
|
|
|
|
|
|
videoProfiles = []
|
|
|
|
for each container in transContainers
|
|
|
|
if supportedVideoCodecs[container]["av1"] <> invalid
|
|
|
|
for each profile in supportedVideoCodecs[container]["av1"]
|
|
|
|
videoProfiles.push(profile)
|
|
|
|
end for
|
|
|
|
exit for
|
|
|
|
end if
|
|
|
|
end for
|
|
|
|
|
2022-07-07 19:58:01 +00:00
|
|
|
deviceProfile.CodecProfiles.push({
|
2022-10-16 10:45:53 +00:00
|
|
|
"Type": "Video",
|
|
|
|
"Codec": "av1",
|
|
|
|
"Conditions": [
|
2023-06-02 04:37:22 +00:00
|
|
|
{
|
|
|
|
"Condition": "EqualsAny",
|
|
|
|
"Property": "VideoProfile",
|
|
|
|
"Value": videoProfiles.join("|"),
|
|
|
|
"IsRequired": false
|
|
|
|
},
|
2022-10-16 10:45:53 +00:00
|
|
|
{
|
|
|
|
"Condition": "EqualsAny",
|
|
|
|
"Property": "VideoRangeType",
|
|
|
|
"Value": av1VideoRangeTypes,
|
|
|
|
"IsRequired": false
|
2022-12-19 00:15:10 +00:00
|
|
|
},
|
2023-06-02 04:37:22 +00:00
|
|
|
{
|
|
|
|
"Condition": "LessThanEqual",
|
|
|
|
"Property": "VideoLevel",
|
|
|
|
"Value": (120 * av1HighestLevel).ToStr(),
|
|
|
|
"IsRequired": false
|
|
|
|
},
|
2023-01-25 13:44:26 +00:00
|
|
|
GetBitRateLimit("AV1")
|
2022-10-16 10:45:53 +00:00
|
|
|
]
|
|
|
|
})
|
2022-07-07 20:13:30 +00:00
|
|
|
end if
|
2023-06-02 04:37:22 +00:00
|
|
|
|
2022-07-07 20:13:30 +00:00
|
|
|
if addHevcProfile
|
2023-06-02 04:37:22 +00:00
|
|
|
' determine highest level supported
|
|
|
|
hevcHighestLevel = 0.0
|
|
|
|
for each profile in hevcProfiles
|
|
|
|
for each level in supportedVideoCodecs["ts"]["hevc"][profile]
|
|
|
|
levelFloat = level.ToFloat()
|
|
|
|
if levelFloat > hevcHighestLevel
|
|
|
|
hevcHighestLevel = levelFloat
|
|
|
|
end if
|
|
|
|
end for
|
|
|
|
end for
|
|
|
|
|
|
|
|
videoProfiles = []
|
|
|
|
for each container in transContainers
|
|
|
|
if supportedVideoCodecs[container]["hevc"] <> invalid
|
|
|
|
for each profile in supportedVideoCodecs[container]["hevc"]
|
|
|
|
videoProfiles.push(profile)
|
|
|
|
end for
|
|
|
|
exit for
|
|
|
|
end if
|
|
|
|
end for
|
|
|
|
|
|
|
|
' use ts container codecs
|
2022-07-07 20:13:30 +00:00
|
|
|
deviceProfile.CodecProfiles.push({
|
2022-10-16 10:45:53 +00:00
|
|
|
"Type": "Video",
|
|
|
|
"Codec": "hevc",
|
|
|
|
"Conditions": [
|
|
|
|
{
|
|
|
|
"Condition": "EqualsAny",
|
|
|
|
"Property": "VideoProfile",
|
2023-06-02 04:37:22 +00:00
|
|
|
"Value": videoProfiles.join("|"),
|
2022-10-16 10:45:53 +00:00
|
|
|
"IsRequired": false
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"Condition": "EqualsAny",
|
|
|
|
"Property": "VideoRangeType",
|
|
|
|
"Value": hevcVideoRangeTypes,
|
|
|
|
"IsRequired": false
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"Condition": "LessThanEqual",
|
|
|
|
"Property": "VideoLevel",
|
2023-06-01 03:19:03 +00:00
|
|
|
"Value": (120 * hevcHighestLevel).ToStr(),
|
2022-10-16 10:45:53 +00:00
|
|
|
"IsRequired": false
|
2022-12-19 00:15:10 +00:00
|
|
|
},
|
2023-01-25 13:44:26 +00:00
|
|
|
GetBitRateLimit("H265")
|
2022-10-16 10:45:53 +00:00
|
|
|
]
|
|
|
|
})
|
2022-07-07 20:13:30 +00:00
|
|
|
end if
|
2023-06-02 04:37:22 +00:00
|
|
|
|
2022-07-07 19:58:01 +00:00
|
|
|
if addVp9Profile
|
2023-06-02 04:37:22 +00:00
|
|
|
videoProfiles = []
|
|
|
|
for each container in transContainers
|
|
|
|
if supportedVideoCodecs[container]["vp9"] <> invalid
|
|
|
|
for each profile in supportedVideoCodecs[container]["vp9"]
|
|
|
|
videoProfiles.push(profile)
|
|
|
|
end for
|
|
|
|
exit for
|
|
|
|
end if
|
|
|
|
end for
|
|
|
|
|
|
|
|
' use ts container codecs
|
2022-07-07 19:58:01 +00:00
|
|
|
deviceProfile.CodecProfiles.push({
|
2022-10-16 10:45:53 +00:00
|
|
|
"Type": "Video",
|
|
|
|
"Codec": "vp9",
|
|
|
|
"Conditions": [
|
2023-06-02 04:37:22 +00:00
|
|
|
{
|
|
|
|
"Condition": "EqualsAny",
|
|
|
|
"Property": "VideoProfile",
|
|
|
|
"Value": videoProfiles.join("|"),
|
|
|
|
"IsRequired": false
|
|
|
|
},
|
2022-10-16 10:45:53 +00:00
|
|
|
{
|
|
|
|
"Condition": "EqualsAny",
|
|
|
|
"Property": "VideoRangeType",
|
|
|
|
"Value": vp9VideoRangeTypes,
|
|
|
|
"IsRequired": false
|
2022-12-19 00:15:10 +00:00
|
|
|
},
|
2023-06-02 04:37:22 +00:00
|
|
|
GetBitRateLimit("vp9")
|
2022-10-16 10:45:53 +00:00
|
|
|
]
|
|
|
|
})
|
2022-07-07 19:58:01 +00:00
|
|
|
end if
|
2022-10-16 10:45:53 +00:00
|
|
|
|
2022-07-07 19:58:01 +00:00
|
|
|
return deviceProfile
|
2020-07-11 07:52:52 +00:00
|
|
|
end function
|
|
|
|
|
|
|
|
|
|
|
|
function GetDirectPlayProfiles() as object
|
|
|
|
di = CreateObject("roDeviceInfo")
|
2023-06-01 04:35:08 +00:00
|
|
|
' all possible containers
|
|
|
|
supportedCodecs = {
|
|
|
|
mp4: {
|
|
|
|
audio: [],
|
|
|
|
video: []
|
|
|
|
},
|
2023-06-02 04:37:22 +00:00
|
|
|
hls: {
|
2023-06-01 04:35:08 +00:00
|
|
|
audio: [],
|
|
|
|
video: []
|
|
|
|
},
|
2023-06-02 04:37:22 +00:00
|
|
|
mkv: {
|
2023-06-01 04:35:08 +00:00
|
|
|
audio: [],
|
|
|
|
video: []
|
|
|
|
},
|
2023-06-02 04:37:22 +00:00
|
|
|
ism: {
|
2023-06-01 04:35:08 +00:00
|
|
|
audio: [],
|
|
|
|
video: []
|
|
|
|
},
|
2023-06-02 04:37:22 +00:00
|
|
|
dash: {
|
|
|
|
audio: [],
|
|
|
|
video: []
|
|
|
|
},
|
|
|
|
ts: {
|
2023-06-01 04:35:08 +00:00
|
|
|
audio: [],
|
|
|
|
video: []
|
|
|
|
}
|
|
|
|
}
|
|
|
|
' all possible codecs
|
|
|
|
videoCodecs = ["h264", "vp8", "hevc", "vp9"]
|
|
|
|
audioCodecs = ["mp3", "pcm", "lpcm", "wav", "ac3", "wma", "flac", "alac", "aac", "opus", "dts", "wmapro", "vorbis", "eac3"]
|
|
|
|
' respect user settings
|
2023-06-01 13:42:50 +00:00
|
|
|
if m.global.session.user.settings["playback.mpeg4"]
|
2023-06-01 04:35:08 +00:00
|
|
|
videoCodecs.push("mpeg4")
|
2020-07-11 07:52:52 +00:00
|
|
|
end if
|
2023-06-01 13:42:50 +00:00
|
|
|
if m.global.session.user.settings["playback.mpeg2"]
|
2023-06-01 04:35:08 +00:00
|
|
|
videoCodecs.push("mpeg2")
|
2020-07-11 07:52:52 +00:00
|
|
|
end if
|
2023-06-01 04:35:08 +00:00
|
|
|
' check video codecs for each container
|
|
|
|
for each container in supportedCodecs
|
|
|
|
for each videoCodec in videoCodecs
|
|
|
|
if di.CanDecodeVideo({ Codec: videoCodec, Container: container }).Result
|
|
|
|
if videoCodec = "hevc"
|
|
|
|
supportedCodecs[container]["video"].push("hevc")
|
|
|
|
supportedCodecs[container]["video"].push("h265")
|
|
|
|
else if videoCodec = "mpeg2"
|
|
|
|
supportedCodecs[container]["video"].push("mpeg2video")
|
|
|
|
else
|
|
|
|
' device profile string matches codec string
|
|
|
|
supportedCodecs[container]["video"].push(videoCodec)
|
|
|
|
end if
|
|
|
|
end if
|
|
|
|
end for
|
|
|
|
end for
|
|
|
|
' check audio codecs for each container
|
|
|
|
for each container in supportedCodecs
|
|
|
|
for each audioCodec in audioCodecs
|
|
|
|
if di.CanDecodeAudio({ Codec: audioCodec, Container: container }).Result
|
|
|
|
supportedCodecs[container]["audio"].push(audioCodec)
|
|
|
|
end if
|
|
|
|
end for
|
|
|
|
end for
|
|
|
|
' check audio codecs with no container
|
|
|
|
supportedAudio = []
|
|
|
|
for each audioCodec in audioCodecs
|
|
|
|
if di.CanDecodeAudio({ Codec: audioCodec }).Result
|
|
|
|
supportedAudio.push(audioCodec)
|
|
|
|
end if
|
|
|
|
end for
|
2023-06-02 04:37:22 +00:00
|
|
|
' build return array
|
2023-06-01 04:35:08 +00:00
|
|
|
returnArray = []
|
2023-06-02 04:37:22 +00:00
|
|
|
|
2023-06-01 04:35:08 +00:00
|
|
|
for each container in supportedCodecs
|
2023-06-01 04:37:04 +00:00
|
|
|
videoCodecString = supportedCodecs[container]["video"].Join(",")
|
|
|
|
if videoCodecString <> ""
|
2023-06-02 04:37:22 +00:00
|
|
|
containerString = ""
|
|
|
|
if container = "mp4"
|
|
|
|
containerString = "mp4,mov,m4v"
|
|
|
|
else if container = "mkv"
|
|
|
|
containerString = "mkv,webm"
|
|
|
|
else
|
|
|
|
containerString = container
|
|
|
|
end if
|
2023-06-01 04:35:08 +00:00
|
|
|
returnArray.push({
|
2023-06-02 04:37:22 +00:00
|
|
|
"Container": containerString,
|
2023-06-01 04:35:08 +00:00
|
|
|
"Type": "Video",
|
2023-06-01 04:37:04 +00:00
|
|
|
"VideoCodec": videoCodecString,
|
2023-06-01 04:35:08 +00:00
|
|
|
"AudioCodec": supportedCodecs[container]["audio"].Join(",")
|
|
|
|
})
|
|
|
|
end if
|
|
|
|
end for
|
2020-07-11 07:52:52 +00:00
|
|
|
|
2023-06-01 04:35:08 +00:00
|
|
|
returnArray.push({
|
|
|
|
"Container": supportedAudio.Join(","),
|
|
|
|
"Type": "Audio"
|
|
|
|
})
|
|
|
|
return returnArray
|
2022-03-28 19:40:34 +00:00
|
|
|
end function
|
2023-01-25 13:44:26 +00:00
|
|
|
|
2023-06-02 04:37:22 +00:00
|
|
|
function GetBitRateLimit(codec as string) as object
|
2023-06-01 12:43:27 +00:00
|
|
|
if m.global.session.user.settings["playback.bitrate.maxlimited"] = true
|
|
|
|
userSetLimit = m.global.session.user.settings["playback.bitrate.limit"]
|
2023-02-04 13:54:39 +00:00
|
|
|
userSetLimit *= 1000000
|
|
|
|
|
|
|
|
if userSetLimit > 0
|
2023-01-26 03:25:22 +00:00
|
|
|
return {
|
|
|
|
"Condition": "LessThanEqual",
|
|
|
|
"Property": "VideoBitrate",
|
2023-02-04 13:54:39 +00:00
|
|
|
"Value": userSetLimit.ToStr(),
|
2023-06-01 03:19:03 +00:00
|
|
|
"IsRequired": true
|
2023-01-26 03:25:22 +00:00
|
|
|
}
|
2023-02-04 13:54:39 +00:00
|
|
|
else
|
2023-06-02 04:37:22 +00:00
|
|
|
codec = Lcase(codec)
|
2023-02-04 13:54:39 +00:00
|
|
|
' Some repeated values (e.g. same "40mbps" for several codecs)
|
|
|
|
' but this makes it easy to update in the future if the bitrates start to deviate.
|
2023-06-02 04:37:22 +00:00
|
|
|
if codec = "h264"
|
2023-02-04 13:54:39 +00:00
|
|
|
' Roku only supports h264 up to 10Mpbs
|
|
|
|
return {
|
|
|
|
"Condition": "LessThanEqual",
|
|
|
|
"Property": "VideoBitrate",
|
|
|
|
"Value": "10000000",
|
2023-06-01 03:19:03 +00:00
|
|
|
"IsRequired": true
|
2023-02-04 13:54:39 +00:00
|
|
|
}
|
2023-06-02 04:37:22 +00:00
|
|
|
else if codec = "av1"
|
2023-02-04 13:54:39 +00:00
|
|
|
' Roku only supports AV1 up to 40Mpbs
|
|
|
|
return {
|
|
|
|
"Condition": "LessThanEqual",
|
|
|
|
"Property": "VideoBitrate",
|
|
|
|
"Value": "40000000",
|
2023-06-01 03:19:03 +00:00
|
|
|
"IsRequired": true
|
2023-02-04 13:54:39 +00:00
|
|
|
}
|
2023-06-02 04:37:22 +00:00
|
|
|
else if codec = "h265"
|
2023-02-04 13:54:39 +00:00
|
|
|
' Roku only supports h265 up to 40Mpbs
|
|
|
|
return {
|
|
|
|
"Condition": "LessThanEqual",
|
|
|
|
"Property": "VideoBitrate",
|
|
|
|
"Value": "40000000",
|
2023-06-01 03:19:03 +00:00
|
|
|
"IsRequired": true
|
2023-02-04 13:54:39 +00:00
|
|
|
}
|
2023-06-02 04:37:22 +00:00
|
|
|
else if codec = "vp9"
|
2023-02-04 13:54:39 +00:00
|
|
|
' Roku only supports VP9 up to 40Mpbs
|
|
|
|
return {
|
|
|
|
"Condition": "LessThanEqual",
|
|
|
|
"Property": "VideoBitrate",
|
|
|
|
"Value": "40000000",
|
2023-06-01 03:19:03 +00:00
|
|
|
"IsRequired": true
|
2023-02-04 13:54:39 +00:00
|
|
|
}
|
|
|
|
end if
|
2023-01-26 03:25:22 +00:00
|
|
|
end if
|
2023-01-25 13:44:26 +00:00
|
|
|
end if
|
|
|
|
return {}
|
|
|
|
end function
|