Commit 7861d6d3 authored by NzSN's avatar NzSN

update

parent 7d3bfeb8
...@@ -352,6 +352,11 @@ class Channel { ...@@ -352,6 +352,11 @@ class Channel {
let rEnd = this.#readPointerCache; let rEnd = this.#readPointerCache;
this.#writePointerCache = this.#getWritePointer(); this.#writePointerCache = this.#getWritePointer();
let rPos = this.#readPointerCache;
if (rPos == endPos) {
rPos = this.#metaSize;
}
if (this.dataSize() < size) if (this.dataSize() < size)
return new Uint8Array(0); return new Uint8Array(0);
...@@ -364,25 +369,24 @@ class Channel { ...@@ -364,25 +369,24 @@ class Channel {
let rBlks = this.#getRBlks(); let rBlks = this.#getRBlks();
buffer = new Uint8Array(blksRequired * this.#blockSize); buffer = new Uint8Array(blksRequired * this.#blockSize);
if (this.#readPointerCache >= this.#writePointerCache) { if (rPos >= this.#writePointerCache) {
let spaceBetweenEnd = endPos - this.#readPointerCache; let spaceBetweenEnd = endPos - rPos;
let blks = Math.floor(spaceBetweenEnd / this.#blockSize); let blks = Math.floor(spaceBetweenEnd / this.#blockSize);
if (blks >= blksRequired) { if (blks >= blksRequired) {
rEnd = this.#readPointerCache + (blksRequired * this.#blockSize); rEnd = rPos + (blksRequired * this.#blockSize);
buffer.set(this.#buffer.subarray(this.#readPointerCache, rEnd)); buffer.set(this.#buffer.subarray(rPos, rEnd));
} else { } else {
// Read two times // Read two times
rEnd = this.#metaSize + (blksRequired - blks) * this.#blockSize; rEnd = this.#metaSize + (blksRequired - blks) * this.#blockSize;
buffer.set(this.#buffer.subarray( buffer.set(this.#buffer.subarray(
this.#readPointerCache, blks * this.#blockSize)); rPos, blks * this.#blockSize));
buffer.set(this.#buffer.subarray(this.#metaSize, rEnd), buffer.set(this.#buffer.subarray(this.#metaSize, rEnd),
blks * this.#blockSize); blks * this.#blockSize);
} }
} else if (this.#readPointerCache < this.#writePointerCache) { } else if (rPos < this.#writePointerCache) {
rEnd = this.#readPointerCache + (blksRequired * this.#blockSize); rEnd = rPos + (blksRequired * this.#blockSize);
buffer.set(this.#buffer.subarray( buffer.set(this.#buffer.subarray(rPos, rEnd));
this.#readPointerCache, rEnd));
} }
this.#setRBlks((rBlks+blksRequired)%Math.pow(2, 8)); this.#setRBlks((rBlks+blksRequired)%Math.pow(2, 8));
......
...@@ -84,9 +84,6 @@ export class H264EncWWGroup extends WWGroup { ...@@ -84,9 +84,6 @@ export class H264EncWWGroup extends WWGroup {
if ('blocksize' in options) if ('blocksize' in options)
this.#blockSize = options.blocksize; this.#blockSize = options.blocksize;
console.log(options);
console.log("BlockSize is :" + this.#blockSize);
if ('width' in options && 'height' in options && 'fps' in options) { if ('width' in options && 'height' in options && 'fps' in options) {
this.#width = options.width; this.#width = options.width;
this.#height = options.height; this.#height = options.height;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment