Skip to content

Commit fe838ee

Browse files
committed
Fix change id
1 parent 5220963 commit fe838ee

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

src/avsrouter.js

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1428,14 +1428,15 @@ export class AVSrouter {
14281428
}
14291429
}
14301430
if (
1431-
(nextqual || newid) &&
1432-
quality === (nextqual || curqual) &&
1431+
(typeof nextqual !== 'undefined' || typeof newid !== 'undefined') &&
1432+
(quality === (nextqual || curqual) ||
1433+
(nextqual || curqual) === -1) &&
14331434
(pid === (newid || curid) || newid === 'sleep') &&
14341435
((chunk.paketstart && chunk.keyframe) || qualchangeStor.length > 0)
14351436
) {
14361437
if (!inpaket) {
14371438
// we can change
1438-
if (nextqual) {
1439+
if (typeof nextqual !== 'undefined') {
14391440
curqual = nextqual
14401441
nextqual = undefined
14411442
if (!newid) {
@@ -1447,7 +1448,7 @@ export class AVSrouter {
14471448
}
14481449
}
14491450
}
1450-
if (newid) {
1451+
if (typeof newid !== 'undefined') {
14511452
slog('change id unregister stream peek', newid, curid)
14521453
if (curid && curid !== 'sleep')
14531454
this.unregisterStream(curid, type, writeChunk)
@@ -1460,6 +1461,8 @@ export class AVSrouter {
14601461
increaseQual = this.getIncreaseQual(newid, type)
14611462
decreaseQual = this.getDecreaseQual(newid, type)
14621463
curid = newid
1464+
curqual = fixQuality(curqual) // we may need to fix it...., if it is -1 or unavaliable
1465+
slog('cur quality after change id:', curqual)
14631466
newid = undefined
14641467
}
14651468
try {
@@ -1683,6 +1686,14 @@ export class AVSrouter {
16831686
newid = messid
16841687
const checkqual = fixQuality(curqual)
16851688
if (checkqual !== curqual) nextqual = checkqual
1689+
slog(
1690+
'registerStream in change',
1691+
newid,
1692+
type,
1693+
nextqual,
1694+
curqual,
1695+
checkqual
1696+
)
16861697

16871698
this.registerStream(newid, type, writeChunk)
16881699
} else {

0 commit comments

Comments
 (0)