Giter Club home page Giter Club logo

hlscachingreverseproxyserver's Introduction

HLSCachingReverseProxyServer

Swift CocoaPods Build Status CodeCov

A simple local reverse proxy server for HLS segment cache.

How it works

HLSCachingReverseProxyServer Concept

  1. User sets a reverse proxy url to the AVPlayer instead of the origin url.
    - https://example.com/vod.m3u8
    + http://127.0.0.1:8080/vod.m3u8?__hls_origin_url=https://example.com/vod.m3u8
  2. AVPlayer requests a playlist(.m3u8) to the local reverse proxy server.
  3. Reverse proxy server fetches the origin playlist and replaces all URIs to point the localhost.
      #EXTM3U
      #EXTINF:12.000,
    - vod_00001.ts
    + http://127.0.0.1:8080/vod.m3u8?__hls_origin_url=https://example.com/vod_00001.ts
      #EXTINF:12.000,
    - vod_00002.ts
    + http://127.0.0.1:8080/vod.m3u8?__hls_origin_url=https://example.com/vod_00002.ts
      #EXTINF:12.000,
    - vod_00003.ts
    + http://127.0.0.1:8080/vod.m3u8?__hls_origin_url=https://example.com/vod_00003.ts
  4. AVPlayer requests segments(.ts) to the local reverse proxy server.
  5. Reverse proxy server fetches the origin segment and caches it. Next time the server will return the cached data for the same segment.

Usage

let server = HLSCachingReverseProxyServer()
server.start(port: 8080)

let playlistURL = URL(string: "http://devstreaming.apple.com/videos/wwdc/2016/102w0bsn0ge83qfv7za/102/0640/0640.m3u8")!
let reverseProxyURL = server.reverseProxyURL(from: playlistURL)!
let playerItem = AVPlayerItem(url: reverseProxyURL)
self.player.replaceCurrentItem(with: playerItem)

Dependencies

Installation

Use CocoaPods with Podfile:

pod 'HLSCachingReverseProxyServer'

Development

$ make project
$ open HLSCachingReverseProxyServer.xcworkspace

License

HLSCachingReverseProxyServer is under MIT license. See the LICENSE for more info.

hlscachingreverseproxyserver's People

Contributors

devxoul avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.