dahuacgi

package
v0.0.0-...-72e33f6 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package dahuacgi is a client library for Dahua's CGI API.

Index

Constants

View Source
const (
	HTTPTypeSinglePart = "singlepart"
	HTTPTypeMultiPart  = "multipart"
)

Variables

This section is empty.

Functions

func AudioInputChannelCount

func AudioInputChannelCount(ctx context.Context, c Conn) (int, error)

func AudioOutputChannelCount

func AudioOutputChannelCount(ctx context.Context, c Conn) (int, error)

func OK

func OK(res *http.Response, err error) (*http.Response, error)

Types

type AudioStream

type AudioStream struct {
	io.ReadCloser
	ContentType string
}

func AudioStreamGet

func AudioStreamGet(ctx context.Context, c Conn, channel int, httpType HTTPType) (AudioStream, error)

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(httpClient http.Client, u *url.URL, username, password string) Client

func (Client) Do

func (c Client) Do(ctx context.Context, r *Request) (*http.Response, error)

type Conn

type Conn interface {
	Do(ctx context.Context, req *Request) (*http.Response, error)
}

type Event

type Event struct {
	ContentType   string
	ContentLength int
	Code          string
	Action        string
	Index         int
	Data          json.RawMessage
}

type EventBoundary

type EventBoundary string
const DefaultEventBoundary EventBoundary = "myboundary"

type EventManager

type EventManager struct {
	io.ReadCloser
	Boundary EventBoundary
}

func EventManagerGet

func EventManagerGet(ctx context.Context, c Conn, heartbeat int) (EventManager, error)

func (EventManager) Reader

func (em EventManager) Reader() EventReader

type EventReader

type EventReader struct {
	// contains filtered or unexported fields
}

func NewEventReader

func NewEventReader(rd io.Reader, boundary EventBoundary) EventReader

func (EventReader) Poll

func (er EventReader) Poll() error

Poll waits for the next event boundary.

func (EventReader) ReadEvent

func (er EventReader) ReadEvent() (Event, error)

ReadEvent reads and parses the next event. This should be called after Poll.

type HTTPError

type HTTPError struct {
	StatusCode int
	Status     string
}

func (HTTPError) Error

func (e HTTPError) Error() string

type HTTPType

type HTTPType string

type Request

type Request struct {
	Header http.Header
	// contains filtered or unexported fields
}

func New

func New(method string) *Request

func (*Request) HeaderString

func (r *Request) HeaderString(key string, value string) *Request

func (*Request) QueryInt

func (r *Request) QueryInt(key string, value int) *Request

func (*Request) QueryString

func (r *Request) QueryString(key string, value string) *Request

func (*Request) Request

func (r *Request) Request(req *http.Request) *http.Request

func (*Request) URL

func (r *Request) URL(baseURL string) string

type Snapshot

type Snapshot struct {
	io.ReadCloser
	ContentType   string
	ContentLength string
}

func SnapshotGet

func SnapshotGet(ctx context.Context, c Conn, channel int) (Snapshot, error)

type Table

type Table []TableData

func OKTable

func OKTable(res *http.Response, err error) (Table, error)

func (Table) Get

func (t Table) Get(key string) string

type TableData

type TableData struct {
	Key   string
	Value string
}

Jump to

Keyboard shortcuts

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