Documentation
¶
Overview ¶
Package scheme holds goav's built-in URL schemes, the providers goav.FromURI and goav.ToURI resolve through: File for file URLs and bare paths, and HTTP for http and https. bundle.Schemes registers them on a runtime; registering one yourself replaces it there, last wins:
rt, err := bundle.New(runconfig.WithScheme("https", scheme.HTTP(scheme.Client(myClient))))
Both use the standard library only. Transports with dependencies live in nested modules and export their schemes the same way (webrtcav.WHEP); a future RTMP, SRT, or HLS input is one more provider.Scheme, a provider.ByteSource when it carries a container (FLV, MPEG-TS, fMP4 segments) and a provider.Source when it carries media.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrChanged = errors.New("scheme: http resource changed while it was read")
ErrChanged reports an HTTP resource that changed while it was read: a ranged request's validator (ETag or Last-Modified) no longer matched, so the bytes read so far and the bytes to come belong to different files.
Functions ¶
func File ¶
File is the file scheme: file:///abs/path.mp4, a relative file:path.mp4, or a bare path given to goav.FromURI or goav.ToURI. Inputs open random-access (MP4 with its index at the end seeks); destinations create the file and its parent directories when the run opens them. It is an InputScheme and a DestinationScheme.
func HTTP ¶
func HTTP(options ...HTTPOption) provider.InputScheme
HTTP is the http and https scheme for inputs. The resource is container bytes read through ranged GETs, so a random-access container (MP4 with its index at the end) seeks instead of downloading everything first. Requests after the first carry If-Range with its strong ETag or Last-Modified, and a server that answers with a different representation fails the read with ErrChanged instead of splicing two files. Redirects are followed once: later requests go to the final URL. A server without range support is read progressively, keeping a window of recent bytes for short backward reads and reading again from the start for longer ones.
A server that sends no length and takes no ranges (MPEG-TS over HTTP), or an Icecast mount, is a live stream: it reads forward only, paces as live, and its end is a drop goav.Reconnect recovers from. A read that waits 30s for data fails, and the run's context ends reads. HTTP is an input scheme: it does not write.
Types ¶
type HTTPOption ¶
type HTTPOption func(*httpConfig)
HTTPOption configures HTTP.
func Client ¶
func Client(c *http.Client) HTTPOption
Client makes HTTP send its requests through c instead of the default client, whose transport bounds dialing (10s), the TLS handshake (10s), and the wait for response headers (30s), and which follows at most 10 redirects. c keeps its own timeouts and redirect policy; credentials set with Header are still dropped when a redirect leaves the URL's host.
func Header ¶
func Header(key, value string) HTTPOption
Header adds a header to every request HTTP sends: the place for credentials (Authorization, an API key) a URL should not carry. goav redacts the URLs it reports, and never reports headers.