@jxstjh/jhvideo
Version:
HTML5 jhvideo base on MPEG2-TS Stream Player
48 lines • 2.06 kB
JavaScript
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
/**
* ResampleProcessor
*/
import PCMProcessor from './pcm-processor.js';
var AudioEncodeProcessor = /** @class */ (function (_super) {
__extends(AudioEncodeProcessor, _super);
function AudioEncodeProcessor(options) {
var _this = _super.call(this) || this;
// console.log(...arguments)
var processorOptions = options.processorOptions;
_this._processor = new PCMProcessor(processorOptions, function (samples) {
_this.port.postMessage(samples);
});
return _this;
}
AudioEncodeProcessor.prototype.process = function (inputs, outputs, parameters) {
var input = inputs[0];
if (input.length === 0)
return true;
var chunk = input[0];
if (chunk[0] === 0)
return true;
// console.log(inputs, outputs, parameters)
// 可在此将PCM原始音频数据传递给主线程进行其他操作,如写文件等。
// this.port.postMessage({ type: 'origin', inputs })
// 加工处理PCM音频数据
this._processor.input(chunk);
return true;
};
return AudioEncodeProcessor;
}(AudioWorkletProcessor));
registerProcessor('AudioEncodeProcessor', AudioEncodeProcessor);
//# sourceMappingURL=AudioEncodeProcessor.worklet.js.map