Commit 7861d6d3 authored by NzSN's avatar NzSN

update

parent 7d3bfeb8
......@@ -352,6 +352,11 @@ class Channel {
let rEnd = this.#readPointerCache;
this.#writePointerCache = this.#getWritePointer();
let rPos = this.#readPointerCache;
if (rPos == endPos) {
rPos = this.#metaSize;
}
if (this.dataSize() < size)
return new Uint8Array(0);
......@@ -364,25 +369,24 @@ class Channel {
let rBlks = this.#getRBlks();
buffer = new Uint8Array(blksRequired * this.#blockSize);
if (this.#readPointerCache >= this.#writePointerCache) {
let spaceBetweenEnd = endPos - this.#readPointerCache;
if (rPos >= this.#writePointerCache) {
let spaceBetweenEnd = endPos - rPos;
let blks = Math.floor(spaceBetweenEnd / this.#blockSize);
if (blks >= blksRequired) {
rEnd = this.#readPointerCache + (blksRequired * this.#blockSize);
buffer.set(this.#buffer.subarray(this.#readPointerCache, rEnd));
rEnd = rPos + (blksRequired * this.#blockSize);
buffer.set(this.#buffer.subarray(rPos, rEnd));
} else {
// Read two times
rEnd = this.#metaSize + (blksRequired - blks) * this.#blockSize;
buffer.set(this.#buffer.subarray(
this.#readPointerCache, blks * this.#blockSize));
rPos, blks * this.#blockSize));
buffer.set(this.#buffer.subarray(this.#metaSize, rEnd),
blks * this.#blockSize);
}
} else if (this.#readPointerCache < this.#writePointerCache) {
rEnd = this.#readPointerCache + (blksRequired * this.#blockSize);
buffer.set(this.#buffer.subarray(
this.#readPointerCache, rEnd));
} else if (rPos < this.#writePointerCache) {
rEnd = rPos + (blksRequired * this.#blockSize);
buffer.set(this.#buffer.subarray(rPos, rEnd));
}
this.#setRBlks((rBlks+blksRequired)%Math.pow(2, 8));
......
......@@ -84,9 +84,6 @@ export class H264EncWWGroup extends WWGroup {
if ('blocksize' in options)
this.#blockSize = options.blocksize;
console.log(options);
console.log("BlockSize is :" + this.#blockSize);
if ('width' in options && 'height' in options && 'fps' in options) {
this.#width = options.width;
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