mirror of
https://github.com/davedoesdev/streamana.git
synced 2025-09-27 18:12:09 +08:00
Remember force exit sending state
This commit is contained in:
@@ -191,7 +191,7 @@ async function start() {
|
|||||||
|
|
||||||
function cleanup(err) {
|
function cleanup(err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
console.error(err);
|
console.error(err.toString());
|
||||||
}
|
}
|
||||||
if (done) {
|
if (done) {
|
||||||
return;
|
return;
|
||||||
@@ -382,7 +382,7 @@ async function start() {
|
|||||||
});
|
});
|
||||||
} catch (ex) {
|
} catch (ex) {
|
||||||
console.warn(`Failed to get user media (need_audio=${need_audio} need_video=${need_video})`);
|
console.warn(`Failed to get user media (need_audio=${need_audio} need_video=${need_video})`);
|
||||||
console.error(ex);
|
console.error(ex.toString());
|
||||||
if (need_audio && need_video) {
|
if (need_audio && need_video) {
|
||||||
console.warn("Retrying with only video");
|
console.warn("Retrying with only video");
|
||||||
try {
|
try {
|
||||||
@@ -392,7 +392,7 @@ async function start() {
|
|||||||
});
|
});
|
||||||
} catch (ex) {
|
} catch (ex) {
|
||||||
console.warn('Failed to get user video, retrying with only audio');
|
console.warn('Failed to get user video, retrying with only audio');
|
||||||
console.error(ex);
|
console.error(ex.toString());
|
||||||
try {
|
try {
|
||||||
media_stream = await navigator.mediaDevices.getUserMedia({
|
media_stream = await navigator.mediaDevices.getUserMedia({
|
||||||
audio: true,
|
audio: true,
|
||||||
@@ -400,7 +400,7 @@ async function start() {
|
|||||||
});
|
});
|
||||||
} catch (ex) {
|
} catch (ex) {
|
||||||
console.warn('Failed to get user audio');
|
console.warn('Failed to get user audio');
|
||||||
console.error(ex);
|
console.error(ex.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -35,7 +35,7 @@ export class HLS extends EventTarget {
|
|||||||
await this.media_recorder('video/webm;codecs=H264');
|
await this.media_recorder('video/webm;codecs=H264');
|
||||||
console.log("Using MediaRecorder WebM/h264");
|
console.log("Using MediaRecorder WebM/h264");
|
||||||
} catch (ex) {
|
} catch (ex) {
|
||||||
console.warn(ex);
|
console.warn(ex.toString());
|
||||||
try {
|
try {
|
||||||
// next try WebCodecs - this should work on Chrome including Android
|
// next try WebCodecs - this should work on Chrome including Android
|
||||||
await this.webcodecs(video_encoder_codec,
|
await this.webcodecs(video_encoder_codec,
|
||||||
@@ -43,7 +43,7 @@ export class HLS extends EventTarget {
|
|||||||
{ avc: { format: 'annexb' } });
|
{ avc: { format: 'annexb' } });
|
||||||
console.log("Using WebCodecs");
|
console.log("Using WebCodecs");
|
||||||
} catch (ex) {
|
} catch (ex) {
|
||||||
console.warn(ex);
|
console.warn(ex.toString());
|
||||||
// finally try MP4 - this should work on Safari MacOS and iOS, producing H264
|
// finally try MP4 - this should work on Safari MacOS and iOS, producing H264
|
||||||
// this assumes ffmpeg.js has been configured with MP4 support
|
// this assumes ffmpeg.js has been configured with MP4 support
|
||||||
await this.media_recorder('video/mp4');
|
await this.media_recorder('video/mp4');
|
||||||
@@ -247,7 +247,7 @@ export class HLS extends EventTarget {
|
|||||||
video_worker.terminate();
|
video_worker.terminate();
|
||||||
audio_worker.terminate();
|
audio_worker.terminate();
|
||||||
this.stop_dummy_processor();
|
this.stop_dummy_processor();
|
||||||
if ((msg.code === 'force-end') && !this.sending) {
|
if ((msg.code === 'force-end') && this.was_not_sending) {
|
||||||
msg.code = 0;
|
msg.code = 0;
|
||||||
}
|
}
|
||||||
this.dispatchEvent(new CustomEvent(msg.type, { detail: { code: msg.code } }));
|
this.dispatchEvent(new CustomEvent(msg.type, { detail: { code: msg.code } }));
|
||||||
@@ -288,7 +288,8 @@ export class HLS extends EventTarget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
end(force) {
|
end(force) {
|
||||||
force = force || !this.sending;
|
this.was_not_sending = !this.sending;
|
||||||
|
force = force || this.was_not_sending;
|
||||||
if (force) {
|
if (force) {
|
||||||
if (this.receiver) {
|
if (this.receiver) {
|
||||||
this.receiver.end({ force });
|
this.receiver.end({ force });
|
||||||
|
Reference in New Issue
Block a user