Remember force exit sending state

This commit is contained in:
David Halls
2021-09-30 22:25:22 +01:00
parent 5f8ce5a381
commit 40a23543ea
2 changed files with 9 additions and 8 deletions

View File

@@ -191,7 +191,7 @@ async function start() {
function cleanup(err) {
if (err) {
console.error(err);
console.error(err.toString());
}
if (done) {
return;
@@ -382,7 +382,7 @@ async function start() {
});
} catch (ex) {
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) {
console.warn("Retrying with only video");
try {
@@ -392,7 +392,7 @@ async function start() {
});
} catch (ex) {
console.warn('Failed to get user video, retrying with only audio');
console.error(ex);
console.error(ex.toString());
try {
media_stream = await navigator.mediaDevices.getUserMedia({
audio: true,
@@ -400,7 +400,7 @@ async function start() {
});
} catch (ex) {
console.warn('Failed to get user audio');
console.error(ex);
console.error(ex.toString());
}
}
}

View File

@@ -35,7 +35,7 @@ export class HLS extends EventTarget {
await this.media_recorder('video/webm;codecs=H264');
console.log("Using MediaRecorder WebM/h264");
} catch (ex) {
console.warn(ex);
console.warn(ex.toString());
try {
// next try WebCodecs - this should work on Chrome including Android
await this.webcodecs(video_encoder_codec,
@@ -43,7 +43,7 @@ export class HLS extends EventTarget {
{ avc: { format: 'annexb' } });
console.log("Using WebCodecs");
} catch (ex) {
console.warn(ex);
console.warn(ex.toString());
// finally try MP4 - this should work on Safari MacOS and iOS, producing H264
// this assumes ffmpeg.js has been configured with MP4 support
await this.media_recorder('video/mp4');
@@ -247,7 +247,7 @@ export class HLS extends EventTarget {
video_worker.terminate();
audio_worker.terminate();
this.stop_dummy_processor();
if ((msg.code === 'force-end') && !this.sending) {
if ((msg.code === 'force-end') && this.was_not_sending) {
msg.code = 0;
}
this.dispatchEvent(new CustomEvent(msg.type, { detail: { code: msg.code } }));
@@ -288,7 +288,8 @@ export class HLS extends EventTarget {
}
end(force) {
force = force || !this.sending;
this.was_not_sending = !this.sending;
force = force || this.was_not_sending;
if (force) {
if (this.receiver) {
this.receiver.end({ force });