actioncam: github.com/jonas-koeritz/actioncam/libipcamera Index | Examples | Files

package libipcamera

import "github.com/jonas-koeritz/actioncam/libipcamera"

Index

Examples

Package Files

Camera.go Discovery.go RTPRelay.go protocol.go

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
)

func AutodiscoverCamera Uses

func AutodiscoverCamera(verbose bool) (net.IP, error)

AutodiscoverCamera will try to find a camera using UDP Broadcasts

func CreateCommandPacket Uses

func CreateCommandPacket(command uint32) []byte

CreateCommandPacket prepares a command packet to be sent to the camera

func CreateLoginPacket Uses

func CreateLoginPacket(username, password string) []byte

CreateLoginPacket creates a Login packet to be sent to the camera

func CreatePacket Uses

func CreatePacket(header Header, payload []byte) []byte

CreatePacket creates a packet ready to be sent to the camera

Code:

// 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

type Camera Uses

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

Camera contains all information and features on a single IP Camera

func CreateCamera Uses

func CreateCamera(ipAddress net.IP, port int, username, password string) (*Camera, error)

CreateCamera creates a new Camera instance

Code:

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)
}

func (*Camera) Connect Uses

func (c *Camera) Connect()

Connect to the camera and start responding to keepalive packets

func (*Camera) Disconnect Uses

func (c *Camera) Disconnect()

Disconnect from the camera

func (*Camera) GetFileList Uses

func (c *Camera) GetFileList() ([]StoredFile, error)

GetFileList retrieves a list of files stored on the cameras SD-Card

func (*Camera) GetFirmwareInfo Uses

func (c *Camera) GetFirmwareInfo() (string, error)

GetFirmwareInfo will request firmware information from the camera

func (*Camera) Handle Uses

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 Uses

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 Uses

func (c *Camera) IsConnected() bool

IsConnected returns true if the camera connection has not been disconnected

func (*Camera) Log Uses

func (c *Camera) Log(format string, data ...interface{})

Log will write to stdout if this camera has been set to be verbose

func (*Camera) Login Uses

func (c *Camera) Login() error

Login will try to login to the camera control service

func (*Camera) SendPacket Uses

func (c *Camera) SendPacket(packet []byte) error

SendPacket sends a raw packet to the camera

func (*Camera) SetVerbose Uses

func (c *Camera) SetVerbose(verbose bool)

SetVerbose changes the verbosity setting of this camera object

func (*Camera) StartPreviewStream Uses

func (c *Camera) StartPreviewStream() error

StartPreviewStream starts streaming video to this host

func (*Camera) StartRecording Uses

func (c *Camera) StartRecording() error

StartRecording starts recording video to SD-Card

func (*Camera) StopRecording Uses

func (c *Camera) StopRecording() error

StopRecording stops recording video to SD-Card

func (*Camera) TakePicture Uses

func (c *Camera) TakePicture() error

TakePicture instructs the camera to take a still image

type Header struct {
    Magic       uint16
    Length      uint16
    MessageType uint32
}

Header is an ipcamera protocol message header

func CreateCommandHeader Uses

func CreateCommandHeader(command uint32) Header

CreateCommandHeader prepares a packet header for command packets

func (*Header) String Uses

func (h *Header) String() string

type Message Uses

type Message struct {
    Header  Header
    Payload []byte
}

Message represents a complete message from/to the camera

func (*Message) String Uses

func (m *Message) String() string

type MessageHandler Uses

type MessageHandler func(camera *Camera, message *Message) (bool, error)

MessageHandler is used to process incoming messages from the camera

type RTPRelay Uses

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

RTPRelay holds information on the relaying stream listener

func CreateRTPRelay Uses

func CreateRTPRelay(ctx context.Context, targetAddress net.IP, targetPort int) *RTPRelay

CreateRTPRelay creates a UDP listener that handles live data from the camera and forwards it as an RTP stream

func (*RTPRelay) Stop Uses

func (r *RTPRelay) Stop()

Stop stops listening for packets

type StoredFile Uses

type StoredFile struct {
    Path string
    Size uint64
}

StoredFile is a file stored on the cameras sd-card

Package libipcamera imports 13 packages (graph) and is imported by 2 packages. Updated 2019-10-15. Refresh now. Tools for package owners.