icecast

package module
v2.0.8 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2024 License: Apache-2.0 Imports: 10 Imported by: 2

README

GoReportCard GitHub Actions CI Status GitHub Actions CodeQL Status
Codebeat badge Coverage Status

Usage exampleCI StatusLicense


go-icecast is a Go package for working with Icecast Admin API.

Usage example

package main

import (
  "fmt"
  ic "pkg.re/essentialkaos/go-icecast/v2"
)

func main() {
  api, err := ic.NewAPI("https://127.0.0.1:8000", "admin", "MySuppaPAssWOrd")
  api.SetUserAgent("MyApp", "1.2.3")

  if err != nil {
    fmt.Printf("Error: %v\n", err)
    return
  }

  stats, err := api.GetStats()

  if err != nil {
    fmt.Printf("Error: %v\n", err)
    return
  }

  fmt.Println("%-v\n", stats)
}

CI Status

Branch Status
master (Stable) CI
develop (Unstable) CI

License

Apache License, Version 2.0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInitEmptyURL      = errors.New("URL can't be empty")
	ErrInitEmptyUser     = errors.New("User can't be empty")
	ErrInitEmptyPassword = errors.New("Password can't be empty")
)

API errors

Functions

This section is empty.

Types

type API

type API struct {
	Client *fasthttp.Client // Client is client for http requests
	// contains filtered or unexported fields
}

API is Confluence API struct

func NewAPI

func NewAPI(url, user, password string) (*API, error)

NewAPI creates new API struct

func (*API) GetStats

func (api *API) GetStats() (*Stats, error)

GetStats fetches info about Icecast server

func (*API) KillClient

func (api *API) KillClient(mount string, id int) error

KillClient kills client with given ID connected to given mount point

func (*API) KillSource

func (api *API) KillSource(mount string) error

KillSource kills the source with given mount point

func (*API) ListClients

func (api *API) ListClients(mount string) ([]*Listener, error)

ListClients fetches list of listeners connected to given mount point

func (*API) ListMounts

func (api *API) ListMounts() ([]*Mount, error)

ListMounts fetches info about mounted sources

func (*API) MoveClients

func (api *API) MoveClients(from, to string) error

MoveClients moves clients from one source to another

func (*API) SetUserAgent

func (api *API) SetUserAgent(app, version string)

SetUserAgent set user-agent string based on app name and version

func (*API) UpdateFallback

func (api *API) UpdateFallback(mount, fallback string) error

UpdateFallback updates fallback for given mount source

func (*API) UpdateMeta

func (api *API) UpdateMeta(mount string, meta TrackMeta) error

UpdateMeta updates meta for given mount source

type AudioInfo

type AudioInfo struct {
	Bitrate    int
	Channels   int
	SampleRate int
	CodecID    int
	RawInfo    string
}

AudioInfo contains basic info about stream

type Listener

type Listener struct {
	ID        int    `xml:"ID"`
	IP        string `xml:"IP"`
	UserAgent string `xml:"UserAgent"`
	Referer   string `xml:"Referer"`
	Lag       int    `xml:"lag"`
	Connected int    `xml:"Connected"`
}

Listener contains info about listener

type Mount

type Mount struct {
	Path        string `xml:"mount,attr"`
	Listeners   int    `xml:"listeners"`
	Connected   int    `xml:"Connected"`
	ContentType string `xml:"content-type"`
}

Mount contains basic info about source mount

type ServerInfo

type ServerInfo struct {
	ID    string
	Build int
}

ServerInfo contains basic info about Icecast Server

type ServerStats

type ServerStats struct {
	BannedIPs               int
	ClientConnections       int
	Clients                 int
	Connections             int
	FileConnections         int
	ListenerConnections     int
	Listeners               int
	OutgoingBitrate         int
	SourceClientConnections int
	SourceRelayConnections  int
	SourceTotalConnections  int
	Sources                 int
	Stats                   int
	StatsConnections        int
	StreamBytesRead         int
	StreamBytesSent         int
}

ServerStats contains overall Icecast Server statistics

type Source

type Source struct {
	MetadataUpdated time.Time
	StreamStarted   time.Time
	Bitrate         string
	Genre           string
	ListenURL       string
	SourceIP        string
	UserAgent       string
	AudioInfo       *AudioInfo
	IceAudioInfo    *AudioInfo
	Info            *SourceInfo
	Stats           *SourceStats
	Track           *TrackInfo
	Public          bool
}

Source contains info about source

type SourceInfo

type SourceInfo struct {
	Name        string
	Description string
	Type        string
	URL         string
	SubType     string
}

SourceInfo contains basic source info

type SourceStats

type SourceStats struct {
	Connected           int
	IncomingBitrate     int
	OutgoingBitrate     int
	ListenerConnections int
	ListenerPeak        int
	Listeners           int
	MaxListeners        int
	QueueSize           int
	SlowListeners       int
	TotalBytesRead      int
	TotalBytesSent      int
}

SourceStats contains source statistics

type Sources

type Sources map[string]*Source

Sources contains info about all sources

type Stats

type Stats struct {
	Admin    string
	Host     string
	Started  time.Time
	Location string

	Info    *ServerInfo
	Stats   *ServerStats
	Sources Sources
}

Stats contains info about Icecast Server

func (*Stats) GetSource

func (s *Stats) GetSource(mount string) *Source

GetSource tries to find source with given mount point

type TrackInfo

type TrackInfo struct {
	Artist      string
	Title       string
	Artwork     string
	MetadataURL string
	RawInfo     string
}

TrackInfo contains info about current playing track

type TrackMeta

type TrackMeta struct {
	Song    string
	Title   string
	Artist  string
	URL     string
	Artwork string
	Charset string
	Intro   string
}

TrackMeta contains track meta

func (TrackMeta) ToQuery

func (m TrackMeta) ToQuery() string

ToQuery encodes meta for URL query

Jump to

Keyboard shortcuts

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