Skip to content

Commit

Permalink
refactor: update TransformStream and ReadableStream to use arrow func…
Browse files Browse the repository at this point in the history
…tions
  • Loading branch information
Hazi7 committed Jan 21, 2025
1 parent 75225a9 commit ff8c48d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
18 changes: 8 additions & 10 deletions src/core/flv-muxer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,22 +109,20 @@ export class FlvMuxer {
}

private initTransform() {
let muxer = this;

this.transform = new TransformStream({
async start(controller) {
const header = muxer.encoder.encodeFlvHeader(
!!muxer.options.video,
!!muxer.options.audio
start: async (controller) => {
const header = this.encoder.encodeFlvHeader(
!!this.options.video,
!!this.options.audio
);
const metadata = muxer.encodeMetadata();
const metadata = this.encodeMetadata();
controller.enqueue(header);
controller.enqueue(metadata);

muxer.processor.start();
this.processor.start();
},
transform(chunk, controller) {
const tag = muxer.muxChunk(chunk);
transform: (chunk, controller) => {
const tag = this.muxChunk(chunk);
controller.enqueue(tag);
},
});
Expand Down
5 changes: 2 additions & 3 deletions src/core/media-processor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,9 @@ export class MediaProcessor {
this.readAndEncode(this.vStream.getReader(), this.vEncoder);
}

const mediaProcessor = this;
this.oStream = new ReadableStream({
start(controller) {
mediaProcessor.buffer.subscribe((data) => {
start: (controller) => {
this.buffer.subscribe((data) => {
controller.enqueue(data);
});
},
Expand Down

0 comments on commit ff8c48d

Please sign in to comment.