gram-tgcalls
Advanced tools
Comparing version 2.1.4 to 2.1.5
@@ -53,3 +53,3 @@ "use strict"; | ||
async stream(audio, video, params) { | ||
var _a, _b, _c, _d; | ||
var _a, _b, _c, _d, _e, _f; | ||
if (!(audio === null || audio === void 0 ? void 0 : audio.readable) && !(video === null || video === void 0 ? void 0 : video.readable)) { | ||
@@ -75,20 +75,26 @@ throw new Error('Provide a readable at least'); | ||
this.audioStream = new tgcalls_1.Stream(audio === null || audio === void 0 ? void 0 : audio.readable, { | ||
audio: { ...audio === null || audio === void 0 ? void 0 : audio.options }, | ||
audio: { ...audio === null || audio === void 0 ? void 0 : audio.params }, | ||
}); | ||
this.audioTrack = this.audioStream.createTrack(); | ||
if ((_a = audio === null || audio === void 0 ? void 0 : audio.options) === null || _a === void 0 ? void 0 : _a.onFinish) { | ||
this.audioStream.addListener('finish', audio.options.onFinish); | ||
if ((_a = audio === null || audio === void 0 ? void 0 : audio.listeners) === null || _a === void 0 ? void 0 : _a.onError) { | ||
this.audioStream.on('error', audio.listeners.onError); | ||
} | ||
if ((_b = audio === null || audio === void 0 ? void 0 : audio.listeners) === null || _b === void 0 ? void 0 : _b.onFinish) { | ||
this.audioStream.on('finish', audio.listeners.onFinish); | ||
} | ||
this.videoStream = new tgcalls_1.Stream(video === null || video === void 0 ? void 0 : video.readable, { | ||
video: { ...video === null || video === void 0 ? void 0 : video.options }, | ||
video: { ...video === null || video === void 0 ? void 0 : video.params }, | ||
}); | ||
this.videoTrack = this.videoStream.createTrack(); | ||
if ((_b = video === null || video === void 0 ? void 0 : video.options) === null || _b === void 0 ? void 0 : _b.onFinish) { | ||
this.videoStream.addListener('finish', video.options.onFinish); | ||
if ((_c = video === null || video === void 0 ? void 0 : video.listeners) === null || _c === void 0 ? void 0 : _c.onError) { | ||
this.videoStream.on('error', video.listeners.onError); | ||
} | ||
if ((_d = video === null || video === void 0 ? void 0 : video.listeners) === null || _d === void 0 ? void 0 : _d.onFinish) { | ||
this.videoStream.on('finish', video.listeners.onFinish); | ||
} | ||
} | ||
else { | ||
(_c = this.audioStream) === null || _c === void 0 ? void 0 : _c.setReadable(audio === null || audio === void 0 ? void 0 : audio.readable); | ||
(_e = this.audioStream) === null || _e === void 0 ? void 0 : _e.setReadable(audio === null || audio === void 0 ? void 0 : audio.readable); | ||
if (video === null || video === void 0 ? void 0 : video.readable) { | ||
(_d = this.videoStream) === null || _d === void 0 ? void 0 : _d.setReadable(video.readable); | ||
(_f = this.videoStream) === null || _f === void 0 ? void 0 : _f.setReadable(video.readable); | ||
} | ||
@@ -95,0 +101,0 @@ return; |
@@ -20,6 +20,10 @@ /// <reference types="node" /> | ||
} | ||
export interface Listeners { | ||
onFinish?: () => void; | ||
onError?: (error: Error) => void; | ||
} | ||
export interface Video { | ||
readable?: Readable; | ||
options?: { | ||
onFinish?: () => void; | ||
listeners: Listeners; | ||
params?: { | ||
width?: number; | ||
@@ -32,4 +36,4 @@ height?: number; | ||
readable?: Readable; | ||
options?: { | ||
onFinish?: () => void; | ||
listeners: Listeners; | ||
params?: { | ||
bitsPerSample?: number; | ||
@@ -36,0 +40,0 @@ sampleRate?: number; |
{ | ||
"name": "gram-tgcalls", | ||
"version": "2.1.4", | ||
"version": "2.1.5", | ||
"main": "lib/index.js", | ||
@@ -5,0 +5,0 @@ "scripts": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
26575
478