-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy patharchitecture.html
More file actions
342 lines (300 loc) · 16.8 KB
/
Copy patharchitecture.html
File metadata and controls
342 lines (300 loc) · 16.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
<!doctype html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>HTTPMediaCache Architecture</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;600;700&display=swap" rel="stylesheet">
<style>
:root {
color-scheme: dark;
--bg: #020617;
--panel: #0f172a;
--line: #64748b;
--text: #e2e8f0;
--muted: #94a3b8;
--cyan: #22d3ee;
--emerald: #34d399;
--violet: #a78bfa;
--amber: #fbbf24;
--orange: #fb923c;
--rose: #fb7185;
--slate: #94a3b8;
}
* {
box-sizing: border-box;
}
body {
margin: 0;
min-height: 100vh;
background: radial-gradient(circle at 20% 0%, rgba(34, 211, 238, 0.12), transparent 28%),
radial-gradient(circle at 80% 0%, rgba(167, 139, 250, 0.12), transparent 30%),
var(--bg);
color: var(--text);
font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}
main {
width: min(1180px, calc(100vw - 32px));
margin: 0 auto;
padding: 36px 0 28px;
}
header {
display: flex;
align-items: center;
justify-content: space-between;
gap: 24px;
margin-bottom: 22px;
}
h1 {
margin: 0;
font-size: 28px;
letter-spacing: 0;
}
.subtitle {
margin: 8px 0 0;
color: var(--muted);
font-size: 13px;
}
.status {
display: inline-flex;
align-items: center;
gap: 9px;
color: var(--emerald);
font-size: 12px;
white-space: nowrap;
}
.pulse {
width: 10px;
height: 10px;
border-radius: 999px;
background: var(--emerald);
box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.6);
animation: pulse 1.8s infinite;
}
@keyframes pulse {
70% { box-shadow: 0 0 0 12px rgba(52, 211, 153, 0); }
100% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0); }
}
.diagram-card {
border: 1px solid rgba(148, 163, 184, 0.28);
border-radius: 12px;
background: rgba(15, 23, 42, 0.78);
overflow: hidden;
box-shadow: 0 24px 80px rgba(0, 0, 0, 0.35);
}
svg {
display: block;
width: 100%;
height: auto;
}
.cards {
display: grid;
grid-template-columns: repeat(3, minmax(0, 1fr));
gap: 14px;
margin-top: 16px;
}
.card {
border: 1px solid rgba(148, 163, 184, 0.2);
border-radius: 10px;
background: rgba(15, 23, 42, 0.72);
padding: 16px;
}
.card-header {
display: flex;
align-items: center;
gap: 9px;
margin-bottom: 10px;
}
.card-dot {
width: 9px;
height: 9px;
border-radius: 999px;
}
.card h3 {
margin: 0;
font-size: 13px;
}
.card ul {
margin: 0;
padding: 0;
list-style: none;
color: var(--muted);
font-size: 11px;
line-height: 1.85;
}
footer {
margin-top: 18px;
color: #64748b;
font-size: 11px;
text-align: center;
}
@media (max-width: 820px) {
header {
display: block;
}
.status {
margin-top: 14px;
}
.cards {
grid-template-columns: 1fr;
}
}
</style>
</head>
<body>
<main>
<header>
<div>
<h1>HTTPMediaCache Architecture</h1>
<p class="subtitle">Swift-only local HTTP media cache: proxy playback, preload, HLS rewrite, byte range storage.</p>
</div>
<div class="status"><span class="pulse"></span>1.0.2 public API surface</div>
</header>
<section class="diagram-card" aria-label="HTTPMediaCache architecture diagram">
<svg viewBox="0 0 1120 760" role="img" aria-labelledby="title desc" xmlns="http://www.w3.org/2000/svg">
<title id="title">HTTPMediaCache module architecture</title>
<desc id="desc">Architecture diagram showing app, API, runtime, proxy, HLS, pipeline, storage, and network modules.</desc>
<defs>
<pattern id="grid" width="40" height="40" patternUnits="userSpaceOnUse">
<path d="M 40 0 L 0 0 0 40" fill="none" stroke="#1e293b" stroke-width="0.5"/>
</pattern>
<marker id="arrowhead" markerWidth="10" markerHeight="7" refX="9" refY="3.5" orient="auto">
<polygon points="0 0, 10 3.5, 0 7" fill="#64748b"/>
</marker>
<marker id="arrowhead-cyan" markerWidth="10" markerHeight="7" refX="9" refY="3.5" orient="auto">
<polygon points="0 0, 10 3.5, 0 7" fill="#22d3ee"/>
</marker>
<marker id="arrowhead-rose" markerWidth="10" markerHeight="7" refX="9" refY="3.5" orient="auto">
<polygon points="0 0, 10 3.5, 0 7" fill="#fb7185"/>
</marker>
</defs>
<rect width="1120" height="760" fill="#020617"/>
<rect width="1120" height="760" fill="url(#grid)"/>
<path d="M 180 178 C 240 178, 250 115, 310 115" fill="none" stroke="#64748b" stroke-width="1.5" marker-end="url(#arrowhead)"/>
<path d="M 180 287 C 240 287, 250 115, 310 115" fill="none" stroke="#64748b" stroke-width="1.5" marker-end="url(#arrowhead)"/>
<path d="M 470 115 L 560 115" fill="none" stroke="#64748b" stroke-width="1.5" marker-end="url(#arrowhead)"/>
<path d="M 635 155 L 635 218" fill="none" stroke="#64748b" stroke-width="1.5" marker-end="url(#arrowhead)"/>
<path d="M 710 115 L 820 115" fill="none" stroke="#22d3ee" stroke-width="1.8" marker-end="url(#arrowhead-cyan)"/>
<path d="M 940 115 C 1010 115, 1010 210, 945 230" fill="none" stroke="#64748b" stroke-width="1.5" marker-end="url(#arrowhead)"/>
<path d="M 860 270 L 860 345" fill="none" stroke="#64748b" stroke-width="1.5" marker-end="url(#arrowhead)"/>
<path d="M 560 278 C 500 278, 475 385, 430 385" fill="none" stroke="#64748b" stroke-width="1.5" marker-end="url(#arrowhead)"/>
<path d="M 560 278 C 510 278, 500 490, 430 490" fill="none" stroke="#64748b" stroke-width="1.5" marker-end="url(#arrowhead)"/>
<path d="M 710 270 C 760 270, 790 370, 820 385" fill="none" stroke="#64748b" stroke-width="1.5" marker-end="url(#arrowhead)"/>
<path d="M 710 270 C 760 270, 790 478, 820 490" fill="none" stroke="#64748b" stroke-width="1.5" marker-end="url(#arrowhead)"/>
<path d="M 430 385 L 560 385" fill="none" stroke="#64748b" stroke-width="1.5" marker-end="url(#arrowhead)"/>
<path d="M 710 385 L 820 385" fill="none" stroke="#64748b" stroke-width="1.5" marker-end="url(#arrowhead)"/>
<path d="M 710 490 L 820 490" fill="none" stroke="#64748b" stroke-width="1.5" marker-end="url(#arrowhead)"/>
<path d="M 635 425 L 635 548" fill="none" stroke="#64748b" stroke-width="1.5" marker-end="url(#arrowhead)"/>
<path d="M 860 530 C 860 585, 745 612, 700 612" fill="none" stroke="#64748b" stroke-width="1.5" marker-end="url(#arrowhead)"/>
<path d="M 945 490 C 1008 490, 1010 612, 930 612" fill="none" stroke="#64748b" stroke-width="1.5" marker-end="url(#arrowhead)"/>
<path d="M 430 490 C 500 490, 505 612, 560 612" fill="none" stroke="#fb7185" stroke-width="1.5" stroke-dasharray="5,5" marker-end="url(#arrowhead-rose)"/>
<rect x="32" y="76" width="170" height="260" rx="12" fill="none" stroke="#fbbf24" stroke-width="1.5" stroke-dasharray="8,4"/>
<text x="117" y="102" fill="#fbbf24" font-size="11" font-weight="600" text-anchor="middle">Consumers</text>
<rect x="20" y="140" width="160" height="76" rx="6" fill="#0f172a"/>
<rect x="20" y="140" width="160" height="76" rx="6" fill="rgba(8, 51, 68, 0.4)" stroke="#22d3ee" stroke-width="1.5"/>
<text x="100" y="166" fill="#fff" font-size="12" font-weight="600" text-anchor="middle">App / AVPlayer</text>
<text x="100" y="184" fill="#94a3b8" font-size="9" text-anchor="middle">proxyURL playback</text>
<text x="100" y="199" fill="#94a3b8" font-size="9" text-anchor="middle">preload / query / cleanup</text>
<rect x="20" y="250" width="160" height="74" rx="6" fill="#0f172a"/>
<rect x="20" y="250" width="160" height="74" rx="6" fill="rgba(30, 41, 59, 0.5)" stroke="#94a3b8" stroke-width="1.5"/>
<text x="100" y="276" fill="#fff" font-size="12" font-weight="600" text-anchor="middle">Example / Tests</text>
<text x="100" y="294" fill="#94a3b8" font-size="9" text-anchor="middle">iOS, macOS, XCTest</text>
<text x="100" y="309" fill="#94a3b8" font-size="9" text-anchor="middle">public API verification</text>
<rect x="300" y="72" width="180" height="86" rx="6" fill="#0f172a"/>
<rect x="300" y="72" width="180" height="86" rx="6" fill="rgba(6, 78, 59, 0.4)" stroke="#34d399" stroke-width="1.5"/>
<text x="390" y="100" fill="#fff" font-size="12" font-weight="600" text-anchor="middle">API</text>
<text x="390" y="119" fill="#94a3b8" font-size="9" text-anchor="middle">HTTPMediaCache</text>
<text x="390" y="134" fill="#94a3b8" font-size="9" text-anchor="middle">CacheRequest / Options</text>
<rect x="560" y="72" width="150" height="86" rx="6" fill="#0f172a"/>
<rect x="560" y="72" width="150" height="86" rx="6" fill="rgba(76, 29, 149, 0.4)" stroke="#a78bfa" stroke-width="1.5"/>
<text x="635" y="100" fill="#fff" font-size="12" font-weight="600" text-anchor="middle">Core Runtime</text>
<text x="635" y="119" fill="#94a3b8" font-size="9" text-anchor="middle">CacheRuntime</text>
<text x="635" y="134" fill="#94a3b8" font-size="9" text-anchor="middle">ByteRange / URL codec</text>
<rect x="820" y="72" width="150" height="86" rx="6" fill="#0f172a"/>
<rect x="820" y="72" width="150" height="86" rx="6" fill="rgba(6, 78, 59, 0.4)" stroke="#34d399" stroke-width="1.5"/>
<text x="895" y="100" fill="#fff" font-size="12" font-weight="600" text-anchor="middle">Proxy</text>
<text x="895" y="119" fill="#94a3b8" font-size="9" text-anchor="middle">NIOProxyServer</text>
<text x="895" y="134" fill="#94a3b8" font-size="9" text-anchor="middle">HTTPRequestRouter</text>
<rect x="560" y="218" width="150" height="104" rx="6" fill="#0f172a"/>
<rect x="560" y="218" width="150" height="104" rx="6" fill="rgba(6, 78, 59, 0.4)" stroke="#34d399" stroke-width="1.5"/>
<text x="635" y="246" fill="#fff" font-size="12" font-weight="600" text-anchor="middle">Preload</text>
<text x="635" y="265" fill="#94a3b8" font-size="9" text-anchor="middle">PreloadCoordinator</text>
<text x="635" y="280" fill="#94a3b8" font-size="9" text-anchor="middle">FilePreloadExecutor</text>
<text x="635" y="295" fill="#94a3b8" font-size="9" text-anchor="middle">HLSPreloadExecutor</text>
<rect x="820" y="218" width="150" height="104" rx="6" fill="#0f172a"/>
<rect x="820" y="218" width="150" height="104" rx="6" fill="rgba(30, 41, 59, 0.5)" stroke="#94a3b8" stroke-width="1.5"/>
<text x="895" y="246" fill="#fff" font-size="12" font-weight="600" text-anchor="middle">HTTP Response</text>
<text x="895" y="265" fill="#94a3b8" font-size="9" text-anchor="middle">HTTPResponseWriter</text>
<text x="895" y="280" fill="#94a3b8" font-size="9" text-anchor="middle">StreamingProxyBodyPump</text>
<text x="895" y="295" fill="#94a3b8" font-size="9" text-anchor="middle">200 / 206 / HEAD</text>
<rect x="300" y="350" width="150" height="86" rx="6" fill="#0f172a"/>
<rect x="300" y="350" width="150" height="86" rx="6" fill="rgba(6, 78, 59, 0.4)" stroke="#34d399" stroke-width="1.5"/>
<text x="375" y="378" fill="#fff" font-size="12" font-weight="600" text-anchor="middle">HLS</text>
<text x="375" y="397" fill="#94a3b8" font-size="9" text-anchor="middle">Parser / Rewriter</text>
<text x="375" y="412" fill="#94a3b8" font-size="9" text-anchor="middle">Selection / Policy</text>
<rect x="560" y="350" width="150" height="86" rx="6" fill="#0f172a"/>
<rect x="560" y="350" width="150" height="86" rx="6" fill="rgba(6, 78, 59, 0.4)" stroke="#34d399" stroke-width="1.5"/>
<text x="635" y="378" fill="#fff" font-size="12" font-weight="600" text-anchor="middle">Pipeline</text>
<text x="635" y="397" fill="#94a3b8" font-size="9" text-anchor="middle">DataReader / Loader</text>
<text x="635" y="412" fill="#94a3b8" font-size="9" text-anchor="middle">SourcePlanner</text>
<rect x="820" y="350" width="150" height="86" rx="6" fill="#0f172a"/>
<rect x="820" y="350" width="150" height="86" rx="6" fill="rgba(76, 29, 149, 0.4)" stroke="#a78bfa" stroke-width="1.5"/>
<text x="895" y="378" fill="#fff" font-size="12" font-weight="600" text-anchor="middle">Storage</text>
<text x="895" y="397" fill="#94a3b8" font-size="9" text-anchor="middle">CacheIndex / CacheUnit</text>
<text x="895" y="412" fill="#94a3b8" font-size="9" text-anchor="middle">FileStore</text>
<rect x="300" y="455" width="150" height="86" rx="6" fill="#0f172a"/>
<rect x="300" y="455" width="150" height="86" rx="6" fill="rgba(136, 19, 55, 0.4)" stroke="#fb7185" stroke-width="1.5"/>
<text x="375" y="483" fill="#fff" font-size="12" font-weight="600" text-anchor="middle">HLS Download</text>
<text x="375" y="502" fill="#94a3b8" font-size="9" text-anchor="middle">playlist/key/media</text>
<text x="375" y="517" fill="#94a3b8" font-size="9" text-anchor="middle">header policy</text>
<rect x="820" y="455" width="150" height="86" rx="6" fill="#0f172a"/>
<rect x="820" y="455" width="150" height="86" rx="6" fill="rgba(30, 41, 59, 0.5)" stroke="#94a3b8" stroke-width="1.5"/>
<text x="895" y="483" fill="#fff" font-size="12" font-weight="600" text-anchor="middle">Cache Files</text>
<text x="895" y="502" fill="#94a3b8" font-size="9" text-anchor="middle">byte range zones</text>
<text x="895" y="517" fill="#94a3b8" font-size="9" text-anchor="middle">eviction by capacity</text>
<rect x="560" y="575" width="150" height="76" rx="6" fill="#0f172a"/>
<rect x="560" y="575" width="150" height="76" rx="6" fill="rgba(251, 146, 60, 0.3)" stroke="#fb923c" stroke-width="1.5"/>
<text x="635" y="603" fill="#fff" font-size="12" font-weight="600" text-anchor="middle">Network</text>
<text x="635" y="622" fill="#94a3b8" font-size="9" text-anchor="middle">CacheDownloading</text>
<text x="635" y="637" fill="#94a3b8" font-size="9" text-anchor="middle">URLSessionDownloader</text>
<rect x="820" y="575" width="150" height="76" rx="6" fill="#0f172a"/>
<rect x="820" y="575" width="150" height="76" rx="6" fill="rgba(120, 53, 15, 0.3)" stroke="#fbbf24" stroke-width="1.5"/>
<text x="895" y="603" fill="#fff" font-size="12" font-weight="600" text-anchor="middle">Origin / CDN</text>
<text x="895" y="622" fill="#94a3b8" font-size="9" text-anchor="middle">HTTP Range</text>
<text x="895" y="637" fill="#94a3b8" font-size="9" text-anchor="middle">HLS playlists/media</text>
<rect x="260" y="684" width="600" height="30" rx="5" fill="rgba(30, 41, 59, 0.6)" stroke="#334155" stroke-width="1"/>
<text x="560" y="704" fill="#94a3b8" font-size="9" text-anchor="middle">Main dependencies: API orchestrates actors/runtime; Proxy and Preload converge on Pipeline, HLS, Storage, and Network.</text>
</svg>
</section>
<section class="cards">
<article class="card">
<div class="card-header"><span class="card-dot" style="background: var(--emerald)"></span><h3>入口层</h3></div>
<ul>
<li>• `HTTPMediaCache` 暴露播放、预加载、查询与清理入口</li>
<li>• `CacheRuntime` 持有代理、存储、下载器和 HLS 策略</li>
<li>• Example 与 XCTest 均通过公开 API 验证行为</li>
</ul>
</article>
<article class="card">
<div class="card-header"><span class="card-dot" style="background: var(--cyan)"></span><h3>数据链路</h3></div>
<ul>
<li>• Proxy 路由播放器请求,按 HLS 与普通媒体分流</li>
<li>• Pipeline 将请求拆成本地缓存段和远端下载段</li>
<li>• Storage 记录缓存区间并落盘到本地文件</li>
</ul>
</article>
<article class="card">
<div class="card-header"><span class="card-dot" style="background: var(--rose)"></span><h3>HLS 边界</h3></div>
<ul>
<li>• Playlist 缓存原始内容,播放侧按需改写代理 URL</li>
<li>• key、init map、segment 使用独立下载策略</li>
<li>• 预加载复用同一套选择、下载和缓存策略</li>
</ul>
</article>
</section>
<footer>Generated for HTTPMediaCache 1.0.2 documentation.</footer>
</main>
</body>
</html>