werift 0.19.5 → 0.19.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -45,11 +45,6 @@ class MediaRecorder {
45
45
  value: new rx_mini_1.default()
46
46
  });
47
47
  this.tracks = props.tracks ?? this.tracks;
48
- if (this.tracks.length === props.numOfTracks) {
49
- this.start().catch((error) => {
50
- this.onError.execute(error);
51
- });
52
- }
53
48
  const { path, stream } = props;
54
49
  if (path) {
55
50
  this.ext = path.split(".").slice(-1)[0];
@@ -73,6 +68,11 @@ class MediaRecorder {
73
68
  stream: stream,
74
69
  });
75
70
  }
71
+ if (this.tracks.length === props.numOfTracks) {
72
+ this.start().catch((error) => {
73
+ this.onError.execute(error);
74
+ });
75
+ }
76
76
  }
77
77
  async addTrack(track) {
78
78
  this.tracks.push(track);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/nonstandard/recorder/index.ts"],"names":[],"mappings":";;;;;;AAAA,sDAA4B;AAK5B,wCAA4C;AAE5C,MAAa,aAAa;IAOxB,YACS,KAWJ;QAXH;;;;mBAAO,KAAK;WAWT;QAlBL;;;;;WAAoB;QACpB;;;;;WAAa;QACb;;;;mBAA6B,EAAE;WAAC;QAChC;;;;mBAAU,KAAK;WAAC;QAChB;;;;mBAAU,IAAI,iBAAK,EAAW;WAAC;QAgB7B,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC,MAAM,IAAI,IAAI,CAAC,MAAM,CAAC;QAC1C,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,KAAK,KAAK,CAAC,WAAW,EAAE,CAAC;YAC7C,IAAI,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;gBAC3B,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;YAC9B,CAAC,CAAC,CAAC;QACL,CAAC;QAED,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,G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from \"rx.mini\";\n\nimport type { PassThrough } from \"stream\";\nimport type { MediaStreamTrack } from \"../../media/track\";\nimport type { MediaWriter } from \"./writer\";\nimport { WebmFactory } from \"./writer/webm\";\n\nexport class MediaRecorder {\n writer: MediaWriter;\n ext?: string;\n tracks: MediaStreamTrack[] = [];\n started = false;\n onError = new Event<[Error]>();\n\n constructor(\n public props: Partial<MediaRecorderOptions> & {\n numOfTracks: number;\n } & (\n | {\n path: string;\n stream?: PassThrough;\n }\n | {\n path?: string;\n stream: PassThrough;\n }\n ),\n ) {\n this.tracks = props.tracks ?? this.tracks;\n if (this.tracks.length === props.numOfTracks) {\n this.start().catch((error) => {\n this.onError.execute(error);\n });\n }\n\n const { path, stream } = props;\n\n if (path) {\n this.ext = path.split(\".\").slice(-1)[0];\n this.writer = (() => {\n switch (this.ext) {\n case \"webm\":\n return new WebmFactory({\n ...props,\n path: path!,\n stream: stream!,\n });\n default:\n throw new Error();\n }\n })();\n } else {\n this.writer = new WebmFactory({\n ...props,\n path: path!,\n stream: stream!,\n });\n }\n }\n\n async addTrack(track: MediaStreamTrack) {\n this.tracks.push(track);\n await this.start();\n }\n\n private async start() {\n if (\n this.tracks.length === this.props.numOfTracks &&\n this.started === false\n ) {\n this.started = true;\n await this.writer.start(this.tracks);\n }\n }\n\n async stop() {\n await this.writer.stop();\n }\n}\n\nexport interface MediaRecorderOptions {\n width: number;\n height: number;\n jitterBufferLatency: number;\n jitterBufferSize: number;\n waitForKeyframe: boolean;\n defaultDuration: number;\n tracks: MediaStreamTrack[];\n disableNtp: boolean;\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/nonstandard/recorder/index.ts"],"names":[],"mappings":";;;;;;AAAA,sDAA4B;AAK5B,wCAA4C;AAE5C,MAAa,aAAa;IAOxB,YACS,KAWJ;QAXH;;;;mBAAO,KAAK;WAWT;QAlBL;;;;;WAAoB;QACpB;;;;;WAAa;QACb;;;;mBAA6B,EAAE;WAAC;QAChC;;;;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AE,CAAC;IACrB,CAAC;IAEO,KAAK,CAAC,KAAK;QACjB,IACE,IAAI,CAAC,MAAM,CAAC,MAAM,KAAK,IAAI,CAAC,KAAK,CAAC,WAAW;YAC7C,IAAI,CAAC,OAAO,KAAK,KAAK,EACtB,CAAC;YACD,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;YACpB,MAAM,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACvC,CAAC;IACH,CAAC;IAED,KAAK,CAAC,IAAI;QACR,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;IAC3B,CAAC;CACF;AAxED,sCAwEC","sourcesContent":["import Event from \"rx.mini\";\n\nimport type { PassThrough } from \"stream\";\nimport type { MediaStreamTrack } from \"../../media/track\";\nimport type { MediaWriter } from \"./writer\";\nimport { WebmFactory } from \"./writer/webm\";\n\nexport class MediaRecorder {\n writer: MediaWriter;\n ext?: string;\n tracks: MediaStreamTrack[] = [];\n started = false;\n onError = new Event<[Error]>();\n\n constructor(\n public props: Partial<MediaRecorderOptions> & {\n numOfTracks: number;\n } & (\n | {\n path: string;\n stream?: PassThrough;\n }\n | {\n path?: string;\n stream: PassThrough;\n }\n ),\n ) {\n this.tracks = props.tracks ?? this.tracks;\n\n const { path, stream } = props;\n\n if (path) {\n this.ext = path.split(\".\").slice(-1)[0];\n this.writer = (() => {\n switch (this.ext) {\n case \"webm\":\n return new WebmFactory({\n ...props,\n path: path!,\n stream: stream!,\n });\n default:\n throw new Error();\n }\n })();\n } else {\n this.writer = new WebmFactory({\n ...props,\n path: path!,\n stream: stream!,\n });\n }\n\n if (this.tracks.length === props.numOfTracks) {\n this.start().catch((error) => {\n this.onError.execute(error);\n });\n }\n }\n\n async addTrack(track: MediaStreamTrack) {\n this.tracks.push(track);\n await this.start();\n }\n\n private async start() {\n if (\n this.tracks.length === this.props.numOfTracks &&\n this.started === false\n ) {\n this.started = true;\n await this.writer.start(this.tracks);\n }\n }\n\n async stop() {\n await this.writer.stop();\n }\n}\n\nexport interface MediaRecorderOptions {\n width: number;\n height: number;\n jitterBufferLatency: number;\n jitterBufferSize: number;\n waitForKeyframe: boolean;\n defaultDuration: number;\n tracks: MediaStreamTrack[];\n disableNtp: boolean;\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "werift",
3
- "version": "0.19.5",
3
+ "version": "0.19.6",
4
4
  "description": "WebRTC Implementation for TypeScript (Node.js)",
5
5
  "keywords": [
6
6
  "WebRTC",
@@ -27,11 +27,6 @@ export class MediaRecorder {
27
27
  ),
28
28
  ) {
29
29
  this.tracks = props.tracks ?? this.tracks;
30
- if (this.tracks.length === props.numOfTracks) {
31
- this.start().catch((error) => {
32
- this.onError.execute(error);
33
- });
34
- }
35
30
 
36
31
  const { path, stream } = props;
37
32
 
@@ -56,6 +51,12 @@ export class MediaRecorder {
56
51
  stream: stream!,
57
52
  });
58
53
  }
54
+
55
+ if (this.tracks.length === props.numOfTracks) {
56
+ this.start().catch((error) => {
57
+ this.onError.execute(error);
58
+ });
59
+ }
59
60
  }
60
61
 
61
62
  async addTrack(track: MediaStreamTrack) {