rebroadcast: add video detection

This commit is contained in:
Koushik Dutta
2022-03-25 22:51:44 -07:00
parent d68b622042
commit 8ebfa2a9c2
3 changed files with 23 additions and 12 deletions

View File

@@ -1,12 +1,12 @@
{
"name": "@scrypted/prebuffer-mixin",
"version": "0.1.212",
"version": "0.1.213",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "@scrypted/prebuffer-mixin",
"version": "0.1.212",
"version": "0.1.213",
"license": "Apache-2.0",
"dependencies": {
"@scrypted/common": "file:../../common",

View File

@@ -1,6 +1,6 @@
{
"name": "@scrypted/prebuffer-mixin",
"version": "0.1.212",
"version": "0.1.213",
"description": "Rebroadcast and Prebuffer for VideoCameras.",
"author": "Scrypted",
"license": "Apache-2.0",

View File

@@ -427,13 +427,6 @@ class PrebufferSession {
probingAudioCodec = true;
}
// complain to the user about the codec if necessary. upstream may send a audio
// stream but report none exists (to request muting).
if (!audioSoftMuted && advertisedAudioCodec && detectedAudioCodec !== undefined
&& detectedAudioCodec !== advertisedAudioCodec) {
this.console.warn('Audio codec plugin reported vs detected mismatch', advertisedAudioCodec, detectedAudioCodec);
}
// the assumed audio codec is the detected codec first and the reported codec otherwise.
const assumedAudioCodec = detectedAudioCodec === undefined
? advertisedAudioCodec?.toLowerCase()
@@ -689,6 +682,19 @@ class PrebufferSession {
.catch(() => { });
}
// complain to the user about the codec if necessary. upstream may send a audio
// stream but report none exists (to request muting).
if (!audioSoftMuted && advertisedAudioCodec && session.inputAudioCodec !== undefined
&& session.inputAudioCodec !== advertisedAudioCodec) {
this.console.warn('Audio codec plugin reported vs detected mismatch', advertisedAudioCodec, detectedAudioCodec);
}
const advertisedVideoCodec = mso?.video?.codec;
if (advertisedVideoCodec && session.inputVideoCodec !== undefined
&& session.inputVideoCodec !== advertisedVideoCodec) {
this.console.warn('Video codec plugin reported vs detected mismatch', advertisedVideoCodec, session.inputVideoCodec);
}
if (!session.inputAudioCodec) {
this.console.log('No audio stream detected.');
}
@@ -1001,11 +1007,16 @@ class PrebufferSession {
}
}
if (mediaStreamOptions.video && session.inputVideoResolution?.[2] && session.inputVideoResolution?.[3]) {
if (!mediaStreamOptions.video)
mediaStreamOptions.video = {};
mediaStreamOptions.video.codec = session.inputVideoCodec;
if (session.inputVideoResolution?.[2] && session.inputVideoResolution?.[3]) {
Object.assign(mediaStreamOptions.video, {
width: parseInt(session.inputVideoResolution[2]),
height: parseInt(session.inputVideoResolution[3]),
})
});
}
const now = Date.now();