httpclient

package
v1.9.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 6, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewPayload

func NewPayload(r io.Reader, contentType string) *payload

func NewReader

func NewReader(r io.Reader, onRead func(total int64)) *reader

Types

type Client

type Client struct {
	*client.Client
}

Client is a profile HTTP client that wraps the base HTTP client

func New

func New(url string, opts ...client.ClientOpt) (*Client, error)

New creates a new profile HTTP client with the given base URL and options. The url parameter should point to the profile API endpoint, e.g. "http://localhost:8080/api".

func (*Client) Encode added in v1.9.3

func (c *Client) Encode(ctx context.Context, req taskencoder.EncodeRequest, onRead func(n int64), fn EncodeEventFunc) (*taskschema.Status, error)

Encode uploads req.Reader for encoding. If fn is nil, it returns as soon as the task is started, with its current status - encoding is long-running, so this doesn't wait for it to finish; poll or watch the task afterwards by its UUID (via the task API). If fn is non-nil, Encode instead waits, streaming the task's own events to fn until it finishes, ctx is done, or fn itself stops it (io.EOF to stop cleanly, any other error to stop and have Encode return that error) - either way, the returned status is the last one observed.

req.Output/Audio/Video/Subtitle must already be fully resolved (e.g. via profile.NewAudioProfile), same as when calling the task directly - they're sent as JSON alongside the uploaded file. If onRead is non-nil, it's called with the cumulative number of bytes read from req.Reader as the upload progresses.

func (*Client) Metadata

func (c *Client) Metadata(ctx context.Context, req taskmetadata.MetadataRequest, contentType string, onRead func(n int64)) (*taskmetadata.MetadataResponse, error)

Metadata uploads req.Reader to the metadata endpoint and returns the detected content type and container-level metadata (excludes artwork and chapters, and doesn't probe streams, unlike ProbeMedia). req.Filter/ req.Format/req.Opts are attached to the request as query parameters.

Upload semantics (contentType, onRead, ownership of req.Reader, and the NamedReader filename convention) are identical to ProbeMedia - see its doc comment.

func (*Client) ProbeMedia

func (c *Client) ProbeMedia(ctx context.Context, req task.ProbeMediaRequest, contentType string, onRead func(n int64)) (*task.ProbeResponse, error)

ProbeMedia uploads req.Reader to the probe endpoint and returns its container format, streams, and metadata. req.Format/req.Opts are attached to the request as query parameters.

If contentType is multipart/form-data, req.Reader is streamed as a single "file" field using go-client's streaming multipart encoder (so the whole body is never buffered in memory, matching the server's expected upload shape); for any other content type, req.Reader is streamed directly as the raw request body with that Content-Type. Either way, the caller retains ownership of req.Reader - ProbeMedia doesn't close it.

If req.Reader implements gomedia.NamedReader, its name is used as the uploaded filename. If onRead is non-nil, it's called with the cumulative number of bytes read from req.Reader as the upload progresses, regardless of which of the two upload paths is taken.

func (*Client) ProbeSource

func (c *Client) ProbeSource(ctx context.Context, req task.ProbeSourceRequest) (*task.ProbeResponse, error)

ProbeSource probes a URL - a network source FFmpeg can read directly (http, https, rtmp, ...), or a "device://<format>/<address>" URL (see ProbeSourceTask's doc comment) - rather than an uploaded file's bytes.

type EncodeEventFunc added in v1.9.3

type EncodeEventFunc func(*taskschema.Event) error

EncodeEventFunc is called for every task event received when Encode is given a non-nil fn. Return io.EOF to stop the stream cleanly, or any other error to stop it and have Encode return that error.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL