Code refactoring for #1644
This commit is contained in:
+6
-22
@@ -580,13 +580,14 @@ export class VideoRTC extends HTMLElement {
|
|||||||
|
|
||||||
/** @type {MediaStream} */
|
/** @type {MediaStream} */
|
||||||
const stream = video2.srcObject;
|
const stream = video2.srcObject;
|
||||||
if (stream.getVideoTracks().length > 0) rtcPriority += 0x220;
|
if (stream.getVideoTracks().length > 0) {
|
||||||
|
// not the best, but a pretty simple way to check a codec
|
||||||
|
const isH265Supported = this.pc.remoteDescription.sdp.includes('H265/90000');
|
||||||
|
rtcPriority += isH265Supported ? 0x240 : 0x220;
|
||||||
|
}
|
||||||
if (stream.getAudioTracks().length > 0) rtcPriority += 0x102;
|
if (stream.getAudioTracks().length > 0) rtcPriority += 0x102;
|
||||||
|
|
||||||
if (this.mseCodecs.indexOf('hvc1.')) {
|
if (this.mseCodecs.indexOf('hvc1.') >= 0) msePriority += 0x230;
|
||||||
if (VideoRTC.isH265Supported()) rtcPriority += 0x230;
|
|
||||||
else msePriority += 0x230;
|
|
||||||
}
|
|
||||||
if (this.mseCodecs.indexOf('avc1.') >= 0) msePriority += 0x210;
|
if (this.mseCodecs.indexOf('avc1.') >= 0) msePriority += 0x210;
|
||||||
if (this.mseCodecs.indexOf('mp4a.') >= 0) msePriority += 0x101;
|
if (this.mseCodecs.indexOf('mp4a.') >= 0) msePriority += 0x101;
|
||||||
|
|
||||||
@@ -667,23 +668,6 @@ export class VideoRTC extends HTMLElement {
|
|||||||
this.send({type: 'mp4', value: this.codecs(this.video.canPlayType)});
|
this.send({type: 'mp4', value: this.codecs(this.video.canPlayType)});
|
||||||
}
|
}
|
||||||
|
|
||||||
static isH265Supported() {
|
|
||||||
try {
|
|
||||||
const videoCodecs = RTCRtpSender?.getCapabilities('video')?.codecs;
|
|
||||||
|
|
||||||
if (!videoCodecs) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return videoCodecs.some(codec =>
|
|
||||||
codec.mimeType.toLowerCase().includes('h265') ||
|
|
||||||
codec.mimeType.toLowerCase().includes('hevc')
|
|
||||||
);
|
|
||||||
} catch {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static btoa(buffer) {
|
static btoa(buffer) {
|
||||||
const bytes = new Uint8Array(buffer);
|
const bytes = new Uint8Array(buffer);
|
||||||
const len = bytes.byteLength;
|
const len = bytes.byteLength;
|
||||||
|
|||||||
Reference in New Issue
Block a user