werift 0.15.4 → 0.15.5

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.
@@ -1 +1 @@
1
- {"version":3,"file":"ice.js","sourceRoot":"","sources":["../../../../src/transport/ice.ts"],"names":[],"mappings":";;;;;;AAAA,sDAA4B;AAC5B,+BAA0B;AAE1B,0CAAqE;AACrE,gCAA0D;AAE1D,MAAa,eAAe;IAS1B,YAAoB,MAAsB;QAAtB,WAAM,GAAN,MAAM,CAAgB;QARjC,OAAE,GAAG,IAAA,SAAE,GAAE,CAAC;QACnB,eAAU,GAAG,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC;QACpC,UAAK,GAA0B,KAAK,CAAC;QAE5B,kBAAa,GAAG,IAAI,iBAAK,EAA2B,CAAC;QAkC9D,uBAAkB,GAAG,KAAK,EAAE,SAAwB,EAAE,EAAE;YACtD,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,mBAAmB,EAAE;gBACxC,IAAI,CAAC,SAAS,EAAE;oBACd,MAAM,IAAI,CAAC,UAAU,CAAC,kBAAkB,CAAC,SAAS,CAAC,CAAC;iBACrD;qBAAM;oBACL,MAAM,IAAI,CAAC,UAAU,CAAC,kBAAkB,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC,CAAC;iBACrE;aACF;QACH,CAAC,CAAC;QArCA,IAAI,CAAC,UAAU,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC,KAAK,EAAE,EAAE;YAC/C,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;QACvB,CAAC,CAAC,CAAC;IACL,CAAC;IAED,IAAI,SAAS;QACX,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED,IAAI,IAAI;QACN,IAAI,IAAI,CAAC,UAAU,CAAC,cAAc;YAAE,OAAO,aAAa,CAAC;;YACpD,OAAO,YAAY,CAAC;IAC3B,CAAC;IAEO,QAAQ,CAAC,KAA4B;QAC3C,IAAI,KA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E;IACpB,CAAC;CACF;AAtCD,oCAsCC;AAED,MAAa,gBAAgB;IAK3B,YAAY,QAAmC,EAAE;QAJjD,YAAO,GAAY,KAAK,CAAC;QAKvB,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAC7B,CAAC;CACF;AARD,4CAQC","sourcesContent":["import Event from \"rx.mini\";\nimport { v4 } from \"uuid\";\n\nimport { Candidate, Connection, IceOptions } from \"../../../ice/src\";\nimport { candidateFromSdp, candidateToSdp } from \"../sdp\";\n\nexport class RTCIceTransport {\n readonly id = v4();\n connection = this.gather.connection;\n state: RTCIceConnectionState = \"new\";\n\n readonly onStateChange = new Event<[RTCIceConnectionState]>();\n\n private waitStart?: Event<[]>;\n\n constructor(private gather: RTCIceGatherer) {\n this.connection.stateChanged.subscribe((state) => {\n this.setState(state);\n });\n }\n\n get iceGather() {\n return this.gather;\n }\n\n get role() {\n if (this.connection.iceControlling) return \"controlling\";\n else return \"controlled\";\n }\n\n private setState(state: RTCIceConnectionState) {\n if (state !== this.state) {\n this.state = state;\n\n if (this.onStateChange.ended) return;\n\n if (state === \"closed\") {\n this.onStateChange.execute(state);\n this.onStateChange.complete();\n } else {\n this.onStateChange.execute(state);\n }\n }\n }\n\n addRemoteCandidate = async (candidate?: IceCandidate) => {\n if (!this.connection.remoteCandidatesEnd) {\n if (!candidate) {\n await this.connection.addRemoteCandidate(undefined);\n } else {\n await this.connection.addRemoteCandidate(candidateToIce(candidate));\n }\n }\n };\n\n setRemoteParams(remoteParameters: RTCIceParameters) {\n this.connection.remoteIsLite = remoteParameters.iceLite;\n this.connection.remoteUsername = remoteParameters.usernameFragment;\n this.connection.remotePassword = remoteParameters.password;\n }\n\n async start() {\n if (this.state === \"closed\") throw new Error(\"RTCIceTransport is closed\");\n if (!this.connection.remotePassword || !this.connection.remoteUsername)\n throw new Error(\"remoteParams missing\");\n\n if (this.waitStart) await this.waitStart.asPromise();\n this.waitStart = new Event();\n\n this.setState(\"checking\");\n\n try {\n await this.connection.connect();\n } catch (error) {\n this.setState(\"failed\");\n throw error;\n }\n\n this.waitStart.complete();\n }\n\n async stop() {\n if (this.state !== \"closed\") {\n this.setState(\"closed\");\n await this.connection.close();\n }\n }\n}\n\nexport const IceTransportStates = [\n \"new\",\n \"checking\",\n \"connected\",\n \"completed\",\n \"disconnected\",\n \"failed\",\n \"closed\",\n] as const;\nexport type RTCIceConnectionState = typeof IceTransportStates[number];\n\nexport const IceGathererStates = [\"new\", \"gathering\", \"complete\"] as const;\nexport type IceGathererState = typeof IceGathererStates[number];\n\nexport class RTCIceGatherer {\n onIceCandidate: (candidate: IceCandidate) => void = () => {};\n gatheringState: IceGathererState = \"new\";\n\n readonly onGatheringStateChange = new Event<[IceGathererState]>();\n readonly connection = new Connection(false, this.options);\n\n constructor(private options: Partial<IceOptions> = {}) {}\n\n async gather() {\n if (this.gatheringState === \"new\") {\n this.setState(\"gathering\");\n await this.connection.gatherCandidates((candidate) =>\n this.onIceCandidate(candidateFromIce(candidate))\n );\n this.setState(\"complete\");\n }\n }\n\n get localCandidates() {\n return this.connection.localCandidates.map(candidateFromIce);\n }\n\n get localParameters() {\n const params = new RTCIceParameters({\n usernameFragment: this.connection.localUserName,\n password: this.connection.localPassword,\n });\n\n return params;\n }\n\n private setState(state: IceGathererState) {\n if (state !== this.gatheringState) {\n this.gatheringState = state;\n this.onGatheringStateChange.execute(state);\n }\n }\n}\n\nexport function candidateFromIce(c: Candidate) {\n const candidate = new IceCandidate(\n c.component,\n c.foundation,\n c.host,\n c.port,\n c.priority,\n c.transport,\n c.type\n );\n candidate.relatedAddress = c.relatedAddress;\n candidate.relatedPort = c.relatedPort;\n candidate.tcpType = c.tcptype;\n return candidate;\n}\n\nexport function candidateToIce(x: IceCandidate) {\n return new Candidate(\n x.foundation,\n x.component,\n x.protocol,\n x.priority,\n x.ip,\n x.port,\n x.type,\n x.relatedAddress,\n x.relatedPort,\n x.tcpType\n );\n}\n\nexport class RTCIceCandidate {\n candidate!: string;\n sdpMid?: string;\n sdpMLineIndex?: number;\n\n constructor(props: Partial<RTCIceCandidate>) {\n Object.assign(this, props);\n }\n\n static isThis(o: any) {\n if (typeof o?.candidate === \"string\") return true;\n }\n\n toJSON() {\n return {\n candidate: this.candidate,\n sdpMid: this.sdpMid,\n sdpMLineIndex: this.sdpMLineIndex,\n };\n }\n}\n\nexport class IceCandidate {\n // \"\"\"\n // The :class:`RTCIceCandidate` interface represents a candidate Interactive\n // Connectivity Establishment (ICE) configuration which may be used to\n // establish an RTCPeerConnection.\n // \"\"\"\n public relatedAddress?: string;\n public relatedPort?: number;\n public sdpMid?: string;\n public sdpMLineIndex?: number;\n public tcpType?: string;\n\n constructor(\n public component: number,\n public foundation: string,\n public ip: string,\n public port: number,\n public priority: number,\n public protocol: string,\n public type: string\n ) {}\n\n toJSON(): RTCIceCandidate {\n return new RTCIceCandidate({\n candidate: candidateToSdp(this),\n sdpMLineIndex: this.sdpMLineIndex,\n sdpMid: this.sdpMid,\n });\n }\n\n static fromJSON(data: RTCIceCandidate) {\n try {\n const candidate = candidateFromSdp(data.candidate);\n candidate.sdpMLineIndex = data.sdpMLineIndex;\n candidate.sdpMid = data.sdpMid;\n return candidate;\n } catch (error) {}\n }\n}\n\nexport class RTCIceParameters {\n iceLite: boolean = false;\n usernameFragment!: string;\n password!: string;\n\n constructor(props: Partial<RTCIceParameters> = {}) {\n Object.assign(this, props);\n }\n}\n"]}
1
+ {"version":3,"file":"ice.js","sourceRoot":"","sources":["../../../../src/transport/ice.ts"],"names":[],"mappings":";;;;;;AAAA,sDAA4B;AAC5B,+BAA0B;AAE1B,0CAAqE;AACrE,gCAA0D;AAE1D,MAAa,eAAe;IAS1B,YAAoB,MAAsB;QAAtB,WAAM,GAAN,MAAM,CAAgB;QARjC,OAAE,GAAG,IAAA,SAAE,GAAE,CAAC;QACnB,eAAU,GAAG,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC;QACpC,UAAK,GAA0B,KAAK,CAAC;QAE5B,kB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EACZ,QAAgB,EAChB,QAAgB,EAChB,IAAY;QANZ,cAAS,GAAT,SAAS,CAAQ;QACjB,eAAU,GAAV,UAAU,CAAQ;QAClB,OAAE,GAAF,EAAE,CAAQ;QACV,SAAI,GAAJ,IAAI,CAAQ;QACZ,aAAQ,GAAR,QAAQ,CAAQ;QAChB,aAAQ,GAAR,QAAQ,CAAQ;QAChB,SAAI,GAAJ,IAAI,CAAQ;IAClB,CAAC;IAEJ,MAAM;QACJ,OAAO,IAAI,eAAe,CAAC;YACzB,SAAS,EAAE,IAAA,oBAAc,EAAC,IAAI,CAAC;YAC/B,aAAa,EAAE,IAAI,CAAC,aAAa;YACjC,MAAM,EAAE,IAAI,CAAC,MAAM;SACpB,CAAC,CAAC;IACL,CAAC;IAED,MAAM,CAAC,QAAQ,CAAC,IAAqB;QACnC,IAAI;YACF,MAAM,SAAS,GAAG,IAAA,sBAAgB,EAAC,IAAI,CAAC,SAAS,CAAC,CAAC;YACnD,SAAS,CAAC,aAAa,GAAG,IAAI,CAAC,aAAa,CAAC;YAC7C,SAAS,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;YAC/B,OAAO,SAAS,CAAC;SAClB;QAAC,OAAO,KAAK,EAAE,GAAE;IACpB,CAAC;CACF;AAtCD,oCAsCC;AAED,MAAa,gBAAgB;IAK3B,YAAY,QAAmC,EAAE;QAJjD,YAAO,GAAY,KAAK,CAAC;QAKvB,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAC7B,CAAC;CACF;AARD,4CAQC","sourcesContent":["import Event from \"rx.mini\";\nimport { v4 } from \"uuid\";\n\nimport { Candidate, Connection, IceOptions } from \"../../../ice/src\";\nimport { candidateFromSdp, candidateToSdp } from \"../sdp\";\n\nexport class RTCIceTransport {\n readonly id = v4();\n connection = this.gather.connection;\n state: RTCIceConnectionState = \"new\";\n\n readonly onStateChange = new Event<[RTCIceConnectionState]>();\n\n private waitStart?: Event<[]>;\n\n constructor(private gather: RTCIceGatherer) {\n this.connection.stateChanged.subscribe((state) => {\n this.setState(state);\n });\n }\n\n get iceGather() {\n return this.gather;\n }\n\n get role() {\n if (this.connection.iceControlling) return \"controlling\";\n else return \"controlled\";\n }\n\n private setState(state: RTCIceConnectionState) {\n if (state !== this.state) {\n this.state = state;\n\n if (this.onStateChange.ended) return;\n\n if (state === \"closed\") {\n this.onStateChange.execute(state);\n this.onStateChange.complete();\n } else {\n this.onStateChange.execute(state);\n }\n }\n }\n\n addRemoteCandidate = (candidate?: IceCandidate) => {\n if (!this.connection.remoteCandidatesEnd) {\n if (!candidate) {\n return this.connection.addRemoteCandidate(undefined);\n } else {\n return this.connection.addRemoteCandidate(candidateToIce(candidate));\n }\n }\n };\n\n setRemoteParams(remoteParameters: RTCIceParameters) {\n this.connection.remoteIsLite = remoteParameters.iceLite;\n this.connection.remoteUsername = remoteParameters.usernameFragment;\n this.connection.remotePassword = remoteParameters.password;\n }\n\n async start() {\n if (this.state === \"closed\") throw new Error(\"RTCIceTransport is closed\");\n if (!this.connection.remotePassword || !this.connection.remoteUsername)\n throw new Error(\"remoteParams missing\");\n\n if (this.waitStart) await this.waitStart.asPromise();\n this.waitStart = new Event();\n\n this.setState(\"checking\");\n\n try {\n await this.connection.connect();\n } catch (error) {\n this.setState(\"failed\");\n throw error;\n }\n\n this.waitStart.complete();\n }\n\n async stop() {\n if (this.state !== \"closed\") {\n this.setState(\"closed\");\n await this.connection.close();\n }\n }\n}\n\nexport const IceTransportStates = [\n \"new\",\n \"checking\",\n \"connected\",\n \"completed\",\n \"disconnected\",\n \"failed\",\n \"closed\",\n] as const;\nexport type RTCIceConnectionState = typeof IceTransportStates[number];\n\nexport const IceGathererStates = [\"new\", \"gathering\", \"complete\"] as const;\nexport type IceGathererState = typeof IceGathererStates[number];\n\nexport class RTCIceGatherer {\n onIceCandidate: (candidate: IceCandidate) => void = () => {};\n gatheringState: IceGathererState = \"new\";\n\n readonly onGatheringStateChange = new Event<[IceGathererState]>();\n readonly connection = new Connection(false, this.options);\n\n constructor(private options: Partial<IceOptions> = {}) {}\n\n async gather() {\n if (this.gatheringState === \"new\") {\n this.setState(\"gathering\");\n await this.connection.gatherCandidates((candidate) =>\n this.onIceCandidate(candidateFromIce(candidate))\n );\n this.setState(\"complete\");\n }\n }\n\n get localCandidates() {\n return this.connection.localCandidates.map(candidateFromIce);\n }\n\n get localParameters() {\n const params = new RTCIceParameters({\n usernameFragment: this.connection.localUserName,\n password: this.connection.localPassword,\n });\n\n return params;\n }\n\n private setState(state: IceGathererState) {\n if (state !== this.gatheringState) {\n this.gatheringState = state;\n this.onGatheringStateChange.execute(state);\n }\n }\n}\n\nexport function candidateFromIce(c: Candidate) {\n const candidate = new IceCandidate(\n c.component,\n c.foundation,\n c.host,\n c.port,\n c.priority,\n c.transport,\n c.type\n );\n candidate.relatedAddress = c.relatedAddress;\n candidate.relatedPort = c.relatedPort;\n candidate.tcpType = c.tcptype;\n return candidate;\n}\n\nexport function candidateToIce(x: IceCandidate) {\n return new Candidate(\n x.foundation,\n x.component,\n x.protocol,\n x.priority,\n x.ip,\n x.port,\n x.type,\n x.relatedAddress,\n x.relatedPort,\n x.tcpType\n );\n}\n\nexport class RTCIceCandidate {\n candidate!: string;\n sdpMid?: string;\n sdpMLineIndex?: number;\n\n constructor(props: Partial<RTCIceCandidate>) {\n Object.assign(this, props);\n }\n\n static isThis(o: any) {\n if (typeof o?.candidate === \"string\") return true;\n }\n\n toJSON() {\n return {\n candidate: this.candidate,\n sdpMid: this.sdpMid,\n sdpMLineIndex: this.sdpMLineIndex,\n };\n }\n}\n\nexport class IceCandidate {\n // \"\"\"\n // The :class:`RTCIceCandidate` interface represents a candidate Interactive\n // Connectivity Establishment (ICE) configuration which may be used to\n // establish an RTCPeerConnection.\n // \"\"\"\n public relatedAddress?: string;\n public relatedPort?: number;\n public sdpMid?: string;\n public sdpMLineIndex?: number;\n public tcpType?: string;\n\n constructor(\n public component: number,\n public foundation: string,\n public ip: string,\n public port: number,\n public priority: number,\n public protocol: string,\n public type: string\n ) {}\n\n toJSON(): RTCIceCandidate {\n return new RTCIceCandidate({\n candidate: candidateToSdp(this),\n sdpMLineIndex: this.sdpMLineIndex,\n sdpMid: this.sdpMid,\n });\n }\n\n static fromJSON(data: RTCIceCandidate) {\n try {\n const candidate = candidateFromSdp(data.candidate);\n candidate.sdpMLineIndex = data.sdpMLineIndex;\n candidate.sdpMid = data.sdpMid;\n return candidate;\n } catch (error) {}\n }\n}\n\nexport class RTCIceParameters {\n iceLite: boolean = false;\n usernameFragment!: string;\n password!: string;\n\n constructor(props: Partial<RTCIceParameters> = {}) {\n Object.assign(this, props);\n }\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "werift",
3
- "version": "0.15.4",
3
+ "version": "0.15.5",
4
4
  "description": "WebRTC Implementation for TypeScript (Node.js)",
5
5
  "keywords": [
6
6
  "WebRTC",
@@ -434,24 +434,32 @@ export class RTCPeerConnection extends EventTarget {
434
434
 
435
435
  iceTransport.iceGather.onIceCandidate = (candidate) => {
436
436
  if (!this.localDescription) return;
437
- const transceiver = this.transceivers.find(
438
- (t) => t.dtlsTransport.iceTransport.id === iceTransport.id
439
- );
440
- if (transceiver) {
441
- candidate.sdpMLineIndex = transceiver.mLineIndex;
442
- candidate.sdpMid = transceiver.mid;
443
- }
444
- if (
445
- this.sctpTransport?.dtlsTransport.iceTransport.id === iceTransport.id
446
- ) {
447
- candidate.sdpMLineIndex = this.sctpTransport.mLineIndex;
448
- candidate.sdpMid = this.sctpTransport.mid;
437
+
438
+ if (this.configuration.bundlePolicy === "max-bundle") {
439
+ candidate.sdpMLineIndex = 0;
440
+ candidate.sdpMid = this._localDescription?.media[0].rtp.muxId;
441
+ } else {
442
+ const transceiver = this.transceivers.find(
443
+ (t) => t.dtlsTransport.iceTransport.id === iceTransport.id
444
+ );
445
+ if (transceiver) {
446
+ candidate.sdpMLineIndex = transceiver.mLineIndex;
447
+ candidate.sdpMid = transceiver.mid;
448
+ }
449
+ if (
450
+ this.sctpTransport?.dtlsTransport.iceTransport.id === iceTransport.id
451
+ ) {
452
+ candidate.sdpMLineIndex = this.sctpTransport.mLineIndex;
453
+ candidate.sdpMid = this.sctpTransport.mid;
454
+ }
449
455
  }
456
+
450
457
  candidate.foundation = "candidate:" + candidate.foundation;
451
458
 
452
459
  this.onIceCandidate.execute(candidate.toJSON());
453
- if (this.onicecandidate)
460
+ if (this.onicecandidate) {
454
461
  this.onicecandidate({ candidate: candidate.toJSON() });
462
+ }
455
463
  this.emit("icecandidate", { candidate });
456
464
  };
457
465
 
@@ -556,6 +564,15 @@ export class RTCPeerConnection extends EventTarget {
556
564
  // for trickle ice
557
565
  this.setLocal(description);
558
566
 
567
+ // connect transports
568
+ if (description.type === "answer") {
569
+ log("callee start connect");
570
+ this.connect().catch((err) => {
571
+ log("connect failed", err);
572
+ this.setConnectionState("failed");
573
+ });
574
+ }
575
+
559
576
  // # gather candidates
560
577
  await Promise.all(
561
578
  this.iceTransports.map((iceTransport) => iceTransport.iceGather.gather())
@@ -573,15 +590,6 @@ export class RTCPeerConnection extends EventTarget {
573
590
 
574
591
  this.setLocal(description);
575
592
 
576
- // connect transports
577
- if (description.type === "answer") {
578
- log("callee start connect");
579
- this.connect().catch((err) => {
580
- log("connect failed", err);
581
- this.setConnectionState("failed");
582
- });
583
- }
584
-
585
593
  if (this.shouldNegotiationneeded) {
586
594
  this.needNegotiation();
587
595
  }
@@ -750,86 +758,90 @@ export class RTCPeerConnection extends EventTarget {
750
758
  let bundleTransport: RTCDtlsTransport | undefined;
751
759
 
752
760
  // # apply description
753
- await Promise.all(
754
- enumerate(remoteSdp.media).map(async ([i, remoteMedia]) => {
755
- let dtlsTransport: RTCDtlsTransport | undefined;
756
-
757
- if (["audio", "video"].includes(remoteMedia.kind)) {
758
- let transceiver = this.transceivers.find(
759
- (t) =>
760
- t.kind === remoteMedia.kind &&
761
- [undefined, remoteMedia.rtp.muxId].includes(t.mid)
762
- );
763
- if (!transceiver) {
764
- // create remote transceiver
765
- transceiver = this.addTransceiver(remoteMedia.kind, {
766
- direction: "recvonly",
767
- });
768
- transceiver.mid = remoteMedia.rtp.muxId;
769
- this.onRemoteTransceiverAdded.execute(transceiver);
770
- }
771
761
 
772
- if (bundle) {
773
- if (!bundleTransport) {
774
- bundleTransport = transceiver.dtlsTransport;
775
- } else {
776
- transceiver.setDtlsTransport(bundleTransport);
777
- }
778
- }
762
+ const transports = enumerate(remoteSdp.media).map(([i, remoteMedia]) => {
763
+ let dtlsTransport: RTCDtlsTransport | undefined;
779
764
 
780
- dtlsTransport = transceiver.dtlsTransport;
765
+ if (["audio", "video"].includes(remoteMedia.kind)) {
766
+ let transceiver = this.transceivers.find(
767
+ (t) =>
768
+ t.kind === remoteMedia.kind &&
769
+ [undefined, remoteMedia.rtp.muxId].includes(t.mid)
770
+ );
771
+ if (!transceiver) {
772
+ // create remote transceiver
773
+ transceiver = this.addTransceiver(remoteMedia.kind, {
774
+ direction: "recvonly",
775
+ });
776
+ transceiver.mid = remoteMedia.rtp.muxId;
777
+ this.onRemoteTransceiverAdded.execute(transceiver);
778
+ }
781
779
 
782
- this.setRemoteRTP(transceiver, remoteMedia, remoteSdp.type, i);
783
- } else if (remoteMedia.kind === "application") {
784
- if (!this.sctpTransport) {
785
- this.sctpTransport = this.createSctpTransport();
786
- this.sctpTransport.mid = remoteMedia.rtp.muxId;
780
+ if (bundle) {
781
+ if (!bundleTransport) {
782
+ bundleTransport = transceiver.dtlsTransport;
783
+ } else {
784
+ transceiver.setDtlsTransport(bundleTransport);
787
785
  }
786
+ }
788
787
 
789
- if (bundle) {
790
- if (!bundleTransport) {
791
- bundleTransport = this.sctpTransport.dtlsTransport;
792
- } else {
793
- this.sctpTransport.setDtlsTransport(bundleTransport);
794
- }
795
- }
788
+ dtlsTransport = transceiver.dtlsTransport;
796
789
 
797
- dtlsTransport = this.sctpTransport.dtlsTransport;
790
+ this.setRemoteRTP(transceiver, remoteMedia, remoteSdp.type, i);
791
+ } else if (remoteMedia.kind === "application") {
792
+ if (!this.sctpTransport) {
793
+ this.sctpTransport = this.createSctpTransport();
794
+ this.sctpTransport.mid = remoteMedia.rtp.muxId;
795
+ }
798
796
 
799
- this.setRemoteSCTP(remoteMedia, this.sctpTransport, i);
800
- } else {
801
- throw new Error("invalid media kind");
797
+ if (bundle) {
798
+ if (!bundleTransport) {
799
+ bundleTransport = this.sctpTransport.dtlsTransport;
800
+ } else {
801
+ this.sctpTransport.setDtlsTransport(bundleTransport);
802
+ }
802
803
  }
803
804
 
804
- const iceTransport = dtlsTransport.iceTransport;
805
+ dtlsTransport = this.sctpTransport.dtlsTransport;
805
806
 
806
- if (remoteMedia.iceParams && remoteMedia.dtlsParams) {
807
- iceTransport.setRemoteParams(remoteMedia.iceParams);
808
- dtlsTransport.setRemoteParams(remoteMedia.dtlsParams);
807
+ this.setRemoteSCTP(remoteMedia, this.sctpTransport, i);
808
+ } else {
809
+ throw new Error("invalid media kind");
810
+ }
809
811
 
810
- // One agent full, one lite: The full agent MUST take the controlling role, and the lite agent MUST take the controlled role
811
- // RFC 8445 S6.1.1
812
- if (remoteMedia.iceParams?.iceLite) {
813
- iceTransport.connection.iceControlling = true;
814
- }
812
+ const iceTransport = dtlsTransport.iceTransport;
813
+
814
+ if (remoteMedia.iceParams && remoteMedia.dtlsParams) {
815
+ iceTransport.setRemoteParams(remoteMedia.iceParams);
816
+ dtlsTransport.setRemoteParams(remoteMedia.dtlsParams);
817
+
818
+ // One agent full, one lite: The full agent MUST take the controlling role, and the lite agent MUST take the controlled role
819
+ // RFC 8445 S6.1.1
820
+ if (remoteMedia.iceParams?.iceLite) {
821
+ iceTransport.connection.iceControlling = true;
815
822
  }
823
+ }
816
824
 
817
- // # add ICE candidates
818
- remoteMedia.iceCandidates.forEach(iceTransport.addRemoteCandidate);
825
+ // # add ICE candidates
826
+ remoteMedia.iceCandidates.forEach(iceTransport.addRemoteCandidate);
819
827
 
820
- await iceTransport.iceGather.gather();
828
+ if (remoteMedia.iceCandidatesComplete) {
829
+ iceTransport.addRemoteCandidate(undefined);
830
+ }
821
831
 
822
- if (remoteMedia.iceCandidatesComplete) {
823
- await iceTransport.addRemoteCandidate(undefined);
824
- }
832
+ // # set DTLS role
833
+ if (remoteSdp.type === "answer" && remoteMedia.dtlsParams?.role) {
834
+ dtlsTransport.role =
835
+ remoteMedia.dtlsParams.role === "client" ? "server" : "client";
836
+ }
837
+ return iceTransport;
838
+ });
825
839
 
826
- // # set DTLS role
827
- if (remoteSdp.type === "answer" && remoteMedia.dtlsParams?.role) {
828
- dtlsTransport.role =
829
- remoteMedia.dtlsParams.role === "client" ? "server" : "client";
830
- }
831
- })
832
- );
840
+ if (remoteSdp.type === "offer") {
841
+ this.setSignalingState("have-remote-offer");
842
+ } else if (remoteSdp.type === "answer") {
843
+ this.setSignalingState("stable");
844
+ }
833
845
 
834
846
  // connect transports
835
847
  if (remoteSdp.type === "answer") {
@@ -840,11 +852,11 @@ export class RTCPeerConnection extends EventTarget {
840
852
  });
841
853
  }
842
854
 
843
- if (remoteSdp.type === "offer") {
844
- this.setSignalingState("have-remote-offer");
845
- } else if (remoteSdp.type === "answer") {
846
- this.setSignalingState("stable");
847
- }
855
+ await Promise.all(
856
+ transports.map(async (iceTransport) => {
857
+ await iceTransport.iceGather.gather();
858
+ })
859
+ );
848
860
 
849
861
  this.negotiationneeded = false;
850
862
  if (this.shouldNegotiationneeded) {
@@ -1140,6 +1152,12 @@ export class RTCPeerConnection extends EventTarget {
1140
1152
  }
1141
1153
 
1142
1154
  async createAnswer() {
1155
+ await this.ensureCerts();
1156
+ const description = this.buildAnswer();
1157
+ return description.toJSON();
1158
+ }
1159
+
1160
+ private buildAnswer() {
1143
1161
  this.assertNotClosed();
1144
1162
  if (
1145
1163
  !["have-remote-offer", "have-local-pranswer"].includes(
@@ -1152,8 +1170,6 @@ export class RTCPeerConnection extends EventTarget {
1152
1170
  throw new Error("wrong state");
1153
1171
  }
1154
1172
 
1155
- await this.ensureCerts();
1156
-
1157
1173
  const description = new SessionDescription();
1158
1174
  addSDPHeader("answer", description);
1159
1175
 
@@ -1206,7 +1222,7 @@ export class RTCPeerConnection extends EventTarget {
1206
1222
  description.group.push(bundle);
1207
1223
  }
1208
1224
 
1209
- return description.toJSON();
1225
+ return description;
1210
1226
  }
1211
1227
 
1212
1228
  async close() {
@@ -43,12 +43,12 @@ export class RTCIceTransport {
43
43
  }
44
44
  }
45
45
 
46
- addRemoteCandidate = async (candidate?: IceCandidate) => {
46
+ addRemoteCandidate = (candidate?: IceCandidate) => {
47
47
  if (!this.connection.remoteCandidatesEnd) {
48
48
  if (!candidate) {
49
- await this.connection.addRemoteCandidate(undefined);
49
+ return this.connection.addRemoteCandidate(undefined);
50
50
  } else {
51
- await this.connection.addRemoteCandidate(candidateToIce(candidate));
51
+ return this.connection.addRemoteCandidate(candidateToIce(candidate));
52
52
  }
53
53
  }
54
54
  };