Skip to content

Commit

Permalink
check if at least 1 audio/video stream is supported
Browse files Browse the repository at this point in the history
  • Loading branch information
unclekingpin committed Oct 27, 2023
1 parent ba3e62a commit daadf79
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions src/withStreamingServer/withStreamingServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -359,17 +359,20 @@ function withStreamingServer(Video) {
var isFormatSupported = options.formats.some(function(format) {
return probe.format.name.indexOf(format) !== -1;
});
var areStreamsSupported = probe.streams.every(function(stream) {
if (stream.track === 'audio') {
return stream.channels <= options.maxAudioChannels &&
options.audioCodecs.indexOf(stream.codec) !== -1;
} else if (stream.track === 'video') {
return options.videoCodecs.indexOf(stream.codec) !== -1;
}

return true;
var videoStreams = probe.streams.filter(function(stream) {
return stream.track === 'video';
});
var areVideoStreamsSupported = videoStreams.length === 0 || videoStreams.some(function(stream) {
return options.videoCodecs.indexOf(stream.codec) !== -1;
});
var audioStreams = probe.streams.filter(function(stream) {
return stream.track === 'audio';
});
var areAudioStreamsSupported = audioStreams.length === 0 || audioStreams.some(function(stream) {
return stream.channels <= options.maxAudioChannels &&
options.audioCodecs.indexOf(stream.codec) !== -1;
});
return isFormatSupported && areStreamsSupported;
return isFormatSupported && areVideoStreamsSupported && areAudioStreamsSupported;
});
});
};
Expand Down

0 comments on commit daadf79

Please sign in to comment.