janus-simple-videoroom-client 2.0.0 → 2.1.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/dist/index.d.ts +23 -19
- package/dist/index.js +2 -4
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,21 +1,15 @@
|
|
|
1
|
-
import Janus from "janus-gateway";
|
|
1
|
+
import Janus, { JanusJS } from "janus-gateway";
|
|
2
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
3
|
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
4
|
interface JanusMessage {
|
|
11
5
|
[key: string]: any;
|
|
12
6
|
}
|
|
13
7
|
interface JanusMediaOptions {
|
|
14
|
-
tracks?:
|
|
8
|
+
tracks?: JanusJS.TrackOption[];
|
|
15
9
|
trickle?: boolean;
|
|
16
10
|
stream?: MediaStream;
|
|
17
|
-
customizeSdp?: (jsep:
|
|
18
|
-
customizeRemoteSdp?: (jsep:
|
|
11
|
+
customizeSdp?: (jsep: JanusJS.JSEP) => void;
|
|
12
|
+
customizeRemoteSdp?: (jsep: JanusJS.JSEP) => void;
|
|
19
13
|
}
|
|
20
14
|
interface JanusStreamSpec {
|
|
21
15
|
feed: unknown;
|
|
@@ -39,6 +33,16 @@ interface JanusPublishOptions {
|
|
|
39
33
|
description: string;
|
|
40
34
|
}[];
|
|
41
35
|
}
|
|
36
|
+
interface JanusPublisherConfigureOptions extends JanusPublishOptions {
|
|
37
|
+
keyframe?: boolean;
|
|
38
|
+
streams?: Array<{
|
|
39
|
+
mid: JanusMid;
|
|
40
|
+
keyframe?: boolean;
|
|
41
|
+
send?: boolean;
|
|
42
|
+
min_delay?: number;
|
|
43
|
+
max_delay?: number;
|
|
44
|
+
}>;
|
|
45
|
+
}
|
|
42
46
|
interface JanusSubscriberConfigureOptions {
|
|
43
47
|
mid?: JanusMid;
|
|
44
48
|
send?: boolean;
|
|
@@ -51,7 +55,7 @@ interface JanusSubscriberConfigureOptions {
|
|
|
51
55
|
audio_active_packets?: number;
|
|
52
56
|
}
|
|
53
57
|
export interface VideoRoomClient {
|
|
54
|
-
createSession(server: string | string[], options?:
|
|
58
|
+
createSession(server: string | string[], options?: Partial<JanusJS.ConstructorOptions>): Promise<VideoRoomSession>;
|
|
55
59
|
}
|
|
56
60
|
export interface VideoRoomSession {
|
|
57
61
|
eventTarget: ReturnType<typeof makeEventTarget>;
|
|
@@ -85,8 +89,8 @@ export interface VideoRoomPublisher {
|
|
|
85
89
|
publisherId: string | number;
|
|
86
90
|
onTrackAdded(callback: (track: MediaStreamTrack) => void): void;
|
|
87
91
|
onTrackRemoved(callback: (track: MediaStreamTrack) => void): void;
|
|
88
|
-
configure(configureOptions:
|
|
89
|
-
restart(mediaOptions?: JanusMediaOptions): Promise<void>;
|
|
92
|
+
configure(configureOptions: JanusPublisherConfigureOptions): Promise<void>;
|
|
93
|
+
restart(mediaOptions?: JanusMediaOptions, publishOptions?: JanusPublishOptions): Promise<void>;
|
|
90
94
|
unpublish(): Promise<void>;
|
|
91
95
|
}
|
|
92
96
|
export interface VideoRoomSubscriber {
|
|
@@ -115,7 +119,7 @@ export interface StreamingSubscriber {
|
|
|
115
119
|
}): Promise<void>;
|
|
116
120
|
unsubscribe(): Promise<void>;
|
|
117
121
|
}
|
|
118
|
-
export interface JanusPluginHandleEx extends
|
|
122
|
+
export interface JanusPluginHandleEx extends JanusJS.PluginHandle {
|
|
119
123
|
eventTarget: ReturnType<typeof makeEventTarget>;
|
|
120
124
|
sendRequest(message: JanusMessage & {
|
|
121
125
|
request: string;
|
|
@@ -124,18 +128,18 @@ export interface JanusPluginHandleEx extends JanusPluginHandle {
|
|
|
124
128
|
message: JanusMessage & {
|
|
125
129
|
request: string;
|
|
126
130
|
};
|
|
127
|
-
jsep?:
|
|
131
|
+
jsep?: JanusJS.JSEP;
|
|
128
132
|
expectResponse: (response: AsyncResponse) => boolean;
|
|
129
133
|
}): Promise<AsyncResponse>;
|
|
130
|
-
handleRemoteJsep(params:
|
|
131
|
-
customizeSdp?: (jsep:
|
|
134
|
+
handleRemoteJsep(params: JanusJS.PluginHandleRemoteJsepParam & {
|
|
135
|
+
customizeSdp?: (jsep: JanusJS.JSEP) => void;
|
|
132
136
|
}): void;
|
|
133
137
|
}
|
|
134
138
|
interface AsyncResponse {
|
|
135
139
|
message: JanusMessage;
|
|
136
|
-
jsep?:
|
|
140
|
+
jsep?: JanusJS.JSEP;
|
|
137
141
|
}
|
|
138
|
-
export declare function createVideoRoomClient(options?:
|
|
142
|
+
export declare function createVideoRoomClient(options?: JanusJS.InitOptions): Promise<VideoRoomClient>;
|
|
139
143
|
declare function makeEventTarget(): {
|
|
140
144
|
addEventListener(name: string, callback: (event: CustomEvent) => void): void;
|
|
141
145
|
removeEventListener(name: string, callback: (event: CustomEvent) => void): void;
|
package/dist/index.js
CHANGED
|
@@ -344,15 +344,13 @@ function createVideoRoomPublisher(handle, publisherId, opts) {
|
|
|
344
344
|
});
|
|
345
345
|
});
|
|
346
346
|
},
|
|
347
|
-
restart(mediaOptions = options.mediaOptions) {
|
|
347
|
+
restart(mediaOptions = options.mediaOptions, publishOptions) {
|
|
348
348
|
return __awaiter(this, void 0, void 0, function* () {
|
|
349
349
|
const offerJsep = yield new Promise(function (fulfill, reject) {
|
|
350
350
|
handle.createOffer(Object.assign(Object.assign({}, mediaOptions), { success: fulfill, error: reject }));
|
|
351
351
|
});
|
|
352
352
|
const response = yield handle.sendAsyncRequest({
|
|
353
|
-
message: {
|
|
354
|
-
request: "configure",
|
|
355
|
-
},
|
|
353
|
+
message: Object.assign(Object.assign({}, publishOptions), { request: "configure" }),
|
|
356
354
|
jsep: offerJsep,
|
|
357
355
|
expectResponse: r => r.message.videoroom == "event" && r.message.configured == "ok"
|
|
358
356
|
});
|
package/package.json
CHANGED