Documentation
¶
Overview ¶
Author: Benehiko Modified Date: 2020/12/10 Contact: alanoterblanche@gmail.com | https://github.com/Benehiko
RtspClient is greatly inspired by github.com/deepch/RTSPtoWebRTC RtspClient only wraps and simplifies their code to fit inside this library.
Author: Benehiko Modified Date: 2020/12/10 Contact: alanoterblanche@gmail.com | https://github.com/Benehiko
WebRtcClient is greatly inspired by github.com/deepch/RTSPtoWebRTC WebRtcClient only wraps and simplifies their code to fit inside this library.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type GeneralData ¶
type GeneralData struct {
Cmd string `json:"cmd"`
Code int `json:"code"`
Value map[string]json.RawMessage `json:"value,omitempty"`
Initial map[string]json.RawMessage `json:"initial,omitempty"`
Range map[string]json.RawMessage `json:"range,omitempty"`
}
type OptionRestHandler ¶
type OptionRestHandler func(*RestHandler)
func RestHandlerOptionEndpoint ¶
func RestHandlerOptionEndpoint(endpoint string) OptionRestHandler
Change the default endpoint to a custom endpoint Default is "/cgi-bin/api.cgi" If for some reason the camera you are using is different, one can update it here.
func RestHandlerOptionHttp ¶
func RestHandlerOptionHttp(https bool) OptionRestHandler
Change the default scheme from HTTP to HTTPS
func RestHandlerOptionPort ¶
func RestHandlerOptionPort(port int) OptionRestHandler
Change the default port to a custom port. Default is unset due to http being the default protocol
func RestHandlerOptionProxy ¶
func RestHandlerOptionProxy(proxy Proxy, host string, port int, auth *RestHandlerProxyAuth, protocol *Protocol) OptionRestHandler
Add a proxy layer on top of the current connection
type OptionRtspClient ¶
type OptionRtspClient func(*RtspClient)
func RtspClientOptionDebug ¶
func RtspClientOptionDebug(debug bool) OptionRtspClient
func RtspClientOptionRetryCount ¶
func RtspClientOptionRetryCount(retryCount int) OptionRtspClient
func RtspClientOptionTimeout ¶
func RtspClientOptionTimeout(timeout time.Duration) OptionRtspClient
type RestHandler ¶
type RestHandler struct {
Host string
Port int
Endpoint string
Proxy *RestHandlerProxy
HTTPS bool
*RestAuth
}
func NewRestHandler ¶
func NewRestHandler(host string, options ...OptionRestHandler) *RestHandler
Create a new RestHandler object with optional argument using Variadic options pattern for customisation Refer to the RestHandlerOption<option_name> functions RestHandler is used to wrap the http package and give a cleaner more defined scope which the person implementing the library will have full control over. https://stackoverflow.com/a/26326418
func (*RestHandler) Request ¶
func (rh *RestHandler) Request(method string, payload interface{}, command string, auth bool) (*GeneralData, error)
Do the http request endpoint: the trailing part of the URL after the port. method: GET or POST payload: the json data auth: alters the request to include auth token on true
func (*RestHandler) SetToken ¶
func (rh *RestHandler) SetToken(token string)
func (*RestHandler) SetUsernamePassword ¶
func (rh *RestHandler) SetUsernamePassword(username string, password string)
type RestHandlerProxy ¶
type RestHandlerProxy struct {
Type Proxy
Protocol *Protocol
Host string
Port int
Auth *RestHandlerProxyAuth
}
type RestHandlerProxyAuth ¶
type RtspClient ¶
type RtspClient struct {
UUID string
Timeout time.Duration
URL string
Debug bool
RetryCount int
Stream *Stream
}
func NewRtspClient ¶
func NewRtspClient(url string, rtspOptions ...OptionRtspClient) *RtspClient
Create a new RTSP client Defaults: Timeout: 10 * time.Second Debug: false RetryCount: 5
func (*RtspClient) OpenStream ¶
func (rc *RtspClient) OpenStream()
type Stream ¶
stream contains all the necessary information of the stream. stream packet contains audio and video
type WebRtcClient ¶
type WebRtcClient struct {
Ready chan bool
SDP chan string
RTSP *RtspClient
}
func NewWebRtcClient ¶
func NewWebRtcClient(rtspClient *RtspClient) *WebRtcClient
func (*WebRtcClient) OpenWebRtcStream ¶
func (wrtc *WebRtcClient) OpenWebRtcStream(sdpData string)
Open a WebRTC Stream from the RTSP Stream Credit for most of this code goes to deepch https://github.com/deepch/RTSPtoWebRTC