Commit ebfae502 authored by NzSN's avatar NzSN

Redo ParaEncoder and EncGroup.

parent 9d20a86f
import { makeMsg, MESSAGE_TYPE, typeOfMsg } from './encGrooupMsg';
import { Observable, filter } from './rxjs';
import { Observable, filter } from 'rxjs';
export class WWInitError extends Error {
......
......@@ -77,6 +77,8 @@ export class H264EncWWGroup extends WWGroup {
this.#numOfWorkers = numOfWW;
this.#numOfEncWorker = this.#numOfWorkers - 1;
console.log(this.#numOfEncWorker);
}
// H264EncWWGroup has two types of workers:
......
......@@ -16,11 +16,12 @@ export class ParaEncoder {
#mode = undefined
#grp = null;
#options
constructor(numOfWW, codec, mode) {
constructor(numOfWW, options) {
if (typeof(numOfWW) != 'number' ||
!(codec in ENC_GRPS) ||
!isInObj(ENCODE_MODE, mode)) {
(!('codec' in options) || !(options['codec'] in ENC_GRPS)) ||
!('config' in options)) {
throw new TypeError(
"Mismatch types parameter", "paraEncode.js");
......@@ -28,12 +29,12 @@ export class ParaEncoder {
this.#numOfWW = numOfWW;
this.#codec = codec;
this.#mode = mode;
this.#codec = options.codec;
this.#options = options;
}
async init() {
this.#grp = new ENC_GRPS[codec]("ENCs", {});
this.#grp = new ENC_GRPS[this.#codec]("ENCs", this.#numOfWW, this.#options.config);
await this.#grp.start();
}
......@@ -56,15 +57,15 @@ export class ParaEncoder {
* pixels can be null which means there are no more frames to encode,
* after that encoder will rejected any pixels.
* */
encode(pixels) {
NEED_TO_IMPLEMENT();
async encode(pixels) {
await this.#grp.dispatch(pixels);
}
/* Does all frames provide to Encoder be encoded.
*
* Note: isDone() alwasy return false before eof. */
isDone() {
NEED_TO_IMPLEMENT();
return this.#grp.isDone();
}
}
......@@ -7,7 +7,7 @@ const RGBAFrameSize = 1920*1080*4;
beforeEach(async () => {
paraEnc = new ParaEncoder(11, {
codec: "H264",
grpcfg: {
config: {
encchnlsize: RGBAFrameSize * 10,
bridgechnlsize: Math.pow(2, 25),
}
......
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