videoserver

package module
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2020 License: MIT Imports: 20 Imported by: 0

README

GoDoc Sourcegraph Go Report Card GitHub tag

Golang-based video-server for re-streaming RTSP to HLS/MSE

Table of Contents

About

Simple WS/HTTP server for re-streaming video (RTSP) to client in MSE/HLS format.

Instalation

Binaries

Linux - link

Windows - link

From source
go get github.com/LdDl/video-server
# or just clone it
# git clone https://github.com/LdDl/video-server.git

Go to root folder of downloaded repository, move to cmd/video_server folder:

cd $CLONED_PATH/cmd/video_server
go build -o video_server main.go

Usage

video_server -h
-conf string
    Path to configuration JSON-file (default "conf.json")
-cpuprofile file
    write cpu profile to file
-memprofile file
    write memory profile to file
Start server

Prepare configuration file (example here). Then run binary:

video_server --conf=conf.json
Test Client-Server

For HLS-based player go to hls-subdirectory.

For MSE-based (websockets) player go to mse-subdirectory.

Then follow this set of commands:

npm install
npm run dev

You will se something like this after succesfull fron-end start:

DONE  Compiled successfully in 1783ms                                                                                                                                                                         12:09:30 PM
App running at:
- Local:   http://localhost:8080/ 

Paste link to the browser and check if video loaded successfully.

Dependencies

GIN web-framework - https://github.com/gin-gonic/gin. License is MIT

Media library - http://github.com/deepch/vdk. License is MIT. We are using fork actually - https://github.com/morozka/vdk

UUID generation and parsing - https://github.com/google/uuid. License is BSD 3-Clause

Websockets - https://github.com/gorilla/websocket. License is BSD 2-Clause

m3u8 library - https://github.com/grafov/m3u8. License is BSD 3-Clause

errors wrapping - https://github.com/pkg/errors . License is BSD 2-Clause

License

You can check it here

Developers

Roman - https://github.com/webver

Pavel - https://github.com/Pavel7824

Dimitrii Lopanov - https://github.com/LdDl

Morozka - https://github.com/morozka

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrStreamNotFound When map of streams doesn't contain requested key
	ErrStreamNotFound = fmt.Errorf("Stream not found for provided ID")
)

Functions

func HLSWrapper added in v0.2.0

func HLSWrapper(app *Application) func(ctx *gin.Context)

HLSWrapper Returns HLS handler (static files)

func ListWrapper added in v0.2.0

func ListWrapper(app *Application) func(ctx *gin.Context)

ListWrapper Returns list of streams

func StatusWrapper added in v0.2.0

func StatusWrapper(app *Application) func(ctx *gin.Context)

StatusWrapper Returns statuses for list of streams

func WebSocketWrapper added in v0.2.0

func WebSocketWrapper(app *Application, wsUpgrader *websocket.Upgrader) func(ctx *gin.Context)

WebSocketWrapper Returns WS handler

Types

type Application added in v0.2.0

type Application struct {
	Server          *ServerInfo  `json:"server"`
	Streams         StreamsMap   `json:"streams"`
	HlsMsPerSegment int64        `json:"hls_ms_per_segment"`
	HlsDirectory    string       `json:"hls_directory"`
	HlsWindowSize   uint         `json:"hls_window_size"`
	HlsCapacity     uint         `json:"hls_window_capacity"`
	CorsConfig      *cors.Config `json:"-"`
}

Application Configuration parameters for application

func NewApplication added in v0.2.0

func NewApplication(cfg *ConfigurationArgs) (*Application, error)

NewApplication Prepare configuration for application

func (*Application) StartHTTPServer added in v0.2.0

func (app *Application) StartHTTPServer()

StartHTTPServer Initialize http server and run it

func (*Application) StartStreams added in v0.2.0

func (app *Application) StartStreams()

StartStreams Start video streams

type ConfigurationArgs

type ConfigurationArgs struct {
	Server          ServerConfiguration `json:"server"`
	Streams         []StreamArg         `json:"streams"`
	HlsMsPerSegment int64               `json:"hls_ms_per_segment"`
	HlsDirectory    string              `json:"hls_directory"`
	HlsWindowSize   uint                `json:"hls_window_size"`
	HlsCapacity     uint                `json:"hls_window_capacity"`
	CorsConfig      CorsConfiguration   `json:"cors_config"`
}

ConfigurationArgs Configuration parameters for application as JSON-file

func NewConfiguration added in v0.2.0

func NewConfiguration(fname string) (*ConfigurationArgs, error)

NewConfiguration Constructor for ConfigurationArgs

type CorsConfiguration added in v0.3.0

type CorsConfiguration struct {
	UseCORS          bool     `json:"use_cors"`
	AllowOrigins     []string `json:"allow_origins"`
	AllowMethods     []string `json:"allow_methods"`
	AllowHeaders     []string `json:"allow_headers"`
	ExposeHeaders    []string `json:"expose_headers"`
	AllowCredentials bool     `json:"allow_credentials"`
}

CorsConfiguration Configuration of CORS requests

type ServerConfiguration

type ServerConfiguration struct {
	HTTPAddr string `json:"http_addr"`
	HTTPPort int    `json:"http_port"`
}

ServerConfiguration Configuration parameters for server

type ServerInfo added in v0.2.0

type ServerInfo struct {
	HTTPAddr string `json:"http_addr"`
	HTTPPort int    `json:"http_port"`
}

ServerInfo Information about server

type StreamArg

type StreamArg struct {
	GUID        string   `json:"guid"`
	URL         string   `json:"url"`
	StreamTypes []string `json:"stream_types"`
}

StreamArg Infromation about stream's source

type StreamConfiguration

type StreamConfiguration struct {
	URL                  string   `json:"url"`
	Status               bool     `json:"status"`
	SupportedStreamTypes []string `json:"supported_stream_types"`
	Codecs               []av.CodecData
	Clients              map[uuid.UUID]viewer
	// contains filtered or unexported fields
}

StreamConfiguration Configuration parameters for stream

type StreamsMap added in v0.2.0

type StreamsMap struct {
	sync.Mutex
	Streams map[uuid.UUID]*StreamConfiguration
}

StreamsMap Map wrapper for map[uuid.UUID]*StreamConfiguration with mutex for concurrent usage

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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