ÎļþÃû´Ó src/utils/sipService-zs.js ÐÞ¸Ä |
| | |
| | | } |
| | | |
| | | 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", "å¼å«ä¸..."), |
| | |
| | | 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) { |