From 102e826aaef1ea682a63da8ee40fbf267711ba22 Mon Sep 17 00:00:00 2001
From: 罗广辉 <guanghui.luo@foxmail.com>
Date: Mon, 09 Feb 2026 10:22:01 +0800
Subject: [PATCH] feat: 音频通话注释

---
 applications/drone-command/src/views/audioCall.vue |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/applications/drone-command/src/views/audioCall.vue b/applications/drone-command/src/views/audioCall.vue
index 90910ac..ff1cdd2 100644
--- a/applications/drone-command/src/views/audioCall.vue
+++ b/applications/drone-command/src/views/audioCall.vue
@@ -126,6 +126,7 @@
 		}
 	}
 
+	// 步骤7 接收音频流并且播放
 	pc.ontrack = (e) => {
 		log('✅ 收到远端音频流')
 		const stream = e.streams[0]
@@ -167,6 +168,7 @@
 		pc.getSenders().map(s => (s.track ? s.track.id : null)).filter(Boolean)
 	)
 
+	// 步骤6 发送音频流
 	stream.getTracks().forEach(track => {
 		if (!existingTrackIds.has(track.id)) {
 			pc.addTrack(track, stream)
@@ -179,6 +181,7 @@
 	return stream
 }
 
+// 步骤5
 async function flushCandidates() {
 	if (!pc || !pc.remoteDescription) return
 	while (pendingCandidates.length) {
@@ -235,6 +238,7 @@
 		return
 	}
 
+	// 步骤2
 	if (t === 'offer') {
 		// 被叫收到 offer:只有点击接听后才真正应答(你要求“先点接听”)
 		offeredByPeer = true
@@ -254,10 +258,12 @@
 		return
 	}
 
+	// 步骤3
 	if (t === 'answer') {
 		log('✅ 收到 answer,通话建立')
 		if (!pc) createPC()
 		await pc.setRemoteDescription(new RTCSessionDescription(msg.payload?.sdp))
+		// 步骤4
 		await flushCandidates()
 
 		state.value = 'in-call'
@@ -368,6 +374,7 @@
 	// ✅ 不会重复 addTrack
 	await ensureLocalTracksAdded()
 
+	// 步骤1
 	const offer = await pc.createOffer()
 	await pc.setLocalDescription(offer)
 
@@ -375,6 +382,7 @@
 	log('➡️ 已发送 offer 给', peerUid.value)
 }
 
+// 步骤2
 async function answerOffer(offerSdp, from) {
 	if (!offerSdp) {
 		log('❌ offer sdp 为空,无法接听')
@@ -436,4 +444,3 @@
 	if (ws) ws.close()
 })
 </script>
-  
\ No newline at end of file

--
Gitblit v1.9.3