WXL (wul)
21 小时以前 38d3a2b23df5d7fea47d3260cfc19e803dc40863
src/utils/sipService-cs.js
ÎļþÃû´Ó src/utils/sipService-zs.js ÐÞ¸Ä
@@ -99,13 +99,26 @@
        }
        const options = {
          sessionTimers: true, // å¯ç”¨ä¼šè¯è®¡æ—¶å™¨
          sessionTimersExpires: 150,
          extraHeaders: ["Accept: application/sdp"],
          mediaConstraints: { audio: true, video: false },
          sessionTimers: true,
          sessionTimersExpires: 300,
          extraHeaders: [
            "Min-SE: 120",
            "Route: <sip:@192.168.100.6>",
            "Accept: application/sdp",
            "Supported: replaces, timer",
            "Allow: INVITE, ACK, BYE, CANCEL, OPTIONS",
          ],
          mediaConstraints: {
            audio: true,
            video: false,
          },
          rtcOfferConstraints: {
            offerToReceiveAudio: true,
            offerToReceiveVideo: false,
            offerToReceiveAudio: 1,
            offerToReceiveVideo: 0,
            mandatory: {
              OfferToReceiveAudio: true,
              OfferToReceiveVideo: false,
            },
          },
          eventHandlers: {
            progress: () => this.updateCallStatus("calling", "呼叫中..."),
@@ -118,13 +131,48 @@
              resolve();
            },
          },
          pcConfig: {
            iceServers: [{ urls: "stun:stun.l.google.com:19302" }],
            iceTransportPolicy: "all",
            bundlePolicy: "balanced",
            rtcpMuxPolicy: "require",
            codecs: {
              audio: [
                { name: "PCMU", clockRate: 8000, payloadType: 0 },
                { name: "PCMA", clockRate: 8000, payloadType: 8 },
              ],
              video: [],
            },
          },
        };
        this.currentSession = this.ua.call(
          `sip:${targetNumber}@1192.170.66.107`,
          `sip:${targetNumber}@192.168.100.6`,
          options
        );
        // åœ¨ä¼šè¯åˆ›å»ºåŽä¿®æ”¹ SDP
        this.currentSession.on("peerconnection", (pc) => {
          this.updateCallStatus("calling", "呼叫中...");
          pc.createOffer = (offerOptions) => {
            return RTCPeerConnection.prototype.createOffer
              .call(pc, offerOptions)
              .then((offer) => {
                const modifiedSdp = offer.sdp
                  .replace(
                    /c=IN IP4 192\.168\.100\.10/g,
                    "c=IN IP4 192.168.100.6"
                  )
                  .replace(
                    /m=audio \d+ RTP\/AVP.*/,
                    "m=audio 7078 RTP/AVP 0 8"
                  );
                return new RTCSessionDescription({
                  type: "offer",
                  sdp: modifiedSdp,
                });
              });
          };
        });
        this.setupPeerConnection(this.currentSession);
        this.setupAudio(this.currentSession);
      } catch (error) {