Skip to content

Commit 1dba4f9

Browse files
committed
Update README.md
1 parent 088d959 commit 1dba4f9

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

README.md

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,17 @@
77

88
A simple local reverse proxy server for HLS segment cache.
99

10-
## Concept
10+
## How it works
1111

12-
1. **User** sets a reverse proxy url instead of original url.
12+
![HLSCachingReverseProxyServer Concept](https://user-images.githubusercontent.com/931655/69081879-45206a80-0a82-11ea-8fca-3c09f3b1ebb1.png)
13+
14+
1. **User** sets a reverse proxy url to the `AVPlayer` instead of the origin url.
1315
```diff
1416
- https://example.com/vod.m3u8
1517
+ http://127.0.0.1:8080/vod.m3u8?__hls_origin_url=https://example.com/vod.m3u8
1618
```
17-
2. **AVAsset** requests a playlist(`.m3u8`) to the local reverse proxy server.
18-
3. **Reverse proxy server** fetches the original playlist and replaces all URIs to point the local reverse proxy server.
19+
2. **AVPlayer** requests a playlist(`.m3u8`) to the local reverse proxy server.
20+
3. **Reverse proxy server** fetches the origin playlist and replaces all URIs to point the localhost.
1921
```diff
2022
#EXTM3U
2123
#EXTINF:12.000,
@@ -28,8 +30,8 @@ A simple local reverse proxy server for HLS segment cache.
2830
- vod_00003.ts
2931
+ http://127.0.0.1:8080/vod.m3u8?__hls_origin_url=https://example.com/vod_00003.ts
3032
```
31-
4. **AVAsset** requests segments(`.ts`) to the local server.
32-
5. **Reverse proxy server** fetches the original segment and caches. Next time the server will return the cached data for the same segment.
33+
4. **AVPlayer** requests segments(`.ts`) to the local reverse proxy server.
34+
5. **Reverse proxy server** fetches the origin segment and caches it. Next time the server will return the cached data for the same segment.
3335

3436
## Usage
3537

@@ -38,8 +40,8 @@ let server = HLSCachingReverseProxyServer()
3840
server.start(port: 8080)
3941

4042
let playlistURL = URL(string: "http://devstreaming.apple.com/videos/wwdc/2016/102w0bsn0ge83qfv7za/102/0640/0640.m3u8")!
41-
let url = server.reverseProxyURL(from: playlistURL)!
42-
let playerItem = AVPlayerItem(url: url)
43+
let reverseProxyURL = server.reverseProxyURL(from: playlistURL)!
44+
let playerItem = AVPlayerItem(url: reverseProxyURL)
4345
self.player.replaceCurrentItem(with: playerItem)
4446
```
4547

@@ -50,7 +52,7 @@ self.player.replaceCurrentItem(with: playerItem)
5052

5153
## Installation
5254

53-
**Podfile**
55+
Use CocoaPods with **Podfile**:
5456

5557
```ruby
5658
pod 'HLSCachingReverseProxyServer'

0 commit comments

Comments
 (0)