@fishjam-cloud/webrtc-client 0.26.0-rc.0 → 0.26.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.mts CHANGED
@@ -633,10 +633,8 @@ declare class WebRTCEndpoint extends WebRTCEndpoint_base {
633
633
  * @param trackMetadata - Any information about this track that other endpoints will
634
634
  * receive in {@link WebRTCEndpointEvents.endpointAdded}. E.g. this can source of the track - whether it's
635
635
  * screensharing, webcam or some other media device.
636
- * @param _simulcastConfig - Simulcast configuration parameter. **Currently ignored** - simulcast is disabled
637
- * regardless of the value passed. This is a temporary change until bandwidth estimation is implemented or
638
- * manual track selection support is added. For more information refer to {@link SimulcastConfig}.
639
- * @param _maxBandwidth - maximal bandwidth this track can use. **Currently processed with a threshold check**:
636
+ * @param simulcastConfig - Simulcast configuration. For more information refer to {@link SimulcastConfig}.
637
+ * @param maxBandwidth - maximal bandwidth this track can use. **Currently processed with a threshold check**:
640
638
  * if the value is a positive number, it will be used; otherwise, it defaults to 0 (unlimited).
641
639
  * This option has no effect for simulcast and audio tracks.
642
640
  * For simulcast tracks use `{@link WebRTCEndpoint.setTrackBandwidth}.
@@ -671,7 +669,7 @@ declare class WebRTCEndpoint extends WebRTCEndpoint_base {
671
669
  * .forEach((track) => webrtc.addTrack(track, localStream));
672
670
  * ```
673
671
  */
674
- addTrack(track: MediaStreamTrack, trackMetadata?: unknown, _simulcastConfig?: MediaEvent_Track_SimulcastConfig, _maxBandwidth?: TrackBandwidthLimit): Promise<string>;
672
+ addTrack(track: MediaStreamTrack, trackMetadata?: unknown, simulcastConfig?: MediaEvent_Track_SimulcastConfig, maxBandwidth?: TrackBandwidthLimit, stream?: MediaStream): Promise<string>;
675
673
  /**
676
674
  * Replaces a track that is being sent to the RTC Engine.
677
675
  * @param trackId - Audio or video track.
package/dist/index.mjs CHANGED
@@ -4072,7 +4072,8 @@ var createSimulcastTransceiverConfig = (trackContext, maxBandwidth) => {
4072
4072
  // keep this array from low resolution to high resolution
4073
4073
  // in other case lower resolution encoding can get
4074
4074
  // higher max_bitrate
4075
- sendEncodings: calculateSimulcastEncodings(encodings, maxBandwidth)
4075
+ sendEncodings: calculateSimulcastEncodings(encodings, maxBandwidth),
4076
+ streams: trackContext.stream ? [trackContext.stream] : []
4076
4077
  };
4077
4078
  };
4078
4079
  var calculateSimulcastEncodings = (encodings, maxBandwidth) => {
@@ -4152,9 +4153,9 @@ var LocalTrack = class {
4152
4153
  const stream = this.trackContext.stream;
4153
4154
  const oldTrack = this.trackContext.track;
4154
4155
  if (!this.sender) throw Error("There is no RTCRtpSender for this track id!");
4155
- stream?.getTracks().forEach((track) => {
4156
- stream?.removeTrack(track);
4157
- });
4156
+ if (oldTrack) {
4157
+ stream?.removeTrack(oldTrack);
4158
+ }
4158
4159
  if (newTrack) {
4159
4160
  stream?.addTrack(newTrack);
4160
4161
  }
@@ -4999,10 +5000,8 @@ var WebRTCEndpoint = class extends EventEmitter3 {
4999
5000
  * @param trackMetadata - Any information about this track that other endpoints will
5000
5001
  * receive in {@link WebRTCEndpointEvents.endpointAdded}. E.g. this can source of the track - whether it's
5001
5002
  * screensharing, webcam or some other media device.
5002
- * @param _simulcastConfig - Simulcast configuration parameter. **Currently ignored** - simulcast is disabled
5003
- * regardless of the value passed. This is a temporary change until bandwidth estimation is implemented or
5004
- * manual track selection support is added. For more information refer to {@link SimulcastConfig}.
5005
- * @param _maxBandwidth - maximal bandwidth this track can use. **Currently processed with a threshold check**:
5003
+ * @param simulcastConfig - Simulcast configuration. For more information refer to {@link SimulcastConfig}.
5004
+ * @param maxBandwidth - maximal bandwidth this track can use. **Currently processed with a threshold check**:
5006
5005
  * if the value is a positive number, it will be used; otherwise, it defaults to 0 (unlimited).
5007
5006
  * This option has no effect for simulcast and audio tracks.
5008
5007
  * For simulcast tracks use `{@link WebRTCEndpoint.setTrackBandwidth}.
@@ -5037,25 +5036,27 @@ var WebRTCEndpoint = class extends EventEmitter3 {
5037
5036
  * .forEach((track) => webrtc.addTrack(track, localStream));
5038
5037
  * ```
5039
5038
  */
5040
- async addTrack(track, trackMetadata, _simulcastConfig = {
5039
+ async addTrack(track, trackMetadata, simulcastConfig = {
5041
5040
  enabled: false,
5042
5041
  enabledVariants: [],
5043
5042
  disabledVariants: []
5044
- }, _maxBandwidth = 0) {
5043
+ }, maxBandwidth = 0, stream) {
5045
5044
  const resolutionNotifier = new Deferred();
5046
5045
  const trackId = this.getTrackId(uuidv4());
5047
- const stream = new MediaStream();
5048
- const simulcastConfig = {
5049
- enabled: false,
5050
- enabledVariants: [],
5051
- disabledVariants: []
5052
- };
5053
- const maxBandwidth = typeof _maxBandwidth === "number" && _maxBandwidth > 0 ? _maxBandwidth : 0;
5046
+ const trackStream = stream ?? new MediaStream();
5047
+ const resolvedMaxBandwidth = typeof maxBandwidth === "number" && maxBandwidth > 0 ? maxBandwidth : 0;
5054
5048
  try {
5055
- stream.addTrack(track);
5049
+ if (!stream) trackStream.addTrack(track);
5056
5050
  this.commandsQueue.pushCommand({
5057
- handler: async () => this.localTrackManager.addTrackHandler(trackId, track, stream, trackMetadata, simulcastConfig, maxBandwidth),
5058
- parse: () => this.localTrackManager.parseAddTrack(track, simulcastConfig, maxBandwidth),
5051
+ handler: async () => this.localTrackManager.addTrackHandler(
5052
+ trackId,
5053
+ track,
5054
+ trackStream,
5055
+ trackMetadata,
5056
+ simulcastConfig,
5057
+ resolvedMaxBandwidth
5058
+ ),
5059
+ parse: () => this.localTrackManager.parseAddTrack(track, simulcastConfig, resolvedMaxBandwidth),
5059
5060
  resolve: "after-renegotiation",
5060
5061
  resolutionNotifier
5061
5062
  });
@@ -5066,10 +5067,10 @@ var WebRTCEndpoint = class extends EventEmitter3 {
5066
5067
  this.emit("localTrackAdded", {
5067
5068
  trackId,
5068
5069
  track,
5069
- stream,
5070
+ stream: trackStream,
5070
5071
  trackMetadata,
5071
5072
  simulcastConfig,
5072
- maxBandwidth
5073
+ maxBandwidth: resolvedMaxBandwidth
5073
5074
  });
5074
5075
  return trackId;
5075
5076
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fishjam-cloud/webrtc-client",
3
- "version": "0.26.0-rc.0",
3
+ "version": "0.26.0",
4
4
  "description": "Typescript client library for ExWebRTC/WebRTC endpoint in Membrane RTC Engine",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Fishjam Team",