janus-simple-videoroom-client 1.0.3 → 2.0.0

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.
package/README.md CHANGED
@@ -1,8 +1,13 @@
1
1
  # janus-simple-videoroom-client
2
2
  Built on top of janus.js, this thin client library provides a simple high-level API that makes it easy to work with the Janus VideoRoom plugin.
3
3
 
4
+ ## Install
5
+ `npm install janus-simple-videoroom-client`
6
+
4
7
  ## Usage
5
8
  ```javascript
9
+ import { createVideoRoomClient } from "janus-simple-videoroom-client"
10
+
6
11
  async function joinRoom(server, roomId, displayName) {
7
12
  const client = await createVideoRoomClient()
8
13
  const session = await client.createSession(server)
@@ -45,7 +50,9 @@ Check out the [example](https://ken107.github.io/janus-videoroom-js/example.html
45
50
  | -------- | ----------- |
46
51
  | isValid() | Return whether the session is connected and valid |
47
52
  | joinRoom(_roomId_) | Joins a room, returns a VideoRoom object |
53
+ | watch(_mountpointId_, _options_) | Subscribe to a streaming mountpoint, return a StreamingSubscriber object |
48
54
  | attachToPlugin() | Attach to the VideoRoom plugin without joining a room, returns a JanusPluginHandleEx object |
55
+ | destroy() | Destroy the session |
49
56
 
50
57
  ### VideoRoom
51
58
 
@@ -62,6 +69,7 @@ Check out the [example](https://ken107.github.io/janus-videoroom-js/example.html
62
69
 
63
70
  | Property | Description |
64
71
  | -------- | ----------- |
72
+ | publisherId | |
65
73
  | onTrackAdded(_callback_) | Register a callback for when a local MediaStreamTrack is available to display |
66
74
  | onTrackRemoved(_callback_) | Register a callback for when a local MediaStreamTrack terminates |
67
75
  | configure(_options_) | Modify publisher properties |
@@ -72,6 +80,7 @@ Check out the [example](https://ken107.github.io/janus-videoroom-js/example.html
72
80
 
73
81
  | Property | Description |
74
82
  | -------- | ----------- |
83
+ | pluginHandle | The JanusPluginHandleEx object associated with this subscriber |
75
84
  | onTrackAdded(_callback_) | Register a callback for when a remote MediaStreamTrack is available to display |
76
85
  | onTrackRemoved(_callback_) | Register a callback for when a remote MediaStreamTrack terminates |
77
86
  | addStreams(_streams_) | Add additional streams to this (multi-stream) subscriber |
package/dist/index.d.ts CHANGED
@@ -1,4 +1,55 @@
1
- import { JanusMediaOptions, JanusMessage, JanusMid, JanusPluginHandle, JanusPublishOptions, JanusSessionOptions, JanusStreamSpec, JanusSubscriberConfigureOptions, JanusWatchOptions, Jsep } from "./janus";
1
+ import Janus from "janus-gateway";
2
+ export { Janus };
3
+ type JanusSessionOptions = ConstructorParameters<typeof Janus>[0];
4
+ type JanusPluginOptions = Parameters<Janus["attach"]>[0];
5
+ type JanusPluginHandle = Parameters<NonNullable<JanusPluginOptions["success"]>>[0];
6
+ type JanusMid = unknown;
7
+ type JanusOfferParams = Parameters<JanusPluginHandle["createOffer"]>[0];
8
+ type JanusTrackOption = NonNullable<JanusOfferParams["tracks"]>[number];
9
+ type Jsep = Parameters<NonNullable<JanusOfferParams["success"]>>[0];
10
+ interface JanusMessage {
11
+ [key: string]: any;
12
+ }
13
+ interface JanusMediaOptions {
14
+ tracks?: JanusTrackOption[];
15
+ trickle?: boolean;
16
+ stream?: MediaStream;
17
+ customizeSdp?: (jsep: Jsep) => void;
18
+ customizeRemoteSdp?: (jsep: Jsep) => void;
19
+ }
20
+ interface JanusStreamSpec {
21
+ feed: unknown;
22
+ mid?: JanusMid;
23
+ }
24
+ interface JanusWatchOptions {
25
+ pin?: string;
26
+ media?: string[];
27
+ }
28
+ interface JanusPublishOptions {
29
+ audiocodec?: string;
30
+ videocodec?: string;
31
+ bitrate?: number;
32
+ record?: boolean;
33
+ filename?: string;
34
+ display?: string;
35
+ audio_level_average?: number;
36
+ audio_active_packets?: number;
37
+ descriptions?: {
38
+ mid: JanusMid;
39
+ description: string;
40
+ }[];
41
+ }
42
+ interface JanusSubscriberConfigureOptions {
43
+ mid?: JanusMid;
44
+ send?: boolean;
45
+ substream?: number;
46
+ temporal?: number;
47
+ fallback?: number;
48
+ spatial_layer?: number;
49
+ temporal_layer?: number;
50
+ audio_level_average?: number;
51
+ audio_active_packets?: number;
52
+ }
2
53
  export interface VideoRoomClient {
3
54
  createSession(server: string | string[], options?: JanusSessionOptions): Promise<VideoRoomSession>;
4
55
  }
@@ -35,7 +86,7 @@ export interface VideoRoomPublisher {
35
86
  onTrackAdded(callback: (track: MediaStreamTrack) => void): void;
36
87
  onTrackRemoved(callback: (track: MediaStreamTrack) => void): void;
37
88
  configure(configureOptions: JanusPublishOptions): Promise<void>;
38
- restart(mediaOptions: JanusMediaOptions): Promise<void>;
89
+ restart(mediaOptions?: JanusMediaOptions): Promise<void>;
39
90
  unpublish(): Promise<void>;
40
91
  }
41
92
  export interface VideoRoomSubscriber {
@@ -47,7 +98,7 @@ export interface VideoRoomSubscriber {
47
98
  pause(): Promise<void>;
48
99
  resume(): Promise<void>;
49
100
  configure(configureOptions: JanusSubscriberConfigureOptions): Promise<void>;
50
- restart(mediaOptions: JanusMediaOptions): Promise<void>;
101
+ restart(mediaOptions?: JanusMediaOptions): Promise<void>;
51
102
  unsubscribe(): Promise<void>;
52
103
  }
53
104
  export interface StreamingSubscriber {
@@ -66,24 +117,27 @@ export interface StreamingSubscriber {
66
117
  }
67
118
  export interface JanusPluginHandleEx extends JanusPluginHandle {
68
119
  eventTarget: ReturnType<typeof makeEventTarget>;
69
- sendRequest(message: JanusMessage): Promise<JanusMessage>;
120
+ sendRequest(message: JanusMessage & {
121
+ request: string;
122
+ }): Promise<JanusMessage>;
70
123
  sendAsyncRequest(options: {
71
- message: JanusMessage;
124
+ message: JanusMessage & {
125
+ request: string;
126
+ };
72
127
  jsep?: Jsep;
73
128
  expectResponse: (response: AsyncResponse) => boolean;
74
129
  }): Promise<AsyncResponse>;
130
+ handleRemoteJsep(params: Parameters<JanusPluginHandle["handleRemoteJsep"]>[0] & {
131
+ customizeSdp?: (jsep: Jsep) => void;
132
+ }): void;
75
133
  }
76
134
  interface AsyncResponse {
77
135
  message: JanusMessage;
78
136
  jsep?: Jsep;
79
137
  }
80
- export declare function createVideoRoomClient(options?: {
81
- debug?: boolean | string[];
82
- dependencies?: unknown;
83
- }): Promise<VideoRoomClient>;
138
+ export declare function createVideoRoomClient(options?: Parameters<typeof Janus.init>[0]): Promise<VideoRoomClient>;
84
139
  declare function makeEventTarget(): {
85
140
  addEventListener(name: string, callback: (event: CustomEvent) => void): void;
86
141
  removeEventListener(name: string, callback: (event: CustomEvent) => void): void;
87
142
  dispatchEvent(event: Event): void;
88
143
  };
89
- export {};