Documentation ¶
Index ¶
- Constants
- func AutodiscoverCamera(verbose bool) (net.IP, error)
- func CreateCommandPacket(command uint32) []byte
- func CreateLoginPacket(username, password string) []byte
- func CreatePacket(header Header, payload []byte) []byte
- type Camera
- func (c *Camera) Connect()
- func (c *Camera) Disconnect()
- func (c *Camera) GetFileList() ([]StoredFile, error)
- func (c *Camera) GetFirmwareInfo() (string, error)
- func (c *Camera) Handle(messageType uint32, handleFunc MessageHandler)
- func (c *Camera) HandleFirst(messageType uint32, handleFunc MessageHandler)
- func (c *Camera) IsConnected() bool
- func (c *Camera) Log(format string, data ...interface{})
- func (c *Camera) Login() error
- func (c *Camera) SendPacket(packet []byte) error
- func (c *Camera) SetVerbose(verbose bool)
- func (c *Camera) StartPreviewStream() error
- func (c *Camera) StartRecording() error
- func (c *Camera) StopRecording() error
- func (c *Camera) TakePicture() error
- type Header
- type Message
- type MessageHandler
- type RTPRelay
- type StoredFile
Examples ¶
Constants ¶
const ( LOGIN = 0x0110 LOGIN_ACCEPT = 0x0111 ALIVE_REQUEST = 0x0112 ALIVE_RESPONSE = 0x0113 DISCOVERY_REQUEST = 0x0114 DISCOVERY_RESPONSE = 0x0115 START_PREVIEW = 0x01FF REQUEST_FILE_LIST = 0xA025 FILE_LIST_CONTENT = 0xA026 REQUEST_FIRMWARE_INFO = 0xA034 FIRMWARE_INFORMATION = 0xA035 TAKE_PICTURE = 0xA038 PICTURE_SAVED = 0xA039 CONTROL_RECORDING = 0xA03A RECORD_COMMAND_ACCEPT = 0xA03B )
const ( // RemoveHandler instructs the network code to remove this handler after execution RemoveHandler = true // KeepHandler instructs the network code to keep this handler after execution KeepHandler = false )
Variables ¶
This section is empty.
Functions ¶
func AutodiscoverCamera ¶
AutodiscoverCamera will try to find a camera using UDP Broadcasts
func CreateCommandPacket ¶
CreateCommandPacket prepares a command packet to be sent to the camera
func CreateLoginPacket ¶
CreateLoginPacket creates a Login packet to be sent to the camera
func CreatePacket ¶
CreatePacket creates a packet ready to be sent to the camera
Example ¶
// Prepare a Header header := CreateCommandHeader(TAKE_PICTURE) payload := []byte{} // Create the packet packet := CreatePacket(header, payload) fmt.Printf("Packet Data: %X\n", packet)
Output: Packet Data: ABCD00000000A038
Types ¶
type Camera ¶
type Camera struct {
// contains filtered or unexported fields
}
Camera contains all information and features on a single IP Camera
func CreateCamera ¶
CreateCamera creates a new Camera instance
Example ¶
cameraIP := net.ParseIP("192.168.0.1") // Create a camera camera := CreateCamera(cameraIP, 6666, "admin", "12345") defer camera.Disconnect() // Enable verbose output for debugging camera.SetVerbose(true) // Connect to the camera and start responding to keep-alive messages camera.Connect() // Send a login packet to enable camera control err := camera.Login() if err != nil { fmt.Printf("Failed to Login: %s\n", err) } // Make the camera take a still image err = camera.TakePicture() if err != nil { fmt.Printf("Failed to take a picture: %s\n", err) }
Output:
func (*Camera) Connect ¶
func (c *Camera) Connect()
Connect to the camera and start responding to keepalive packets
func (*Camera) GetFileList ¶
func (c *Camera) GetFileList() ([]StoredFile, error)
GetFileList retrieves a list of files stored on the cameras SD-Card
func (*Camera) GetFirmwareInfo ¶
GetFirmwareInfo will request firmware information from the camera
func (*Camera) Handle ¶
func (c *Camera) Handle(messageType uint32, handleFunc MessageHandler)
Handle adds a new message handler to the list of message handlers for a given message type
func (*Camera) HandleFirst ¶
func (c *Camera) HandleFirst(messageType uint32, handleFunc MessageHandler)
HandleFirst adds a new message handler to the start of the list of message handlers for a given message type
func (*Camera) IsConnected ¶
IsConnected returns true if the camera connection has not been disconnected
func (*Camera) SendPacket ¶
SendPacket sends a raw packet to the camera
func (*Camera) SetVerbose ¶
SetVerbose changes the verbosity setting of this camera object
func (*Camera) StartPreviewStream ¶
StartPreviewStream starts streaming video to this host
func (*Camera) StartRecording ¶
StartRecording starts recording video to SD-Card
func (*Camera) StopRecording ¶
StopRecording stops recording video to SD-Card
func (*Camera) TakePicture ¶
TakePicture instructs the camera to take a still image
type Header ¶
Header is an ipcamera protocol message header
func CreateCommandHeader ¶
CreateCommandHeader prepares a packet header for command packets
type MessageHandler ¶
MessageHandler is used to process incoming messages from the camera
type RTPRelay ¶
type RTPRelay struct {
// contains filtered or unexported fields
}
RTPRelay holds information on the relaying stream listener
func CreateRTPRelay ¶
CreateRTPRelay creates a UDP listener that handles live data from the camera and forwards it as an RTP stream
type StoredFile ¶
StoredFile is a file stored on the cameras sd-card