mirror of
https://github.com/GopeedLab/gopeed.git
synced 2026-11-06 00:25:43 +00:00
New hls protocol in internal/protocol/hls (registered ahead of http): - master playlist variant picking (highest bandwidth), RFC3986 segment URL resolution, fMP4 init segments, EXT-X-BYTERANGE, EXT-X-GAP skip - AES-128 decryption with mid-playlist key rotation and sequence-derived IVs; explicit errors for live streams, SAMPLE-AES and multi-period fMP4 - concurrent segment downloads with retry, journal-based resume across pause/app restarts, automatic in-order merge into a single .ts/.mp4 - best-effort Content-Length probing for determinate progress - anti-hotlink Referer/Cookie/UA via task extra headers (Go transport does not filter them) Core: fix SchemeFilter extension match for URLs with query strings (also benefits .torrent links); Flutter: Protocol.hls enum, hls protocol config model (prevents config round-trip wipe) and HLS settings block with localized labels in all 22 locales. Tests: parser/crypto unit tests, httptest e2e (Referer-enforced CDN, encrypted streams, byterange, pause/resume, store/restore) and an opt-in live-site acceptance gate (HLS_LIVE_URL).
31 lines
775 B
Go
31 lines
775 B
Go
package hls
|
|
|
|
const (
|
|
defaultSegmentConnections = 8
|
|
defaultMaxRetries = 5
|
|
defaultTimeoutSeconds = 30
|
|
|
|
// maxPrefetchSizeSegments caps the HEAD probing done at resolve time.
|
|
// Playlists larger than this skip size prefetch entirely.
|
|
maxPrefetchSizeSegments = 500
|
|
)
|
|
|
|
type config struct {
|
|
SegmentConnections int `json:"segmentConnections"`
|
|
MaxRetries int `json:"maxRetries"`
|
|
TimeoutSeconds int `json:"timeoutSeconds"`
|
|
PrefetchContentLength bool `json:"prefetchContentLength"`
|
|
}
|
|
|
|
func (c *config) normalize() {
|
|
if c.SegmentConnections <= 0 {
|
|
c.SegmentConnections = defaultSegmentConnections
|
|
}
|
|
if c.MaxRetries < 0 {
|
|
c.MaxRetries = defaultMaxRetries
|
|
}
|
|
if c.TimeoutSeconds <= 0 {
|
|
c.TimeoutSeconds = defaultTimeoutSeconds
|
|
}
|
|
}
|