@fishjam-cloud/webrtc-client 0.26.0-rc.0 → 0.26.0-rc.1

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
@@ -4152,9 +4152,9 @@ var LocalTrack = class {
4152
4152
  const stream = this.trackContext.stream;
4153
4153
  const oldTrack = this.trackContext.track;
4154
4154
  if (!this.sender) throw Error("There is no RTCRtpSender for this track id!");
4155
- stream?.getTracks().forEach((track) => {
4156
- stream?.removeTrack(track);
4157
- });
4155
+ if (oldTrack) {
4156
+ stream?.removeTrack(oldTrack);
4157
+ }
4158
4158
  if (newTrack) {
4159
4159
  stream?.addTrack(newTrack);
4160
4160
  }
@@ -4999,10 +4999,8 @@ var WebRTCEndpoint = class extends EventEmitter3 {
4999
4999
  * @param trackMetadata - Any information about this track that other endpoints will
5000
5000
  * receive in {@link WebRTCEndpointEvents.endpointAdded}. E.g. this can source of the track - whether it's
5001
5001
  * 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**:
5002
+ * @param simulcastConfig - Simulcast configuration. For more information refer to {@link SimulcastConfig}.
5003
+ * @param maxBandwidth - maximal bandwidth this track can use. **Currently processed with a threshold check**:
5006
5004
  * if the value is a positive number, it will be used; otherwise, it defaults to 0 (unlimited).
5007
5005
  * This option has no effect for simulcast and audio tracks.
5008
5006
  * For simulcast tracks use `{@link WebRTCEndpoint.setTrackBandwidth}.
@@ -5037,25 +5035,27 @@ var WebRTCEndpoint = class extends EventEmitter3 {
5037
5035
  * .forEach((track) => webrtc.addTrack(track, localStream));
5038
5036
  * ```
5039
5037
  */
5040
- async addTrack(track, trackMetadata, _simulcastConfig = {
5038
+ async addTrack(track, trackMetadata, simulcastConfig = {
5041
5039
  enabled: false,
5042
5040
  enabledVariants: [],
5043
5041
  disabledVariants: []
5044
- }, _maxBandwidth = 0) {
5042
+ }, maxBandwidth = 0, stream) {
5045
5043
  const resolutionNotifier = new Deferred();
5046
5044
  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;
5045
+ const trackStream = stream ?? new MediaStream();
5046
+ const resolvedMaxBandwidth = typeof maxBandwidth === "number" && maxBandwidth > 0 ? maxBandwidth : 0;
5054
5047
  try {
5055
- stream.addTrack(track);
5048
+ if (!stream) trackStream.addTrack(track);
5056
5049
  this.commandsQueue.pushCommand({
5057
- handler: async () => this.localTrackManager.addTrackHandler(trackId, track, stream, trackMetadata, simulcastConfig, maxBandwidth),
5058
- parse: () => this.localTrackManager.parseAddTrack(track, simulcastConfig, maxBandwidth),
5050
+ handler: async () => this.localTrackManager.addTrackHandler(
5051
+ trackId,
5052
+ track,
5053
+ trackStream,
5054
+ trackMetadata,
5055
+ simulcastConfig,
5056
+ resolvedMaxBandwidth
5057
+ ),
5058
+ parse: () => this.localTrackManager.parseAddTrack(track, simulcastConfig, resolvedMaxBandwidth),
5059
5059
  resolve: "after-renegotiation",
5060
5060
  resolutionNotifier
5061
5061
  });
@@ -5066,10 +5066,10 @@ var WebRTCEndpoint = class extends EventEmitter3 {
5066
5066
  this.emit("localTrackAdded", {
5067
5067
  trackId,
5068
5068
  track,
5069
- stream,
5069
+ stream: trackStream,
5070
5070
  trackMetadata,
5071
5071
  simulcastConfig,
5072
- maxBandwidth
5072
+ maxBandwidth: resolvedMaxBandwidth
5073
5073
  });
5074
5074
  return trackId;
5075
5075
  }
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-rc.1",
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",