@tribe-nest/media-client 0.1.1 → 0.4.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/build/core/index.d.ts +1 -1
- package/build/core/index.d.ts.map +1 -1
- package/build/core/index.js.map +1 -1
- package/build/core/reconnect.d.ts +29 -0
- package/build/core/reconnect.d.ts.map +1 -1
- package/build/core/reconnect.js +49 -9
- package/build/core/reconnect.js.map +1 -1
- package/build/core/signal.d.ts +9 -0
- package/build/core/signal.d.ts.map +1 -1
- package/build/core/signal.js +18 -2
- package/build/core/signal.js.map +1 -1
- package/build/core/state.d.ts +31 -0
- package/build/core/state.d.ts.map +1 -1
- package/build/core/state.js +113 -8
- package/build/core/state.js.map +1 -1
- package/build/index.d.ts +1 -1
- package/build/index.d.ts.map +1 -1
- package/build/index.js.map +1 -1
- package/build/react/index.d.ts +78 -16
- package/build/react/index.d.ts.map +1 -1
- package/build/react/index.js +289 -12
- package/build/react/index.js.map +1 -1
- package/build/room/browserDevice.d.ts.map +1 -1
- package/build/room/browserDevice.js +13 -4
- package/build/room/browserDevice.js.map +1 -1
- package/build/room/device.d.ts +19 -0
- package/build/room/device.d.ts.map +1 -1
- package/build/room/room.d.ts +298 -3
- package/build/room/room.d.ts.map +1 -1
- package/build/room/room.js +742 -24
- package/build/room/room.js.map +1 -1
- package/package.json +2 -2
- package/src/core/_tests/reconnect.spec.ts +92 -0
- package/src/core/_tests/state.spec.ts +138 -0
- package/src/core/index.ts +2 -0
- package/src/core/reconnect.ts +76 -9
- package/src/core/signal.ts +16 -2
- package/src/core/state.ts +163 -11
- package/src/index.ts +2 -0
- package/src/react/index.tsx +323 -19
- package/src/room/_tests/room.spec.ts +954 -4
- package/src/room/browserDevice.ts +14 -4
- package/src/room/device.ts +19 -0
- package/src/room/room.ts +913 -26
|
@@ -27,14 +27,24 @@ import type {
|
|
|
27
27
|
* place.
|
|
28
28
|
*/
|
|
29
29
|
|
|
30
|
-
const
|
|
30
|
+
const CODEC_MIME: Record<"h264" | "vp8", string> = { h264: "video/h264", vp8: "video/vp8" };
|
|
31
|
+
|
|
32
|
+
const adapt = (transport: Transport, device: Device): MediaTransport => ({
|
|
31
33
|
id: transport.id,
|
|
32
34
|
|
|
33
|
-
async produce({ track, appData, encodings }) {
|
|
35
|
+
async produce({ track, appData, encodings, codec }) {
|
|
36
|
+
// The router's own entry for the codec, which is what mediasoup-client
|
|
37
|
+
// wants rather than a name. Missing means the router does not offer it
|
|
38
|
+
// and the default applies, which the caller can see from the producer.
|
|
39
|
+
const wanted = codec ? CODEC_MIME[codec] : undefined;
|
|
40
|
+
const capability = wanted
|
|
41
|
+
? device.rtpCapabilities.codecs?.find((c) => c.mimeType.toLowerCase() === wanted)
|
|
42
|
+
: undefined;
|
|
34
43
|
const producer = await transport.produce({
|
|
35
44
|
track,
|
|
36
45
|
...(encodings ? { encodings: encodings as never } : {}),
|
|
37
46
|
...(appData ? { appData } : {}),
|
|
47
|
+
...(capability ? { codec: capability } : {}),
|
|
38
48
|
});
|
|
39
49
|
return producer as unknown as MediaProducerHandle;
|
|
40
50
|
},
|
|
@@ -103,12 +113,12 @@ export function createBrowserDevice(): MediaDevice {
|
|
|
103
113
|
createSendTransport({ description, iceServers, handlers }) {
|
|
104
114
|
const transport = device.createSendTransport(common(description, iceServers));
|
|
105
115
|
wire(transport, handlers);
|
|
106
|
-
return adapt(transport);
|
|
116
|
+
return adapt(transport, device);
|
|
107
117
|
},
|
|
108
118
|
createRecvTransport({ description, iceServers, handlers }) {
|
|
109
119
|
const transport = device.createRecvTransport(common(description, iceServers));
|
|
110
120
|
wire(transport, handlers);
|
|
111
|
-
return adapt(transport);
|
|
121
|
+
return adapt(transport, device);
|
|
112
122
|
},
|
|
113
123
|
};
|
|
114
124
|
}
|
package/src/room/device.ts
CHANGED
|
@@ -62,6 +62,8 @@ export interface MediaTransport {
|
|
|
62
62
|
track: MediaStreamTrack;
|
|
63
63
|
appData?: Record<string, unknown>;
|
|
64
64
|
encodings?: unknown[];
|
|
65
|
+
/** Prefer this codec from the loaded capabilities; ignored when absent. */
|
|
66
|
+
codec?: "h264" | "vp8";
|
|
65
67
|
}): Promise<MediaProducerHandle>;
|
|
66
68
|
consume(input: {
|
|
67
69
|
id: string;
|
|
@@ -78,7 +80,18 @@ export type MediaProducerHandle = {
|
|
|
78
80
|
pause(): void;
|
|
79
81
|
resume(): void;
|
|
80
82
|
close(): void;
|
|
83
|
+
/** Swap the capture feeding this producer. The node sees nothing. */
|
|
84
|
+
replaceTrack(track: MediaStreamTrack): Promise<void>;
|
|
81
85
|
readonly closed: boolean;
|
|
86
|
+
/**
|
|
87
|
+
* The underlying sender, when the implementation has one.
|
|
88
|
+
*
|
|
89
|
+
* Exposed for `degradationPreference`, which is a SENDER-level setting with
|
|
90
|
+
* no per-encoding equivalent, so there is no way to ask for it through
|
|
91
|
+
* `produce()`. Optional because a non-browser implementation has no such
|
|
92
|
+
* object, and every caller has to cope with its absence anyway.
|
|
93
|
+
*/
|
|
94
|
+
readonly rtpSender?: RTCRtpSender | null;
|
|
82
95
|
};
|
|
83
96
|
|
|
84
97
|
export type MediaConsumerHandle = {
|
|
@@ -89,6 +102,12 @@ export type MediaConsumerHandle = {
|
|
|
89
102
|
pause(): void;
|
|
90
103
|
resume(): void;
|
|
91
104
|
close(): void;
|
|
105
|
+
/**
|
|
106
|
+
* The browser's inbound stats for this consumer, when the implementation
|
|
107
|
+
* has them (mediasoup-client does; a fake need not). What the diagnostics
|
|
108
|
+
* read decoded resolution and bitrate from.
|
|
109
|
+
*/
|
|
110
|
+
getStats?(): Promise<unknown>;
|
|
92
111
|
};
|
|
93
112
|
|
|
94
113
|
/**
|