rtsptowebrtc

package module
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2024 License: MIT Imports: 14 Imported by: 0

README

Go - RTSPtoWebRTC

RTSP Stream to WebBrowser over WebRTC based on Pion (full native! not using ffmpeg or gstreamer).

Note: This repository is a fork of RTSPtoWebRTC

The goal of this fork is to create a dynamic way of restreaming a rtsp connection to webrtc

Installation

go get github.com/salfel/RTSPtoWebRTC

Api

Set config

rtsptowebrtc.SetConfig(&rtsptowebrtc.ConfigST{
   Server: rtsptowebrtc.ServerST{
      ICEServers: []string{"stun:stun.l.google.com:19302"},
   },
})

Serve Routes (only gin for now)

r := gin.Default()

rtsptowebrtc.ServeGin(r)

Start Stream

rtsptowebrtc.ServeStream(client.Channel, rtsptowebrtc.StreamST{
   OnDemand:     false,
   DisableAudio: true,
   URL:          "rtsp://127.0.0.1:8554/stream",
})

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrorStreamExitNoVideoOnStream = errors.New("Stream Exit No Video On Stream")
	ErrorStreamExitRtspDisconnect  = errors.New("Stream Exit Rtsp Disconnect")
	ErrorStreamExitNoViewer        = errors.New("Stream Exit On Demand No Viewer")
)

Functions

func CORSMiddleware

func CORSMiddleware() gin.HandlerFunc

func HTTPAPIServerStreamCodec

func HTTPAPIServerStreamCodec(c *gin.Context)

HTTPAPIServerStreamCodec stream codec

func HTTPAPIServerStreamWebRTC

func HTTPAPIServerStreamWebRTC(c *gin.Context)

HTTPAPIServerStreamWebRTC stream video over WebRTC

func HTTPAPIServerStreamWebRTC2

func HTTPAPIServerStreamWebRTC2(c *gin.Context)

func RTSPWorker

func RTSPWorker(name string, ctx context.Context, url string, OnDemand, DisableAudio, Debug bool) (error, bool)

func RTSPWorkerLoop

func RTSPWorkerLoop(name string, ctx context.Context, url string, OnDemand, DisableAudio, Debug bool)

func RemoveStream added in v0.1.3

func RemoveStream(name string)

func ServeGin

func ServeGin(router *gin.Engine)

func ServeStream

func ServeStream(name string, config StreamST)

func SetConfig

func SetConfig(c *ConfigST)

Types

type ConfigST

type ConfigST struct {
	Server    ServerST            `json:"server"`
	Streams   map[string]StreamST `json:"streams"`
	LastError error
	// contains filtered or unexported fields
}

ConfigST struct

var Config *ConfigST

Config global

func (*ConfigST) GetICECredential

func (element *ConfigST) GetICECredential() string

func (*ConfigST) GetICEServers

func (element *ConfigST) GetICEServers() []string

func (*ConfigST) GetICEUsername

func (element *ConfigST) GetICEUsername() string

func (*ConfigST) GetWebRTCPortMax

func (element *ConfigST) GetWebRTCPortMax() uint16

func (*ConfigST) GetWebRTCPortMin

func (element *ConfigST) GetWebRTCPortMin() uint16

func (*ConfigST) HasViewer

func (element *ConfigST) HasViewer(uuid string) bool

func (*ConfigST) List

func (element *ConfigST) List() (string, []string)

func (*ConfigST) RunIFNotRun

func (element *ConfigST) RunIFNotRun(uuid string)

func (*ConfigST) RunUnlock

func (element *ConfigST) RunUnlock(uuid string)

type JCodec

type JCodec struct {
	Type string
}

type Response

type Response struct {
	Tracks []string `json:"tracks"`
	Sdp64  string   `json:"sdp64"`
}

type ResponseError

type ResponseError struct {
	Error string `json:"error"`
}

type ServerST

type ServerST struct {
	HTTPPort      string   `json:"http_port"`
	ICEServers    []string `json:"ice_servers"`
	ICEUsername   string   `json:"ice_username"`
	ICECredential string   `json:"ice_credential"`
	WebRTCPortMin uint16   `json:"webrtc_port_min"`
	WebRTCPortMax uint16   `json:"webrtc_port_max"`
}

ServerST struct

type StreamST

type StreamST struct {
	URL          string `json:"url"`
	Status       bool   `json:"status"`
	OnDemand     bool   `json:"on_demand"`
	DisableAudio bool   `json:"disable_audio"`
	Debug        bool   `json:"debug"`
	RunLock      bool   `json:"-"`
	Codecs       []av.CodecData
	Cl           map[string]viewer
	Cancel       context.CancelFunc
}

StreamST struct

Jump to

Keyboard shortcuts

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