From e8c62bd430b9697d3f954125b7ec9f61f18347a2 Mon Sep 17 00:00:00 2001
From: WXL (wul) <wl_5969728@163.com>
Date: 星期一, 20 十月 2025 11:19:34 +0800
Subject: [PATCH] 测试完成
---
src/utils/sipService-cs.js | 64 ++++++++++++++++++++++++++++----
1 files changed, 56 insertions(+), 8 deletions(-)
diff --git a/src/utils/sipService-zs.js b/src/utils/sipService-cs.js
similarity index 78%
rename from src/utils/sipService-zs.js
rename to src/utils/sipService-cs.js
index dbc4a4e..0cfc572 100644
--- a/src/utils/sipService-zs.js
+++ b/src/utils/sipService-cs.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) {
--
Gitblit v1.9.3