Update codecs detection for Safari browsers

This commit is contained in:
Alexey Khit
2023-07-13 16:16:37 +03:00
parent c81e29fe54
commit 9fd40467f2
3 changed files with 11 additions and 9 deletions
+3 -3
View File
@@ -997,9 +997,9 @@ Some examples:
| Desktop Edge | H264, OPUS, PCMU, PCMA | H264, H265*, AAC, FLAC*, OPUS | H264, H265*, AAC, FLAC*, OPUS, MP3 | no | | Desktop Edge | H264, OPUS, PCMU, PCMA | H264, H265*, AAC, FLAC*, OPUS | H264, H265*, AAC, FLAC*, OPUS, MP3 | no |
| Android Chrome 107+ | H264, OPUS, PCMU, PCMA | H264, H265*, AAC, FLAC*, OPUS | H264, H265*, AAC, FLAC*, OPUS, MP3 | no | | Android Chrome 107+ | H264, OPUS, PCMU, PCMA | H264, H265*, AAC, FLAC*, OPUS | H264, H265*, AAC, FLAC*, OPUS, MP3 | no |
| Desktop Firefox | H264, OPUS, PCMU, PCMA | H264, AAC, FLAC*, OPUS | H264, AAC, FLAC*, OPUS | no | | Desktop Firefox | H264, OPUS, PCMU, PCMA | H264, AAC, FLAC*, OPUS | H264, AAC, FLAC*, OPUS | no |
| Desktop Safari | H264, H265*, OPUS, PCMU, PCMA | H264, H265, AAC, FLAC* | **no!** | H264, H265, AAC, FLAC* | | Desktop Safari 14+ | H264, H265*, OPUS, PCMU, PCMA | H264, H265, AAC, FLAC* | **no!** | H264, H265, AAC, FLAC* |
| iPad Safari 13+ | H264, H265*, OPUS, PCMU, PCMA | H264, H265, AAC, FLAC* | **no!** | H264, H265, AAC, FLAC* | | iPad Safari 14+ | H264, H265*, OPUS, PCMU, PCMA | H264, H265, AAC, FLAC* | **no!** | H264, H265, AAC, FLAC* |
| iPhone Safari 13+ | H264, H265*, OPUS, PCMU, PCMA | **no!** | **no!** | H264, H265, AAC, FLAC* | | iPhone Safari 14+ | H264, H265*, OPUS, PCMU, PCMA | **no!** | **no!** | H264, H265, AAC, FLAC* |
| macOS [Hass App][1] | no | no | no | H264, H265, AAC, FLAC* | | macOS [Hass App][1] | no | no | no | H264, H265, AAC, FLAC* |
[1]: https://apps.apple.com/app/home-assistant/id1099568401 [1]: https://apps.apple.com/app/home-assistant/id1099568401
-5
View File
@@ -55,7 +55,6 @@ func ParseCodecs(codecs string, parseAudio bool) (medias []*core.Media) {
var videos []*core.Codec var videos []*core.Codec
var audios []*core.Codec var audios []*core.Codec
loop:
for _, name := range strings.Split(codecs, ",") { for _, name := range strings.Split(codecs, ",") {
switch name { switch name {
case MimeH264: case MimeH264:
@@ -67,10 +66,6 @@ loop:
case MimeAAC: case MimeAAC:
codec := &core.Codec{Name: core.CodecAAC} codec := &core.Codec{Name: core.CodecAAC}
audios = append(audios, codec) audios = append(audios, codec)
case "null":
// this means that the browser is lying about the codecs it can play
// and we are not supposed to believe that it can flac or opus
break loop
case MimeFlac: case MimeFlac:
audios = append(audios, audios = append(audios,
&core.Codec{Name: core.CodecPCMA}, &core.Codec{Name: core.CodecPCMA},
+8 -1
View File
@@ -27,7 +27,6 @@ export class VideoRTC extends HTMLElement {
'hvc1.1.6.L153.B0', // H.265 main 5.1 (Chromecast Ultra) 'hvc1.1.6.L153.B0', // H.265 main 5.1 (Chromecast Ultra)
'mp4a.40.2', // AAC LC 'mp4a.40.2', // AAC LC
'mp4a.40.5', // AAC HE 'mp4a.40.5', // AAC HE
'null', // for detecting liars (Safari iOS 12)
'flac', // FLAC (PCM compatible) 'flac', // FLAC (PCM compatible)
'opus', // OPUS Chrome, Firefox 'opus', // OPUS Chrome, Firefox
]; ];
@@ -241,6 +240,14 @@ export class VideoRTC extends HTMLElement {
this.appendChild(this.video); this.appendChild(this.video);
// all Safari lies about supported audio codecs
const m = window.navigator.userAgent.match(/Version\/(\d+).+Safari/);
if (m) {
// AAC from v13, FLAC from v14, OPUS - unsupported
const skip = m[1] < '13' ? 'mp4a.40.2' : m[1] < '14' ? 'flac' : 'opus';
this.CODECS.splice(this.CODECS.indexOf(skip));
}
if (this.background) return; if (this.background) return;
if ('hidden' in document && this.visibilityCheck) { if ('hidden' in document && this.visibilityCheck) {