api

package
v0.0.0-...-31c1c1e Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2022 License: Apache-2.0 Imports: 13 Imported by: 1

Documentation

Overview

Package api provides types for communicating with the REST API

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AVstream

type AVstream struct {
	Input       AVstreamIO `json:"input"`
	Output      AVstreamIO `json:"output"`
	Aqueue      uint64     `json:"aqueue"`
	Queue       uint64     `json:"queue"`
	Dup         uint64     `json:"dup"`
	Drop        uint64     `json:"drop"`
	Enc         uint64     `json:"enc"`
	Looping     bool       `json:"looping"`
	Duplicating bool       `json:"duplicating"`
	GOP         string     `json:"gop"`
}

func (*AVstream) Unmarshal

func (a *AVstream) Unmarshal(av *app.AVstream)

type AVstreamIO

type AVstreamIO struct {
	State  string `json:"state" enums:"running,idle" jsonschema:"enum=running,enum=idle"`
	Packet uint64 `json:"packet"`
	Time   uint64 `json:"time"`
	Size   uint64 `json:"size_kb"`
}

func (*AVstreamIO) Unmarshal

func (i *AVstreamIO) Unmarshal(io *app.AVstreamIO)

type About

type About struct {
	App       string   `json:"app"`
	Auths     []string `json:"auths"`
	Name      string   `json:"name"`
	ID        string   `json:"id"`
	CreatedAt string   `json:"created_at"`
	Uptime    uint64   `json:"uptime_seconds"`
	Version   Version  `json:"version"`
}

About is some general information about the API

type Command

type Command struct {
	Command string `` /* 127-byte string literal not displayed */
}

Command is a command to send to a process

type Config

type Config struct {
	CreatedAt time.Time `json:"created_at"`
	LoadedAt  time.Time `json:"loaded_at"`
	UpdatedAt time.Time `json:"updated_at"`

	Config ConfigData `json:"config"`

	Overrides []string `json:"overrides"`
}

Config is the config returned by the API

func (*Config) Unmarshal

func (c *Config) Unmarshal(cfg *config.Config)

Unmarshal converts a config.Config to a RestreamerConfig.

type ConfigData

type ConfigData struct {
	config.Data
}

ConfigData embeds config.Data

type ConfigError

type ConfigError map[string][]string

ConfigError is used to return error messages when uploading a new config

type Error

type Error struct {
	Code    int      `json:"code" jsonschema:"required"`
	Message string   `json:"message" jsonschema:""`
	Details []string `json:"details" jsonschema:""`
}

Error represents an error response of the API

func Err

func Err(code int, message string, args ...interface{}) Error

Err creates a new API error with the given HTTP status code. If message is empty, the default message for the given code is used. If the first entry in args is a string, it is interpreted as a format string for the remaining entries in args, that is used for fmt.Sprintf. Otherwise the args are ignored.

func (Error) Error

func (e Error) Error() string

Error returns the string representation of the error

type FileInfo

type FileInfo struct {
	Name    string `json:"name" jsonschema:"minLength=1"`
	Size    int64  `json:"size_bytes" jsonschema:"minimum=0"`
	LastMod int64  `json:"last_modified" jsonschema:"minimum=0"`
}

FileInfo represents informatiion about a file on a filesystem

type GraphQuery

type GraphQuery struct {
	Query     string      `json:"query"`
	Variables interface{} `json:"variables"`
}

type GraphResponse

type GraphResponse struct {
	Data   interface{}   `json:"data"`
	Errors []interface{} `json:"errors"`
}

type JWT

type JWT struct {
	AccessToken  string `json:"access_token" jsonschema:"minLength=1"`
	RefreshToken string `json:"refresh_token" jsonschema:"minLength=1"`
}

JWT is the JWT token and its expiry date

type JWTRefresh

type JWTRefresh struct {
	AccessToken string `json:"access_token" jsonschema:"minLength=1"`
}

type LogEvent

type LogEvent map[string]interface{}

LogEvent represents a log event from the app

type Login

type Login struct {
	Username string `json:"username" validate:"required" jsonschema:"minLength=1"`
	Password string `json:"password" validate:"required" jsonschema:"minLength=1"`
}

Login are the requires login credentials

type Metadata

type Metadata interface{}

Metadata represents arbitrary metadata for a process of for the app

func NewMetadata

func NewMetadata(data interface{}) Metadata

NewMetadata takes an interface and converts it to a Metadata type.

type MetricsQuery

type MetricsQuery struct {
	Timerange int64                `json:"timerange_sec"`
	Interval  int64                `json:"interval_sec"`
	Metrics   []MetricsQueryMetric `json:"metrics"`
}

type MetricsQueryMetric

type MetricsQueryMetric struct {
	Name   string            `json:"name"`
	Labels map[string]string `json:"labels"`
}

type MetricsResponse

type MetricsResponse struct {
	Timerange int64                   `json:"timerange_sec"`
	Interval  int64                   `json:"interval_sec"`
	Metrics   []MetricsResponseMetric `json:"metrics"`
}

func (*MetricsResponse) Unmarshal

func (m *MetricsResponse) Unmarshal(data []monitor.HistoryMetrics, timerange, interval time.Duration)

type MetricsResponseMetric

type MetricsResponseMetric struct {
	Name   string                 `json:"name"`
	Labels map[string]string      `json:"labels"`
	Values []MetricsResponseValue `json:"values"`
}

type MetricsResponseValue

type MetricsResponseValue struct {
	TS    time.Time `json:"ts"`
	Value float64   `json:"value"`
}

func (MetricsResponseValue) MarshalJSON

func (v MetricsResponseValue) MarshalJSON() ([]byte, error)

MarshalJSON marshals a MetricsResponseValue to JSON

type MinimalAbout

type MinimalAbout struct {
	App     string         `json:"app"`
	Auths   []string       `json:"auths"`
	Version VersionMinimal `json:"version"`
}

MinimalAbout is the minimal information about the API

type PlayoutStatus

type PlayoutStatus struct {
	ID          string            `json:"id"`
	Address     string            `json:"url"`
	Stream      uint64            `json:"stream"`
	Queue       uint64            `json:"queue"`
	AQueue      uint64            `json:"aqueue"`
	Dup         uint64            `json:"dup"`
	Drop        uint64            `json:"drop"`
	Enc         uint64            `json:"enc"`
	Looping     bool              `json:"looping"`
	Duplicating bool              `json:"duplicating"`
	GOP         string            `json:"gop"`
	Debug       interface{}       `json:"debug"`
	Input       PlayoutStatusIO   `json:"input"`
	Output      PlayoutStatusIO   `json:"output"`
	Swap        PlayoutStatusSwap `json:"swap"`
}

func (*PlayoutStatus) Unmarshal

func (s *PlayoutStatus) Unmarshal(status playout.Status)

type PlayoutStatusIO

type PlayoutStatusIO struct {
	State  string `json:"state" enums:"running,idle" jsonschema:"enum=running,enum=idle"`
	Packet uint64 `json:"packet"`
	Time   uint64 `json:"time"`
	Size   uint64 `json:"size_kb"`
}

func (*PlayoutStatusIO) Unmarshal

func (i *PlayoutStatusIO) Unmarshal(io playout.StatusIO)

type PlayoutStatusSwap

type PlayoutStatusSwap struct {
	Address     string `json:"url"`
	Status      string `json:"status"`
	LastAddress string `json:"lasturl"`
	LastError   string `json:"lasterror"`
}

func (*PlayoutStatusSwap) Unmarshal

func (s *PlayoutStatusSwap) Unmarshal(swap playout.StatusSwap)

type Probe

type Probe struct {
	Streams []ProbeIO `json:"streams"`
	Log     []string  `json:"log"`
}

Probe represents the result of probing a file. It has a list of detected streams and a list of log lone from the probe process.

func (*Probe) Unmarshal

func (probe *Probe) Unmarshal(p *app.Probe)

Unmarshal converts a restreamer Probe to a Probe in API representation

type ProbeIO

type ProbeIO struct {
	// common
	Address  string      `json:"url"`
	Format   string      `json:"format"`
	Index    uint64      `json:"index"`
	Stream   uint64      `json:"stream"`
	Language string      `json:"language"`
	Type     string      `json:"type"`
	Codec    string      `json:"codec"`
	Coder    string      `json:"coder"`
	Bitrate  json.Number `json:"bitrate_kbps" swaggertype:"number"`
	Duration json.Number `json:"duration_sec"  swaggertype:"number"`

	// video
	FPS    json.Number `json:"fps" swaggertype:"number"`
	Pixfmt string      `json:"pix_fmt"`
	Width  uint64      `json:"width"`
	Height uint64      `json:"height"`

	// audio
	Sampling uint64 `json:"sampling_hz"`
	Layout   string `json:"layout"`
	Channels uint64 `json:"channels"`
}

ProbeIO represents a stream of a probed file

func (*ProbeIO) Unmarshal

func (i *ProbeIO) Unmarshal(io *app.ProbeIO)

type Process

type Process struct {
	ID        string         `json:"id" jsonschema:"minLength=1"`
	Type      string         `json:"type" jsonschema:"enum=ffmpeg"`
	Reference string         `json:"reference"`
	CreatedAt int64          `json:"created_at" jsonschema:"minimum=0"`
	Config    *ProcessConfig `json:"config,omitempty"`
	State     *ProcessState  `json:"state,omitempty"`
	Report    *ProcessReport `json:"report,omitempty"`
	Metadata  Metadata       `json:"metadata,omitempty"`
}

Process represents all information on a process

type ProcessConfig

type ProcessConfig struct {
	ID             string              `json:"id"`
	Type           string              `json:"type" validate:"oneof='ffmpeg' ''" jsonschema:"enum=ffmpeg,enum="`
	Reference      string              `json:"reference"`
	Input          []ProcessConfigIO   `json:"input" validate:"required"`
	Output         []ProcessConfigIO   `json:"output" validate:"required"`
	Options        []string            `json:"options"`
	Reconnect      bool                `json:"reconnect"`
	ReconnectDelay uint64              `json:"reconnect_delay_seconds"`
	Autostart      bool                `json:"autostart"`
	StaleTimeout   uint64              `json:"stale_timeout_seconds"`
	Limits         ProcessConfigLimits `json:"limits"`
}

ProcessConfig represents the configuration of an ffmpeg process

func (*ProcessConfig) Marshal

func (cfg *ProcessConfig) Marshal() *app.Config

Marshal converts a process config in API representation to a restreamer process config

func (*ProcessConfig) Unmarshal

func (cfg *ProcessConfig) Unmarshal(c *app.Config)

Unmarshal converts a restream process config to a process config in API representation

type ProcessConfigIO

type ProcessConfigIO struct {
	ID      string                   `json:"id"`
	Address string                   `json:"address" validate:"required" jsonschema:"minLength=1"`
	Options []string                 `json:"options"`
	Cleanup []ProcessConfigIOCleanup `json:"cleanup,omitempty"`
}

ProcessConfigIO represents an input or output of an ffmpeg process config

type ProcessConfigIOCleanup

type ProcessConfigIOCleanup struct {
	Pattern       string `json:"pattern" validate:"required"`
	MaxFiles      uint   `json:"max_files"`
	MaxFileAge    uint   `json:"max_file_age_seconds"`
	PurgeOnDelete bool   `json:"purge_on_delete"`
}

type ProcessConfigLimits

type ProcessConfigLimits struct {
	CPU     float64 `json:"cpu_usage" jsonschema:"minimum=0,maximum=100"`
	Memory  uint64  `json:"memory_mbytes" jsonschema:"minimum=0"`
	WaitFor uint64  `json:"waitfor_seconds" jsonschema:"minimum=0"`
}

type ProcessReport

type ProcessReport struct {
	ProcessReportHistoryEntry
	History []ProcessReportHistoryEntry `json:"history"`
}

ProcessReport represents the current log and the logs of previous runs of a restream process

func (*ProcessReport) Unmarshal

func (report *ProcessReport) Unmarshal(l *app.Log)

Unmarshal converts a restream log to a report

type ProcessReportHistoryEntry

type ProcessReportHistoryEntry struct {
	CreatedAt int64       `json:"created_at"`
	Prelude   []string    `json:"prelude"`
	Log       [][2]string `json:"log"`
}

ProcessReportHistoryEntry represents the logs of a run of a restream process

type ProcessState

type ProcessState struct {
	Order     string      `json:"order" jsonschema:"enum=start,enum=stop"`
	State     string      `json:"exec" jsonschema:"enum=finished,enum=starting,enum=running,enum=finishing,enum=killed,enum=failed"`
	Runtime   int64       `json:"runtime_seconds" jsonschema:"minimum=0"`
	Reconnect int64       `json:"reconnect_seconds"`
	LastLog   string      `json:"last_logline"`
	Progress  *Progress   `json:"progress"`
	Memory    uint64      `json:"memory_bytes"`
	CPU       json.Number `json:"cpu_usage" swaggertype:"number"`
	Command   []string    `json:"command"`
}

ProcessState represents the current state of an ffmpeg process

func (*ProcessState) Unmarshal

func (s *ProcessState) Unmarshal(state *app.State)

Unmarshal converts a restreamer ffmpeg process state to a state in API representation

type Progress

type Progress struct {
	Input     []ProgressIO `json:"inputs"`
	Output    []ProgressIO `json:"outputs"`
	Frame     uint64       `json:"frame"`
	Packet    uint64       `json:"packet"`
	FPS       json.Number  `json:"fps" swaggertype:"number"`
	Quantizer json.Number  `json:"q" swaggertype:"number"`
	Size      uint64       `json:"size_kb"` // kbytes
	Time      json.Number  `json:"time" swaggertype:"number"`
	Bitrate   json.Number  `json:"bitrate_kbit" swaggertype:"number"` // kbit/s
	Speed     json.Number  `json:"speed" swaggertype:"number"`
	Drop      uint64       `json:"drop"`
	Dup       uint64       `json:"dup"`
}

Progress represents the progress of an ffmpeg process

func (*Progress) Unmarshal

func (progress *Progress) Unmarshal(p *app.Progress)

Unmarshal converts a restreamer Progress to a Progress in API representation

type ProgressIO

type ProgressIO struct {
	ID      string `json:"id" jsonschema:"minLength=1"`
	Address string `json:"address" jsonschema:"minLength=1"`

	// General
	Index   uint64      `json:"index"`
	Stream  uint64      `json:"stream"`
	Format  string      `json:"format"`
	Type    string      `json:"type"`
	Codec   string      `json:"codec"`
	Coder   string      `json:"coder"`
	Frame   uint64      `json:"frame"`
	FPS     json.Number `json:"fps" swaggertype:"number"`
	Packet  uint64      `json:"packet"`
	PPS     json.Number `json:"pps" swaggertype:"number"`
	Size    uint64      `json:"size_kb"`                           // kbytes
	Bitrate json.Number `json:"bitrate_kbit" swaggertype:"number"` // kbit/s

	// Video
	Pixfmt    string      `json:"pix_fmt,omitempty"`
	Quantizer json.Number `json:"q,omitempty" swaggertype:"number"`
	Width     uint64      `json:"width,omitempty"`
	Height    uint64      `json:"height,omitempty"`

	// Audio
	Sampling uint64 `json:"sampling_hz,omitempty"`
	Layout   string `json:"layout,omitempty"`
	Channels uint64 `json:"channels,omitempty"`

	// avstream
	AVstream *AVstream `json:"avstream"`
}

ProgressIO represents the progress of an ffmpeg input or output

func (*ProgressIO) Unmarshal

func (i *ProgressIO) Unmarshal(io *app.ProgressIO)

Unmarshal converts a restreamer ProgressIO to a ProgressIO in API representation

type RTMPChannel

type RTMPChannel struct {
	Name string `json:"name" jsonschema:"minLength=1"`
}

RTMPChannel represents details about a currently connected RTMP publisher

type Session

type Session struct {
	ID        string      `json:"id"`
	Reference string      `json:"reference"`
	CreatedAt int64       `json:"created_at"`
	Location  string      `json:"local"`
	Peer      string      `json:"remote"`
	Extra     string      `json:"extra"`
	RxBytes   uint64      `json:"bytes_rx"`
	TxBytes   uint64      `json:"bytes_tx"`
	RxBitrate json.Number `json:"bandwidth_rx_kbit" swaggertype:"number"` // kbit/s
	TxBitrate json.Number `json:"bandwidth_tx_kbit" swaggertype:"number"` // kbit/s
}

Session represents an active session

func (*Session) Unmarshal

func (s *Session) Unmarshal(sess session.Session)

type SessionPeers

type SessionPeers struct {
	SessionStats

	Locations map[string]SessionStats `json:"local"`
}

SessionPeers is for the grouping by peers in the summary

type SessionStats

type SessionStats struct {
	TotalSessions uint64 `json:"sessions"`
	TotalRxBytes  uint64 `json:"traffic_rx_mb"`
	TotalTxBytes  uint64 `json:"traffic_tx_mb"`
}

SessionStats are the accumulated numbers for the session summary

type SessionSummary

type SessionSummary struct {
	Active SessionSummaryActive `json:"active"`

	Summary SessionSummarySummary `json:"summary"`
}

SessionSummary is the API representation of a session.Summary

func (*SessionSummary) Unmarshal

func (summary *SessionSummary) Unmarshal(sum session.Summary)

Unmarshal creates a new SessionSummary from a session.Summary

type SessionSummaryActive

type SessionSummaryActive struct {
	SessionList  []Session   `json:"list"`
	Sessions     uint64      `json:"sessions"`
	RxBitrate    json.Number `json:"bandwidth_rx_mbit" swaggertype:"number"` // mbit/s
	TxBitrate    json.Number `json:"bandwidth_tx_mbit" swaggertype:"number"` // mbit/s
	MaxSessions  uint64      `json:"max_sessions"`
	MaxRxBitrate json.Number `json:"max_bandwidth_rx_mbit" swaggertype:"number"` // mbit/s
	MaxTxBitrate json.Number `json:"max_bandwidth_tx_mbit" swaggertype:"number"` // mbit/s
}

SessionSummaryActive represents the currently active sessions

type SessionSummarySummary

type SessionSummarySummary struct {
	Peers      map[string]SessionPeers `json:"remote"`
	Locations  map[string]SessionStats `json:"local"`
	References map[string]SessionStats `json:"reference"`
	SessionStats
}

SessionSummarySummary represents the summary (history) of all finished sessions

type SessionsActive

type SessionsActive map[string][]Session

SessionsActive is the API representation of all active sessions

type SessionsSummary

type SessionsSummary map[string]SessionSummary

type SetConfig

type SetConfig struct {
	config.Data
}

SetConfig embeds config.Data. It is used to send a new config to the server.

func NewSetConfig

func NewSetConfig(cfg *config.Config) SetConfig

NewSetConfig converts a config.Config into a RestreamerSetConfig in order to prepopulate a RestreamerSetConfig with the current values. The uploaded config can have missing fields that will be filled with the current values after unmarshalling the JSON.

func (*SetConfig) MergeTo

func (rscfg *SetConfig) MergeTo(cfg *config.Config)

MergeTo merges a sent config into a config.Config

type Skills

type Skills struct {
	FFmpeg struct {
		Version       string          `json:"version"`
		Compiler      string          `json:"compiler"`
		Configuration string          `json:"configuration"`
		Libraries     []SkillsLibrary `json:"libraries"`
	} `json:"ffmpeg"`

	Filters  []SkillsFilter  `json:"filter"`
	HWAccels []SkillsHWAccel `json:"hwaccels"`

	Codecs struct {
		Audio    []SkillsCodec `json:"audio"`
		Video    []SkillsCodec `json:"video"`
		Subtitle []SkillsCodec `json:"subtitle"`
	} `json:"codecs"`

	Devices struct {
		Demuxers []SkillsDevice `json:"demuxers"`
		Muxers   []SkillsDevice `json:"muxers"`
	} `json:"devices"`

	Formats struct {
		Demuxers []SkillsFormat `json:"demuxers"`
		Muxers   []SkillsFormat `json:"muxers"`
	} `json:"formats"`

	Protocols struct {
		Input  []SkillsProtocol `json:"input"`
		Output []SkillsProtocol `json:"output"`
	} `json:"protocols"`
}

Skills represents a set of ffmpeg capabilities

func (*Skills) Unmarshal

func (s *Skills) Unmarshal(skills skills.Skills)

Unmarshal converts skills to their API representation

type SkillsCodec

type SkillsCodec struct {
	ID       string   `json:"id"`
	Name     string   `json:"name"`
	Encoders []string `json:"encoders"`
	Decoders []string `json:"decoders"`
}

SkillsCodec represents an ffmpeg codec

func (*SkillsCodec) Unmarshal

func (s *SkillsCodec) Unmarshal(codec skills.Codec)

Unmarshal converts a skills codec to its API representation

type SkillsDevice

type SkillsDevice struct {
	ID      string           `json:"id"`
	Name    string           `json:"name"`
	Devices []SkillsHWDevice `json:"devices"`
}

SkillsDevice represents a group of ffmpeg hardware devices

func (*SkillsDevice) Unmarshal

func (s *SkillsDevice) Unmarshal(device skills.Device)

Unmarshal converts a skills device to its API representation

type SkillsFilter

type SkillsFilter struct {
	ID   string `json:"id"`
	Name string `json:"name"`
}

SkillsFilter represents an ffmpeg filter

func (*SkillsFilter) Unmarshal

func (s *SkillsFilter) Unmarshal(filter skills.Filter)

Unmarshal converts a skills filter to its API representation

type SkillsFormat

type SkillsFormat struct {
	ID   string `json:"id"`
	Name string `json:"name"`
}

SkillsFormat represents an ffmpeg format

func (*SkillsFormat) Unmarshal

func (s *SkillsFormat) Unmarshal(format skills.Format)

Unmarshal converts a skills format to its API representation

type SkillsHWAccel

type SkillsHWAccel struct {
	ID   string `json:"id"`
	Name string `json:"name"`
}

SkillsHWAccel represents an ffmpeg HW accelerator

func (*SkillsHWAccel) Unmarshal

func (s *SkillsHWAccel) Unmarshal(hwaccel skills.HWAccel)

Unmarshal converts a skills HWAccel to its API representation

type SkillsHWDevice

type SkillsHWDevice struct {
	ID    string `json:"id"`
	Name  string `json:"name"`
	Extra string `json:"extra"`
	Media string `json:"media"`
}

SkillsHWDevice represents an ffmpeg hardware device

func (*SkillsHWDevice) Unmarshal

func (s *SkillsHWDevice) Unmarshal(hwdevice skills.HWDevice)

Unmarshal converts a skills HW device to its API representation

type SkillsLibrary

type SkillsLibrary struct {
	Name     string `json:"name"`
	Compiled string `json:"compiled"`
	Linked   string `json:"linked"`
}

SkillsLibrary represents an avlib ffmpeg is compiled and linked with

func (*SkillsLibrary) Unmarshal

func (s *SkillsLibrary) Unmarshal(lib skills.Library)

Unmarshal converts a skills library to its API representation

type SkillsProtocol

type SkillsProtocol struct {
	ID   string `json:"id"`
	Name string `json:"name"`
}

SkillsProtocol represents an ffmpeg protocol

func (*SkillsProtocol) Unmarshal

func (s *SkillsProtocol) Unmarshal(proto skills.Protocol)

Unmarshal converts a skills protocol to its API representation

type Version

type Version struct {
	Number   string `json:"number"`
	Commit   string `json:"repository_commit"`
	Branch   string `json:"repository_branch"`
	Build    string `json:"build_date"`
	Arch     string `json:"arch"`
	Compiler string `json:"compiler"`
}

Version is some information about the binary

type VersionMinimal

type VersionMinimal struct {
	Number string `json:"number"`
}

type WidgetProcess

type WidgetProcess struct {
	CurrentSessions uint64 `json:"current_sessions"`
	TotalSessions   uint64 `json:"total_sessions"`
	Uptime          int64  `json:"uptime"`
}

Jump to

Keyboard shortcuts

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