Commit ebfae502 authored by NzSN's avatar NzSN

Redo ParaEncoder and EncGroup.

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