Content-Length: 298869 | pFad | http://github.com/muxinc/mux-player-swift/pull/24/commits/aa97cdd750f998793282decb45259968a2e10255

FE feat: HLS proxy server and URLCache integration by andrewjl-mux · Pull Request #24 · muxinc/mux-player-swift · GitHub
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: HLS proxy server and URLCache integration #24

Merged
merged 15 commits into from
Feb 13, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
wire in reverse proxy request handlers
  • Loading branch information
andrewjl-mux committed Feb 9, 2024
commit aa97cdd750f998793282decb45259968a2e10255
50 changes: 49 additions & 1 deletion Sources/MuxPlayerSwift/ResourceLoader/ReverseProxyServer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ class ReverseProxyServer {
return
}

self.setupManifestRequestHandler()
self.setupSegmentHandler()

webServer.start(
withPort: port,
bonjourName: nil
Expand Down Expand Up @@ -87,8 +90,22 @@ class ReverseProxyServer {
.map { line in self.processPlaylistLine(line, forOriginURL: origenURL) }
.joined(separator: "\n")

let contentType = response.mimeType ?? "application/x-mpegurl"

guard let serializedParsedManifest = parsedManifest?.data(using: .utf8) else {
return completion(
GCDWebServerErrorResponse(
statusCode: 500
)
)
}

return completion(GCDWebServerErrorResponse(statusCode: 500))
return completion(
GCDWebServerDataResponse(
data: serializedParsedManifest,
contentType: contentType
)
)
}

task.resume()
Expand All @@ -99,6 +116,37 @@ class ReverseProxyServer {

}

private func setupSegmentHandler() {
self.webServer.addHandler(
forMethod: "GET",
pathRegex: "^/.*\\.ts$",
request: GCDWebServerRequest.self
) { [weak self] request, completion in

guard let self = self else {
return completion(GCDWebServerDataResponse(statusCode: 500))
}

guard let origenURL = self.origenURL(from: request) else {
return completion(GCDWebServerErrorResponse(statusCode: 400))
}

let task = self.session.dataTask(with: origenURL) { data, response, error in
guard let data = data, let response = response else {
return completion(GCDWebServerErrorResponse(statusCode: 500))
}

let contentType = response.mimeType ?? "video/mp2t"
completion(GCDWebServerDataResponse(data: data, contentType: contentType))


}

task.resume()

}
}

private func processPlaylistLine(
_ line: String,
forOriginURL origenURL: URL
Expand Down








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/muxinc/mux-player-swift/pull/24/commits/aa97cdd750f998793282decb45259968a2e10255

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy