@fishjam-cloud/webrtc-client 0.30.2-rc.0 → 0.30.2
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.mts +54 -74
- package/dist/index.mjs +49 -89
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import { BinaryWriter, BinaryReader } from '@bufbuild/protobuf/wire';
|
|
2
2
|
import TypedEmitter from 'typed-emitter';
|
|
3
3
|
|
|
4
|
+
declare const getLogger: (enableLogging: boolean) => {
|
|
5
|
+
readonly debug: (arg: unknown, ...args: unknown[]) => void;
|
|
6
|
+
readonly warn: (arg: unknown, ...args: unknown[]) => void;
|
|
7
|
+
readonly error: (arg: unknown, ...args: unknown[]) => void;
|
|
8
|
+
};
|
|
9
|
+
|
|
4
10
|
declare enum Variant {
|
|
5
11
|
VARIANT_UNSPECIFIED = 0,
|
|
6
12
|
VARIANT_LOW = 1,
|
|
@@ -35,42 +41,6 @@ interface MessageFns$2<T> {
|
|
|
35
41
|
fromPartial<I extends Exact$2<DeepPartial$2<T>, I>>(object: I): T;
|
|
36
42
|
}
|
|
37
43
|
|
|
38
|
-
interface MediaEvent_Track_SimulcastConfig {
|
|
39
|
-
enabled: boolean;
|
|
40
|
-
enabledVariants: Variant[];
|
|
41
|
-
disabledVariants: Variant[];
|
|
42
|
-
}
|
|
43
|
-
declare const MediaEvent_Track_SimulcastConfig: MessageFns$1<MediaEvent_Track_SimulcastConfig>;
|
|
44
|
-
interface MediaEvent_OfferData_TrackTypes {
|
|
45
|
-
audio: number;
|
|
46
|
-
video: number;
|
|
47
|
-
}
|
|
48
|
-
declare const MediaEvent_OfferData_TrackTypes: MessageFns$1<MediaEvent_OfferData_TrackTypes>;
|
|
49
|
-
type Builtin$1 = Date | Function | Uint8Array | string | number | boolean | undefined;
|
|
50
|
-
type DeepPartial$1<T> = T extends Builtin$1 ? T : T extends globalThis.Array<infer U> ? globalThis.Array<DeepPartial$1<U>> : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial$1<U>> : T extends {} ? {
|
|
51
|
-
[K in keyof T]?: DeepPartial$1<T[K]>;
|
|
52
|
-
} : Partial<T>;
|
|
53
|
-
type KeysOfUnion$1<T> = T extends T ? keyof T : never;
|
|
54
|
-
type Exact$1<P, I extends P> = P extends Builtin$1 ? P : P & {
|
|
55
|
-
[K in keyof P]: Exact$1<P[K], I[K]>;
|
|
56
|
-
} & {
|
|
57
|
-
[K in Exclude<keyof I, KeysOfUnion$1<P>>]: never;
|
|
58
|
-
};
|
|
59
|
-
interface MessageFns$1<T> {
|
|
60
|
-
encode(message: T, writer?: BinaryWriter): BinaryWriter;
|
|
61
|
-
decode(input: BinaryReader | Uint8Array, length?: number): T;
|
|
62
|
-
fromJSON(object: any): T;
|
|
63
|
-
toJSON(message: T): unknown;
|
|
64
|
-
create<I extends Exact$1<DeepPartial$1<T>, I>>(base?: I): T;
|
|
65
|
-
fromPartial<I extends Exact$1<DeepPartial$1<T>, I>>(object: I): T;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
declare const getLogger: (enableLogging: boolean) => {
|
|
69
|
-
readonly debug: (arg: unknown, ...args: unknown[]) => void;
|
|
70
|
-
readonly warn: (arg: unknown, ...args: unknown[]) => void;
|
|
71
|
-
readonly error: (arg: unknown, ...args: unknown[]) => void;
|
|
72
|
-
};
|
|
73
|
-
|
|
74
44
|
/** Defines any type of message sent from Peer to Membrane RTC Engine */
|
|
75
45
|
interface MediaEvent$1 {
|
|
76
46
|
connect?: MediaEvent_Connect | undefined;
|
|
@@ -86,36 +56,36 @@ interface MediaEvent$1 {
|
|
|
86
56
|
setTargetTrackVariant?: MediaEvent_SetTargetTrackVariant | undefined;
|
|
87
57
|
unmuteTrack?: MediaEvent_UnmuteTrack | undefined;
|
|
88
58
|
}
|
|
89
|
-
declare const MediaEvent$1: MessageFns<MediaEvent$1>;
|
|
59
|
+
declare const MediaEvent$1: MessageFns$1<MediaEvent$1>;
|
|
90
60
|
interface MediaEvent_VariantBitrate {
|
|
91
61
|
variant: Variant;
|
|
92
62
|
bitrate: number;
|
|
93
63
|
}
|
|
94
|
-
declare const MediaEvent_VariantBitrate: MessageFns<MediaEvent_VariantBitrate>;
|
|
64
|
+
declare const MediaEvent_VariantBitrate: MessageFns$1<MediaEvent_VariantBitrate>;
|
|
95
65
|
/** Sent when a peer wants to join WebRTC Endpoint. */
|
|
96
66
|
interface MediaEvent_Connect {
|
|
97
67
|
metadataJson: string;
|
|
98
68
|
}
|
|
99
|
-
declare const MediaEvent_Connect: MessageFns<MediaEvent_Connect>;
|
|
69
|
+
declare const MediaEvent_Connect: MessageFns$1<MediaEvent_Connect>;
|
|
100
70
|
/** Sent when a peer disconnects from WebRTC Endpoint. */
|
|
101
71
|
interface MediaEvent_Disconnect {
|
|
102
72
|
}
|
|
103
|
-
declare const MediaEvent_Disconnect: MessageFns<MediaEvent_Disconnect>;
|
|
73
|
+
declare const MediaEvent_Disconnect: MessageFns$1<MediaEvent_Disconnect>;
|
|
104
74
|
/** Sent when a peer wants to update its metadata */
|
|
105
75
|
interface MediaEvent_UpdateEndpointMetadata {
|
|
106
76
|
metadataJson: string;
|
|
107
77
|
}
|
|
108
|
-
declare const MediaEvent_UpdateEndpointMetadata: MessageFns<MediaEvent_UpdateEndpointMetadata>;
|
|
78
|
+
declare const MediaEvent_UpdateEndpointMetadata: MessageFns$1<MediaEvent_UpdateEndpointMetadata>;
|
|
109
79
|
/** Sent when a peer wants to update its track's metadata */
|
|
110
80
|
interface MediaEvent_UpdateTrackMetadata {
|
|
111
81
|
trackId: string;
|
|
112
82
|
metadataJson: string;
|
|
113
83
|
}
|
|
114
|
-
declare const MediaEvent_UpdateTrackMetadata: MessageFns<MediaEvent_UpdateTrackMetadata>;
|
|
84
|
+
declare const MediaEvent_UpdateTrackMetadata: MessageFns$1<MediaEvent_UpdateTrackMetadata>;
|
|
115
85
|
/** Sent when peer wants to renegotiate connection due to adding a track or removing a track */
|
|
116
86
|
interface MediaEvent_RenegotiateTracks {
|
|
117
87
|
}
|
|
118
|
-
declare const MediaEvent_RenegotiateTracks: MessageFns<MediaEvent_RenegotiateTracks>;
|
|
88
|
+
declare const MediaEvent_RenegotiateTracks: MessageFns$1<MediaEvent_RenegotiateTracks>;
|
|
119
89
|
/**
|
|
120
90
|
* Sent as a response to `offerData` media event during renegotiation
|
|
121
91
|
* Maps contain only information about current peer's `sendonly` tracks.
|
|
@@ -135,35 +105,65 @@ interface MediaEvent_SdpOffer {
|
|
|
135
105
|
[key: string]: string;
|
|
136
106
|
};
|
|
137
107
|
}
|
|
138
|
-
declare const MediaEvent_SdpOffer: MessageFns<MediaEvent_SdpOffer>;
|
|
108
|
+
declare const MediaEvent_SdpOffer: MessageFns$1<MediaEvent_SdpOffer>;
|
|
139
109
|
/** Sent when Peer wants to update its track's bitrate */
|
|
140
110
|
interface MediaEvent_TrackBitrates {
|
|
141
111
|
trackId: string;
|
|
142
112
|
/** Bitrate of each variant. For non-simulcast tracks use VARIANT_UNSPECIFIED. */
|
|
143
113
|
variantBitrates: MediaEvent_VariantBitrate[];
|
|
144
114
|
}
|
|
145
|
-
declare const MediaEvent_TrackBitrates: MessageFns<MediaEvent_TrackBitrates>;
|
|
115
|
+
declare const MediaEvent_TrackBitrates: MessageFns$1<MediaEvent_TrackBitrates>;
|
|
146
116
|
/** Sent when client disables one of the track variants */
|
|
147
117
|
interface MediaEvent_DisableTrackVariant {
|
|
148
118
|
trackId: string;
|
|
149
119
|
variant: Variant;
|
|
150
120
|
}
|
|
151
|
-
declare const MediaEvent_DisableTrackVariant: MessageFns<MediaEvent_DisableTrackVariant>;
|
|
121
|
+
declare const MediaEvent_DisableTrackVariant: MessageFns$1<MediaEvent_DisableTrackVariant>;
|
|
152
122
|
/** Sent when client enables one of the track variants */
|
|
153
123
|
interface MediaEvent_EnableTrackVariant {
|
|
154
124
|
trackId: string;
|
|
155
125
|
variant: Variant;
|
|
156
126
|
}
|
|
157
|
-
declare const MediaEvent_EnableTrackVariant: MessageFns<MediaEvent_EnableTrackVariant>;
|
|
127
|
+
declare const MediaEvent_EnableTrackVariant: MessageFns$1<MediaEvent_EnableTrackVariant>;
|
|
158
128
|
interface MediaEvent_SetTargetTrackVariant {
|
|
159
129
|
trackId: string;
|
|
160
130
|
variant: Variant;
|
|
161
131
|
}
|
|
162
|
-
declare const MediaEvent_SetTargetTrackVariant: MessageFns<MediaEvent_SetTargetTrackVariant>;
|
|
132
|
+
declare const MediaEvent_SetTargetTrackVariant: MessageFns$1<MediaEvent_SetTargetTrackVariant>;
|
|
163
133
|
interface MediaEvent_UnmuteTrack {
|
|
164
134
|
trackId: string;
|
|
165
135
|
}
|
|
166
|
-
declare const MediaEvent_UnmuteTrack: MessageFns<MediaEvent_UnmuteTrack>;
|
|
136
|
+
declare const MediaEvent_UnmuteTrack: MessageFns$1<MediaEvent_UnmuteTrack>;
|
|
137
|
+
type Builtin$1 = Date | Function | Uint8Array | string | number | boolean | undefined;
|
|
138
|
+
type DeepPartial$1<T> = T extends Builtin$1 ? T : T extends globalThis.Array<infer U> ? globalThis.Array<DeepPartial$1<U>> : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial$1<U>> : T extends {} ? {
|
|
139
|
+
[K in keyof T]?: DeepPartial$1<T[K]>;
|
|
140
|
+
} : Partial<T>;
|
|
141
|
+
type KeysOfUnion$1<T> = T extends T ? keyof T : never;
|
|
142
|
+
type Exact$1<P, I extends P> = P extends Builtin$1 ? P : P & {
|
|
143
|
+
[K in keyof P]: Exact$1<P[K], I[K]>;
|
|
144
|
+
} & {
|
|
145
|
+
[K in Exclude<keyof I, KeysOfUnion$1<P>>]: never;
|
|
146
|
+
};
|
|
147
|
+
interface MessageFns$1<T> {
|
|
148
|
+
encode(message: T, writer?: BinaryWriter): BinaryWriter;
|
|
149
|
+
decode(input: BinaryReader | Uint8Array, length?: number): T;
|
|
150
|
+
fromJSON(object: any): T;
|
|
151
|
+
toJSON(message: T): unknown;
|
|
152
|
+
create<I extends Exact$1<DeepPartial$1<T>, I>>(base?: I): T;
|
|
153
|
+
fromPartial<I extends Exact$1<DeepPartial$1<T>, I>>(object: I): T;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
interface MediaEvent_Track_SimulcastConfig {
|
|
157
|
+
enabled: boolean;
|
|
158
|
+
enabledVariants: Variant[];
|
|
159
|
+
disabledVariants: Variant[];
|
|
160
|
+
}
|
|
161
|
+
declare const MediaEvent_Track_SimulcastConfig: MessageFns<MediaEvent_Track_SimulcastConfig>;
|
|
162
|
+
interface MediaEvent_OfferData_TrackTypes {
|
|
163
|
+
audio: number;
|
|
164
|
+
video: number;
|
|
165
|
+
}
|
|
166
|
+
declare const MediaEvent_OfferData_TrackTypes: MessageFns<MediaEvent_OfferData_TrackTypes>;
|
|
167
167
|
type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
|
|
168
168
|
type DeepPartial<T> = T extends Builtin ? T : T extends globalThis.Array<infer U> ? globalThis.Array<DeepPartial<U>> : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>> : T extends {} ? {
|
|
169
169
|
[K in keyof T]?: DeepPartial<T[K]>;
|
|
@@ -200,14 +200,13 @@ type TrackKind = 'audio' | 'video';
|
|
|
200
200
|
*/
|
|
201
201
|
type VadStatus = 'speech' | 'silence';
|
|
202
202
|
/**
|
|
203
|
-
* Type describing maximal bandwidth that can be used, in kbps.
|
|
204
|
-
* Video limits are clamped to `MAX_BANDWIDTH_LIMITS`; 0 is interpreted as "use the cap".
|
|
203
|
+
* Type describing maximal bandwidth that can be used, in kbps. 0 is interpreted as unlimited bandwidth.
|
|
205
204
|
*/
|
|
206
205
|
type BandwidthLimit = number;
|
|
207
206
|
/**
|
|
208
207
|
* Type describing bandwidth limit for simulcast track.
|
|
209
208
|
* It is a mapping (encoding => BandwidthLimit).
|
|
210
|
-
* If encoding isn't present in this mapping,
|
|
209
|
+
* If encoding isn't present in this mapping, it will be assumed that this particular encoding shouldn't have any bandwidth limit
|
|
211
210
|
*/
|
|
212
211
|
type SimulcastBandwidthLimit = Map<Variant, BandwidthLimit>;
|
|
213
212
|
/**
|
|
@@ -496,25 +495,6 @@ type WebRTCEndpointProps = {
|
|
|
496
495
|
};
|
|
497
496
|
type Logger = ReturnType<typeof getLogger>;
|
|
498
497
|
|
|
499
|
-
/**
|
|
500
|
-
* Hard caps (in kbps) for the bitrate of an outgoing video track.
|
|
501
|
-
* A limit passed to the SDK is never allowed to exceed these values, and an unset (0) limit resolves to them.
|
|
502
|
-
*/
|
|
503
|
-
declare const MAX_BANDWIDTH_LIMITS: {
|
|
504
|
-
readonly singleStream: BandwidthLimit;
|
|
505
|
-
readonly simulcast: {
|
|
506
|
-
readonly 1: BandwidthLimit;
|
|
507
|
-
readonly 2: BandwidthLimit;
|
|
508
|
-
readonly 3: BandwidthLimit;
|
|
509
|
-
};
|
|
510
|
-
};
|
|
511
|
-
/**
|
|
512
|
-
* Resolves a user-provided video bandwidth limit against {@link MAX_BANDWIDTH_LIMITS}.
|
|
513
|
-
* - a number is a single-stream limit; 0 or negative means "use the cap", higher values are clamped to it
|
|
514
|
-
* - a Map holds per-variant simulcast limits; each variant is resolved the same way
|
|
515
|
-
*/
|
|
516
|
-
declare const resolveBandwidthLimit: (limit: TrackBandwidthLimit) => TrackBandwidthLimit;
|
|
517
|
-
|
|
518
498
|
declare class ConnectionManager {
|
|
519
499
|
private readonly connection;
|
|
520
500
|
constructor(iceServers: RTCIceServer[]);
|
|
@@ -746,7 +726,7 @@ declare class WebRTCEndpoint extends WebRTCEndpoint_base {
|
|
|
746
726
|
* In case trackId points at the simulcast track bandwidth is split between all of the variant streams proportionally to their resolution.
|
|
747
727
|
*
|
|
748
728
|
* @param {string} trackId
|
|
749
|
-
* @param {BandwidthLimit} bandwidth in kbps
|
|
729
|
+
* @param {BandwidthLimit} bandwidth in kbps
|
|
750
730
|
* @returns {Promise<boolean>} success
|
|
751
731
|
*/
|
|
752
732
|
setTrackBandwidth(trackId: string, bandwidth: BandwidthLimit): Promise<void>;
|
|
@@ -755,7 +735,7 @@ declare class WebRTCEndpoint extends WebRTCEndpoint_base {
|
|
|
755
735
|
*
|
|
756
736
|
* @param {string} trackId - id of the track
|
|
757
737
|
* @param {string} rid - rid of the encoding
|
|
758
|
-
* @param {BandwidthLimit} bandwidth - desired max bandwidth used by the encoding (in kbps)
|
|
738
|
+
* @param {BandwidthLimit} bandwidth - desired max bandwidth used by the encoding (in kbps)
|
|
759
739
|
* @returns
|
|
760
740
|
*/
|
|
761
741
|
setEncodingBandwidth(trackId: string, rid: Variant, bandwidth: BandwidthLimit): Promise<void>;
|
|
@@ -916,4 +896,4 @@ declare class WebRTCEndpoint extends WebRTCEndpoint_base {
|
|
|
916
896
|
private onIceConnectionStateChange;
|
|
917
897
|
}
|
|
918
898
|
|
|
919
|
-
export { type BandwidthLimit, type DataCallback, type DataChannelMessagePayload, type DataChannelOptions, type DataChannelType, type EncodingReason, type Endpoint, type Logger,
|
|
899
|
+
export { type BandwidthLimit, type DataCallback, type DataChannelMessagePayload, type DataChannelOptions, type DataChannelType, type EncodingReason, type Endpoint, type Logger, type MediaEvent, type SerializedMediaEvent, type SimulcastBandwidthLimit, MediaEvent_Track_SimulcastConfig as SimulcastConfig, type TrackBandwidthLimit, type TrackContext, type TrackContextEvents, type TrackKind, type VadStatus, Variant, WebRTCEndpoint, type WebRTCEndpointEvents, getLogger };
|
package/dist/index.mjs
CHANGED
|
@@ -1,3 +1,20 @@
|
|
|
1
|
+
// src/logger.ts
|
|
2
|
+
var FISHJAM_PREFIX = "[FISHJAM]";
|
|
3
|
+
var getLogger = (enableLogging) => ({
|
|
4
|
+
debug: (arg, ...args) => {
|
|
5
|
+
if (enableLogging) console.debug(FISHJAM_PREFIX, arg, ...args);
|
|
6
|
+
},
|
|
7
|
+
warn: (arg, ...args) => {
|
|
8
|
+
if (enableLogging) console.warn(FISHJAM_PREFIX, arg, ...args);
|
|
9
|
+
},
|
|
10
|
+
error: (arg, ...args) => {
|
|
11
|
+
if (enableLogging) console.error(FISHJAM_PREFIX, arg, ...args);
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
// ../protobufs/fishjam/media_events/peer/peer.ts
|
|
16
|
+
import { BinaryReader as BinaryReader2, BinaryWriter as BinaryWriter2 } from "@bufbuild/protobuf/wire";
|
|
17
|
+
|
|
1
18
|
// ../protobufs/fishjam/media_events/shared.ts
|
|
2
19
|
import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire";
|
|
3
20
|
var Variant = /* @__PURE__ */ ((Variant4) => {
|
|
@@ -145,67 +162,7 @@ function isSet(value) {
|
|
|
145
162
|
return value !== null && value !== void 0;
|
|
146
163
|
}
|
|
147
164
|
|
|
148
|
-
// src/bitrate.ts
|
|
149
|
-
var MAX_BANDWIDTH_LIMITS = {
|
|
150
|
-
singleStream: 1500,
|
|
151
|
-
simulcast: {
|
|
152
|
-
[1 /* VARIANT_LOW */]: 150,
|
|
153
|
-
[2 /* VARIANT_MEDIUM */]: 500,
|
|
154
|
-
[3 /* VARIANT_HIGH */]: 1500
|
|
155
|
-
}
|
|
156
|
-
};
|
|
157
|
-
var SIMULCAST_VARIANTS = [1 /* VARIANT_LOW */, 2 /* VARIANT_MEDIUM */, 3 /* VARIANT_HIGH */];
|
|
158
|
-
var isSimulcastVariant = (variant) => SIMULCAST_VARIANTS.includes(variant);
|
|
159
|
-
var resolveAgainstCap = (limit, cap, label) => {
|
|
160
|
-
if (!limit || limit <= 0) return cap;
|
|
161
|
-
if (limit > cap) {
|
|
162
|
-
console.warn(`[Fishjam] ${label} bandwidth limit ${limit} kbps exceeds the cap of ${cap} kbps, using the cap`);
|
|
163
|
-
return cap;
|
|
164
|
-
}
|
|
165
|
-
return limit;
|
|
166
|
-
};
|
|
167
|
-
var resolveBandwidthLimit = (limit) => {
|
|
168
|
-
if (typeof limit === "number") return resolveAgainstCap(limit, MAX_BANDWIDTH_LIMITS.singleStream, "single stream");
|
|
169
|
-
const resolved = /* @__PURE__ */ new Map();
|
|
170
|
-
for (const variant of SIMULCAST_VARIANTS) {
|
|
171
|
-
resolved.set(variant, resolveAgainstCap(limit.get(variant), MAX_BANDWIDTH_LIMITS.simulcast[variant], Variant[variant]));
|
|
172
|
-
}
|
|
173
|
-
return resolved;
|
|
174
|
-
};
|
|
175
|
-
var resolveVariantBandwidthLimit = (variant, limit) => {
|
|
176
|
-
const cap = isSimulcastVariant(variant) ? MAX_BANDWIDTH_LIMITS.simulcast[variant] : MAX_BANDWIDTH_LIMITS.singleStream;
|
|
177
|
-
return resolveAgainstCap(limit, cap, Variant[variant]);
|
|
178
|
-
};
|
|
179
|
-
var kbpsToBps = (kbps) => kbps * 1024;
|
|
180
|
-
var defaultBitrates = {
|
|
181
|
-
audio: 5e4,
|
|
182
|
-
video: kbpsToBps(MAX_BANDWIDTH_LIMITS.singleStream)
|
|
183
|
-
};
|
|
184
|
-
var UNLIMITED_BANDWIDTH = 0;
|
|
185
|
-
var defaultSimulcastBitrates = {
|
|
186
|
-
[3 /* VARIANT_HIGH */]: kbpsToBps(MAX_BANDWIDTH_LIMITS.simulcast[3 /* VARIANT_HIGH */]),
|
|
187
|
-
[2 /* VARIANT_MEDIUM */]: kbpsToBps(MAX_BANDWIDTH_LIMITS.simulcast[2 /* VARIANT_MEDIUM */]),
|
|
188
|
-
[1 /* VARIANT_LOW */]: kbpsToBps(MAX_BANDWIDTH_LIMITS.simulcast[1 /* VARIANT_LOW */]),
|
|
189
|
-
[0 /* VARIANT_UNSPECIFIED */]: 0,
|
|
190
|
-
[-1 /* UNRECOGNIZED */]: 0
|
|
191
|
-
};
|
|
192
|
-
|
|
193
|
-
// src/logger.ts
|
|
194
|
-
var FISHJAM_PREFIX = "[FISHJAM]";
|
|
195
|
-
var getLogger = (enableLogging) => ({
|
|
196
|
-
debug: (arg, ...args) => {
|
|
197
|
-
if (enableLogging) console.debug(FISHJAM_PREFIX, arg, ...args);
|
|
198
|
-
},
|
|
199
|
-
warn: (arg, ...args) => {
|
|
200
|
-
if (enableLogging) console.warn(FISHJAM_PREFIX, arg, ...args);
|
|
201
|
-
},
|
|
202
|
-
error: (arg, ...args) => {
|
|
203
|
-
if (enableLogging) console.error(FISHJAM_PREFIX, arg, ...args);
|
|
204
|
-
}
|
|
205
|
-
});
|
|
206
|
-
|
|
207
165
|
// ../protobufs/fishjam/media_events/peer/peer.ts
|
|
208
|
-
import { BinaryReader as BinaryReader2, BinaryWriter as BinaryWriter2 } from "@bufbuild/protobuf/wire";
|
|
209
166
|
function createBaseMediaEvent() {
|
|
210
167
|
return {
|
|
211
168
|
connect: void 0,
|
|
@@ -4006,15 +3963,18 @@ var TrackContextImpl = class extends EventEmitter2 {
|
|
|
4006
3963
|
}
|
|
4007
3964
|
};
|
|
4008
3965
|
|
|
4009
|
-
// src/
|
|
4010
|
-
var
|
|
4011
|
-
|
|
4012
|
-
|
|
4013
|
-
|
|
4014
|
-
|
|
4015
|
-
|
|
4016
|
-
|
|
4017
|
-
|
|
3966
|
+
// src/bitrate.ts
|
|
3967
|
+
var defaultBitrates = {
|
|
3968
|
+
audio: 5e4,
|
|
3969
|
+
video: 25e5
|
|
3970
|
+
};
|
|
3971
|
+
var UNLIMITED_BANDWIDTH = 0;
|
|
3972
|
+
var defaultSimulcastBitrates = {
|
|
3973
|
+
[3 /* VARIANT_HIGH */]: 25e5,
|
|
3974
|
+
[2 /* VARIANT_MEDIUM */]: 5e5,
|
|
3975
|
+
[1 /* VARIANT_LOW */]: 15e4,
|
|
3976
|
+
[0 /* VARIANT_UNSPECIFIED */]: 0,
|
|
3977
|
+
[-1 /* UNRECOGNIZED */]: 0
|
|
4018
3978
|
};
|
|
4019
3979
|
|
|
4020
3980
|
// src/tracks/bandwidth.ts
|
|
@@ -4407,10 +4367,9 @@ var Local = class {
|
|
|
4407
4367
|
const trackManager = this.localTracks[trackId];
|
|
4408
4368
|
if (!trackManager) throw new Error(`Cannot find ${trackId}`);
|
|
4409
4369
|
await trackManager.setTrackBandwidth(bandwidth);
|
|
4410
|
-
trackManager.trackContext.maxBandwidth = bandwidth;
|
|
4411
4370
|
const trackBitrates = MediaEvent_TrackBitrates.create({
|
|
4412
4371
|
trackId,
|
|
4413
|
-
variantBitrates:
|
|
4372
|
+
variantBitrates: [{ variant: 0 /* VARIANT_UNSPECIFIED */, bitrate: bandwidth }]
|
|
4414
4373
|
});
|
|
4415
4374
|
this.sendMediaEvent(MediaEvent.create({ trackBitrates }));
|
|
4416
4375
|
this.emit("localTrackBandwidthSet", {
|
|
@@ -4431,11 +4390,19 @@ var Local = class {
|
|
|
4431
4390
|
const trackManager = this.localTracks[trackId];
|
|
4432
4391
|
if (!trackManager) throw new Error(`Cannot find ${trackId}`);
|
|
4433
4392
|
await trackManager.setEncodingBandwidth(rid, bandwidth);
|
|
4434
|
-
const
|
|
4435
|
-
|
|
4393
|
+
const bitrates = trackManager.getTrackBitrates();
|
|
4394
|
+
let variantBitrates = [];
|
|
4395
|
+
if (typeof bitrates === "number") {
|
|
4396
|
+
variantBitrates = [{ variant: 0 /* VARIANT_UNSPECIFIED */, bitrate: bitrates }];
|
|
4397
|
+
} else if (bitrates) {
|
|
4398
|
+
variantBitrates = Object.entries(bitrates).map(([variant, bitrate]) => ({
|
|
4399
|
+
variant: Number(variant),
|
|
4400
|
+
bitrate
|
|
4401
|
+
}));
|
|
4402
|
+
}
|
|
4436
4403
|
const trackBitrates = MediaEvent_TrackBitrates.create({
|
|
4437
4404
|
trackId,
|
|
4438
|
-
variantBitrates
|
|
4405
|
+
variantBitrates
|
|
4439
4406
|
});
|
|
4440
4407
|
this.sendMediaEvent(MediaEvent.create({ trackBitrates }));
|
|
4441
4408
|
this.emit("localTrackEncodingBandwidthSet", {
|
|
@@ -4504,13 +4471,8 @@ var Local = class {
|
|
|
4504
4471
|
(acc, { id, trackContext }) => ({ ...acc, [id]: JSON.stringify(trackContext.metadata) }),
|
|
4505
4472
|
{}
|
|
4506
4473
|
);
|
|
4507
|
-
|
|
4508
|
-
|
|
4509
|
-
...acc,
|
|
4510
|
-
[id]: MediaEvent_TrackBitrates.create({ trackId: id, variantBitrates: getVariantBitrates(trackContext) })
|
|
4511
|
-
}),
|
|
4512
|
-
{}
|
|
4513
|
-
);
|
|
4474
|
+
// TODO add bitrates
|
|
4475
|
+
getTrackIdToTrackBitrates = () => Object.values(this.localTracks).reduce((acc, { id }) => ({ ...acc, [id]: { bitrate: 15e5 } }), {});
|
|
4514
4476
|
getMidToTrackId = () => {
|
|
4515
4477
|
if (!this.connection) return {};
|
|
4516
4478
|
const mappingFromTransceivers = this.getTransceiverMapping();
|
|
@@ -5116,7 +5078,7 @@ var WebRTCEndpoint = class extends EventEmitter3 {
|
|
|
5116
5078
|
const resolutionNotifier = new Deferred();
|
|
5117
5079
|
const trackId = this.getTrackId(uuidv4());
|
|
5118
5080
|
const trackStream = stream ?? new MediaStream();
|
|
5119
|
-
const resolvedMaxBandwidth =
|
|
5081
|
+
const resolvedMaxBandwidth = typeof maxBandwidth === "number" && maxBandwidth > 0 ? maxBandwidth : 0;
|
|
5120
5082
|
try {
|
|
5121
5083
|
if (!stream) trackStream.addTrack(track);
|
|
5122
5084
|
this.commandsQueue.pushCommand({
|
|
@@ -5209,24 +5171,24 @@ var WebRTCEndpoint = class extends EventEmitter3 {
|
|
|
5209
5171
|
* In case trackId points at the simulcast track bandwidth is split between all of the variant streams proportionally to their resolution.
|
|
5210
5172
|
*
|
|
5211
5173
|
* @param {string} trackId
|
|
5212
|
-
* @param {BandwidthLimit} bandwidth in kbps
|
|
5174
|
+
* @param {BandwidthLimit} bandwidth in kbps
|
|
5213
5175
|
* @returns {Promise<boolean>} success
|
|
5214
5176
|
*/
|
|
5215
5177
|
setTrackBandwidth(trackId, bandwidth) {
|
|
5216
5178
|
if (!this.connectionManager) throw new Error(`There is no active RTCPeerConnection`);
|
|
5217
|
-
return this.local.setTrackBandwidth(trackId,
|
|
5179
|
+
return this.local.setTrackBandwidth(trackId, bandwidth);
|
|
5218
5180
|
}
|
|
5219
5181
|
/**
|
|
5220
5182
|
* Updates maximum bandwidth for the given simulcast encoding of the given track.
|
|
5221
5183
|
*
|
|
5222
5184
|
* @param {string} trackId - id of the track
|
|
5223
5185
|
* @param {string} rid - rid of the encoding
|
|
5224
|
-
* @param {BandwidthLimit} bandwidth - desired max bandwidth used by the encoding (in kbps)
|
|
5186
|
+
* @param {BandwidthLimit} bandwidth - desired max bandwidth used by the encoding (in kbps)
|
|
5225
5187
|
* @returns
|
|
5226
5188
|
*/
|
|
5227
5189
|
async setEncodingBandwidth(trackId, rid, bandwidth) {
|
|
5228
5190
|
if (!this.connectionManager) throw new Error(`There is no active RTCPeerConnection`);
|
|
5229
|
-
return await this.local.setEncodingBandwidth(trackId, rid,
|
|
5191
|
+
return await this.local.setEncodingBandwidth(trackId, rid, bandwidth);
|
|
5230
5192
|
}
|
|
5231
5193
|
/**
|
|
5232
5194
|
* Removes a track from connection that was sent to the RTC Engine.
|
|
@@ -5523,10 +5485,8 @@ var WebRTCEndpoint = class extends EventEmitter3 {
|
|
|
5523
5485
|
};
|
|
5524
5486
|
};
|
|
5525
5487
|
export {
|
|
5526
|
-
MAX_BANDWIDTH_LIMITS,
|
|
5527
5488
|
MediaEvent_Track_SimulcastConfig as SimulcastConfig,
|
|
5528
5489
|
Variant,
|
|
5529
5490
|
WebRTCEndpoint,
|
|
5530
|
-
getLogger
|
|
5531
|
-
resolveBandwidthLimit
|
|
5491
|
+
getLogger
|
|
5532
5492
|
};
|
package/package.json
CHANGED