werift 0.18.0 → 0.18.1

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.
@@ -1,3 +1,4 @@
1
+ import Event from "rx.mini";
1
2
  import { MediaStreamTrack } from "../../media/track";
2
3
  import { MediaWriter } from "./writer";
3
4
  export declare class MediaRecorder {
@@ -8,6 +9,7 @@ export declare class MediaRecorder {
8
9
  ext: string;
9
10
  tracks: MediaStreamTrack[];
10
11
  started: boolean;
12
+ onError: Event<[Error]>;
11
13
  constructor(path: string, numOfTracks?: number, options?: Partial<MediaRecorderOptions>);
12
14
  addTrack(track: MediaStreamTrack): Promise<void>;
13
15
  private start;
@@ -1,6 +1,10 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.MediaRecorder = void 0;
7
+ const rx_mini_1 = __importDefault(require("rx.mini"));
4
8
  const webm_1 = require("./writer/webm");
5
9
  class MediaRecorder {
6
10
  constructor(path, numOfTracks = 1, options = {}) {
@@ -46,6 +50,12 @@ class MediaRecorder {
46
50
  writable: true,
47
51
  value: false
48
52
  });
53
+ Object.defineProperty(this, "onError", {
54
+ enumerable: true,
55
+ configurable: true,
56
+ writable: true,
57
+ value: new rx_mini_1.default()
58
+ });
49
59
  this.ext = path.split(".").slice(-1)[0];
50
60
  this.writer = (() => {
51
61
  switch (this.ext) {
@@ -56,6 +66,11 @@ class MediaRecorder {
56
66
  }
57
67
  })();
58
68
  this.tracks = options.tracks ?? this.tracks;
69
+ if (this.tracks.length === numOfTracks) {
70
+ this.start().catch((error) => {
71
+ this.onError.execute(error);
72
+ });
73
+ }
59
74
  }
60
75
  async addTrack(track) {
61
76
  this.tracks.push(track);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/nonstandard/recorder/index.ts"],"names":[],"mapp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reamTrack } from \"../../media/track\";\nimport { 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\n constructor(\n public path: string,\n public numOfTracks = 1,\n public options: Partial<MediaRecorderOptions> = {}\n ) {\n this.ext = path.split(\".\").slice(-1)[0];\n this.writer = (() => {\n switch (this.ext) {\n case \"webm\":\n return new WebmFactory(path, options);\n default:\n throw new Error();\n }\n })();\n this.tracks = options.tracks ?? this.tracks;\n }\n\n async addTrack(track: MediaStreamTrack) {\n this.tracks.push(track);\n await this.start();\n }\n\n private async start() {\n if (this.tracks.length === this.numOfTracks && this.started === false) {\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}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/nonstandard/recorder/index.ts"],"names":[],"mappings":";;;;;;AAAA,sDAA4B;AAI5B,wCAA4C;AAE5C,MAAa,aAAa;IAOxB,YACS,IAAY,EACZ,cAAc,CAAC,EACf,UAAyC,EAAE;;;;;mBAF3C;;;;;;mBACA;;;;;;mBACA;;QATT;;;;;WAAoB;QACpB;;;;;WAAY;QACZ;;;;mBAA6B,EAAE;WAAC;QAChC;;;;mBAAU,KAAK;WAAC;QAChB;;;;mBAAU,IAAI,iBAAK,EAAW;WAAC;QAO7B,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACxC,IAAI,CAAC,MAAM,GAAG,CAAC,GAAG,EAAE;YAClB,QAAQ,IAAI,CAAC,GAAG,EAAE;gBAChB,KAAK,MAAM;oBACT,OAAO,IAAI,kBAAW,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;gBACxC;oBACE,MAAM,IAAI,KAAK,EAAE,CAAC;aACrB;QACH,CAAC,CAAC,EAAE,CAAC;QAEL,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,IAAI,IAAI,CAAC,MAAM,CAAC;QAC5C,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,KAAK,WAAW,EAAE;YACtC,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;SACJ;IACH,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,KAAuB;QACpC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACxB,MAAM,IAAI,CAAC,KAAK,EAAE,CAAC;IACrB,CAAC;IAEO,KAAK,CAAC,KAAK;QACjB,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,KAAK,IAAI,CAAC,WAAW,IAAI,IAAI,CAAC,OAAO,KAAK,KAAK,EAAE;YACrE,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;YACpB,MAAM,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;SACtC;IACH,CAAC;IAED,KAAK,CAAC,IAAI;QACR,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;IAC3B,CAAC;CACF;AA7CD,sCA6CC","sourcesContent":["import Event from \"rx.mini\";\n\nimport { MediaStreamTrack } from \"../../media/track\";\nimport { 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 path: string,\n public numOfTracks = 1,\n public options: Partial<MediaRecorderOptions> = {}\n ) {\n this.ext = path.split(\".\").slice(-1)[0];\n this.writer = (() => {\n switch (this.ext) {\n case \"webm\":\n return new WebmFactory(path, options);\n default:\n throw new Error();\n }\n })();\n\n this.tracks = options.tracks ?? this.tracks;\n if (this.tracks.length === 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 (this.tracks.length === this.numOfTracks && this.started === false) {\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}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "werift",
3
- "version": "0.18.0",
3
+ "version": "0.18.1",
4
4
  "description": "WebRTC Implementation for TypeScript (Node.js)",
5
5
  "keywords": [
6
6
  "WebRTC",
@@ -1,3 +1,5 @@
1
+ import Event from "rx.mini";
2
+
1
3
  import { MediaStreamTrack } from "../../media/track";
2
4
  import { MediaWriter } from "./writer";
3
5
  import { WebmFactory } from "./writer/webm";
@@ -7,6 +9,7 @@ export class MediaRecorder {
7
9
  ext: string;
8
10
  tracks: MediaStreamTrack[] = [];
9
11
  started = false;
12
+ onError = new Event<[Error]>();
10
13
 
11
14
  constructor(
12
15
  public path: string,
@@ -22,7 +25,13 @@ export class MediaRecorder {
22
25
  throw new Error();
23
26
  }
24
27
  })();
28
+
25
29
  this.tracks = options.tracks ?? this.tracks;
30
+ if (this.tracks.length === numOfTracks) {
31
+ this.start().catch((error) => {
32
+ this.onError.execute(error);
33
+ });
34
+ }
26
35
  }
27
36
 
28
37
  async addTrack(track: MediaStreamTrack) {