Documentation ¶
Index ¶
- Constants
- func PackBits(width uint8, input []int32, w io.ByteWriter)
- type BitUnpacker
- type Builder
- type ByteReaderReader
- type Compressor
- type Decompressor
- type FieldWriter
- func (f *FieldWriter) Bytes() ([]byte, int)
- func (f *FieldWriter) Float32(code byte, v float32)
- func (f *FieldWriter) String(code byte, v string) error
- func (f *FieldWriter) Timestamp(code byte, t time.Time)
- func (f *FieldWriter) Uint16(code byte, v uint16)
- func (f *FieldWriter) Uint32(code byte, v uint32)
- func (f *FieldWriter) Uint64(code byte, v uint64)
- func (f *FieldWriter) Uint8(code byte, v uint8)
- type Fields
- func (f Fields) FPS() int
- func (f Fields) Float32(key byte) (float32, error)
- func (f Fields) ResX() int
- func (f Fields) ResY() int
- func (f Fields) String(key byte) (string, error)
- func (f Fields) Timestamp(key byte) (time.Time, error)
- func (f Fields) Uint16(key byte) (uint16, error)
- func (f Fields) Uint32(key byte) (uint32, error)
- func (f Fields) Uint64(key byte) (uint64, error)
- func (f Fields) Uint8(key byte) (uint8, error)
- type FileReader
- type FileWriter
- type Header
- type Parser
- type Reader
- func (r *Reader) Accuracy() float32
- func (r *Reader) Altitude() float32
- func (r *Reader) BrandName() string
- func (r *Reader) DeviceID() int
- func (r *Reader) DeviceName() string
- func (r *Reader) EmptyFrame() *cptvframe.Frame
- func (r *Reader) FPS() int
- func (r *Reader) FirmwareVersion() string
- func (r *Reader) FrameCount() (int, error)
- func (r *Reader) HasBackgroundFrame() bool
- func (r *Reader) Latitude() float32
- func (r *Reader) LocTimestamp() time.Time
- func (r *Reader) Longitude() float32
- func (r *Reader) ModelName() string
- func (r *Reader) MotionConfig() string
- func (r *Reader) PreviewSecs() int
- func (r *Reader) ReadFrame(out *cptvframe.Frame) error
- func (r *Reader) ResX() int
- func (r *Reader) ResY() int
- func (r *Reader) SerialNumber() int
- func (r *Reader) Timestamp() time.Time
- func (r *Reader) Version() int
- type Writer
Constants ¶
const ( HeaderSection = 'H' FrameSection = 'F' // Header field keys Timestamp byte = 'T' XResolution byte = 'X' YResolution byte = 'Y' Compression byte = 'C' DeviceName byte = 'D' DeviceID byte = 'I' MotionConfig byte = 'M' PreviewSecs byte = 'P' Latitude byte = 'L' Longitude byte = 'O' LocTimestamp byte = 'S' Altitude byte = 'A' Accuracy byte = 'U' FPS byte = 'Z' Model byte = 'E' Brand byte = 'B' Firmware byte = 'V' CameraSerial byte = 'N' // Frame field keys TimeOn byte = 't' BitWidth byte = 'w' FrameSize byte = 'f' LastFFCTime byte = 'c' TempC byte = 'a' LastFFCTempC byte = 'b' BackgroundFrame byte = 'g' )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type BitUnpacker ¶
type BitUnpacker struct {
// contains filtered or unexported fields
}
BitUnpacker extracts signed integers, packed at some bit width, from a bitstream.
func NewBitUnpacker ¶
func NewBitUnpacker(width uint8, r io.ByteReader) *BitUnpacker
NewBitUnpacker creates a new BitUnpacker. Integers will be extracted from the ByteReader and are expected to be packed at the bit width specified.
func (*BitUnpacker) Next ¶
func (u *BitUnpacker) Next() (int32, error)
Next returns the next signed integer from the bitstream.
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
Builder handles the low-level construction of CPTV sections and fields. See Writer for a higher-level interface.
func NewBuilder ¶
NewBuilder returns a new Builder instance, ready to emit a gzip compressed CPTV file to the provided Writer.
func (*Builder) WriteFrame ¶
func (b *Builder) WriteFrame(f *FieldWriter, frameData []byte) error
WriteFrame writes a CPTV frame to the current Writer
func (*Builder) WriteHeader ¶
func (b *Builder) WriteHeader(f *FieldWriter) error
WriteHeader writes a CPTV header to the current Writer
type ByteReaderReader ¶
type ByteReaderReader interface { io.Reader io.ByteReader }
ByteReaderReader combines io.Reader and io.ByteReader.
type Compressor ¶
type Compressor struct {
// contains filtered or unexported fields
}
Compressor generates a compressed representation of successive Frames, returning CPTV frames.
func NewCompressor ¶
func NewCompressor(c cptvframe.CameraSpec) *Compressor
NewCompressor creates a new Compressor.
func (*Compressor) Next ¶
func (c *Compressor) Next(curr *cptvframe.Frame) (uint8, []byte)
Next takes the next Frame in a recording and converts it to a compressed stream of bytes. The bit width used for packing is also returned (this is required for unpacking).
IMPORTANT: The returned byte slice is reused and therefore is only valid until the next call to Next.
type Decompressor ¶
type Decompressor struct {
// contains filtered or unexported fields
}
Decompressor is used to decompress successive CPTV frames. See the Next() method.
func NewDecompressor ¶
func NewDecompressor(c cptvframe.CameraSpec) *Decompressor
NewDecompressor creates a new Decompressor.
func (*Decompressor) Next ¶
func (d *Decompressor) Next(bitWidth uint8, compressed ByteReaderReader, out *cptvframe.Frame) error
Next reads of stream of bytes as a ByteReaderReader and decompresses them using the bit width provided into the Frame provided.
type FieldWriter ¶
type FieldWriter struct {
// contains filtered or unexported fields
}
FieldWriter generates CPTV encoded fields.
func (*FieldWriter) Bytes ¶
func (f *FieldWriter) Bytes() ([]byte, int)
Bytes returns the encoded header and the number of fields represented.
func (*FieldWriter) Float32 ¶
func (f *FieldWriter) Float32(code byte, v float32)
Float32 writes a float32 field with key 'code' and value 'v'
func (*FieldWriter) String ¶
func (f *FieldWriter) String(code byte, v string) error
String writes a character string field with key 'code' and value 'v'
func (*FieldWriter) Timestamp ¶
func (f *FieldWriter) Timestamp(code byte, t time.Time)
Timestamp writes a time field with key 'code' and value 'v'
func (*FieldWriter) Uint16 ¶
func (f *FieldWriter) Uint16(code byte, v uint16)
Uint16 writes a uint16 field with key 'code' and value 'v'
func (*FieldWriter) Uint32 ¶
func (f *FieldWriter) Uint32(code byte, v uint32)
Uint32 writes a uint32 field with key 'code' and value 'v'
func (*FieldWriter) Uint64 ¶
func (f *FieldWriter) Uint64(code byte, v uint64)
Uint64 writes a uint64 field with key 'code' and value 'v'
func (*FieldWriter) Uint8 ¶
func (f *FieldWriter) Uint8(code byte, v uint8)
Uint8 writes a uint8 field with key 'code' and value 'v'
type Fields ¶
Fields maps from field key -> field data
func ReadFields ¶
ReadFields reads the fields for a CPTV section, returning a new Fields instance.
type FileReader ¶
type FileReader struct { *Reader // contains filtered or unexported fields }
FileReader wraps a Reader and provides a convenient way of reading a CPTV stream from a disk file.
func NewFileReader ¶
func NewFileReader(filename string) (*FileReader, error)
NewFileReader returns a new FileReader from the filename.
func (*FileReader) Name ¶
func (fr *FileReader) Name() string
Name returns the name of the file being read
type FileWriter ¶
type FileWriter struct { *Writer // contains filtered or unexported fields }
FileWriter wraps a Writer and provides a convenient way of writing a CPTV stream to a disk file.
func NewFileWriter ¶
func NewFileWriter(filename string, c cptvframe.CameraSpec) (*FileWriter, error)
NewFileWriter creates file 'filename' and returns a new FileWriter with underlying buffer (bufio) Writer
func (*FileWriter) Close ¶
func (fw *FileWriter) Close()
Close flushes the buffered writer and closes the open file
func (*FileWriter) Name ¶
func (fw *FileWriter) Name() string
Name returns the name of the open File
type Header ¶
type Header struct { Timestamp time.Time DeviceName string DeviceID int CameraSerial int Firmware string PreviewSecs int MotionConfig string Latitude float32 Longitude float32 LocTimestamp time.Time Altitude float32 Accuracy float32 FPS int Brand string Model string BackgroundFrame *cptvframe.Frame }
Header defines the information stored in the header of a CPTV file. All the fields are optional.
type Parser ¶
type Parser struct {
// contains filtered or unexported fields
}
Parser is the low-level type for pulling apart the sections and fields of a CPTV file. See Reader for a high-level interface.
func NewParser ¶
NewParser returns a new Parser instance, for parsing a gzip compressed CPTV stream using the provided io.Reader.
Providing a buffered Reader is preferable.
type Reader ¶
type Reader struct {
// contains filtered or unexported fields
}
Reader uses a Parser and Decompressor to read CPTV recordings.
func (*Reader) Accuracy ¶
Accuracy returns the estimated accuracy of the location setting of the device when this CPTV file was recorded. Returns 0 if the field is not included.
func (*Reader) Altitude ¶
Altitude returns the altitude part of the location of the device when this CPTV file was recorded. Returns 0 if the field is not included.
func (*Reader) BrandName ¶
header returns the camera brand name field from the CPTV recording. Returns an empty string if the brand name field wasn't present.
func (*Reader) DeviceID ¶
DeviceID returns the device id field from the CPTV recording. Returns an empty int if the device id field wasn't present.
func (*Reader) DeviceName ¶
DeviceName returns the device name field from the CPTV recording. Returns an empty string if the device name field wasn't present.
func (*Reader) EmptyFrame ¶
EmptyFrame returns an initialized cptvframe.Frame sized accordingly to the CPTV file frames.
func (*Reader) FirmwareVersion ¶
Get the firmware version of the camera module, if present
func (*Reader) FrameCount ¶
FrameCount returns the remaining number of frames in a CPTV file. After this call, all remaining frames will have been consumed.
func (*Reader) HasBackgroundFrame ¶
func (*Reader) Latitude ¶
Latitude returns the latitude part of the location of the device when this CPTV file was recorded. Returns 0 if the field is not included.
func (*Reader) LocTimestamp ¶
LocTimestamp returns the timestamp at which the location of the device. Returns the nil time.Time value if the field is not included.
func (*Reader) Longitude ¶
Longitude returns the longitude part of the location of the device when this CPTV file was recorded. Returns 0 if the field is not included.
func (*Reader) ModelName ¶
Model returns the camera model name field from the CPTV recording. Returns an empty string if the model name field wasn't present.
func (*Reader) MotionConfig ¶
MotionConfig returns the YAML configuration for the motion detector that was in use when this CPTV file was recorded. Returns an empty string if this field is not included.
func (*Reader) PreviewSecs ¶
PreviewSecs returns the number of seconds included in the recording before motion was detected. Returns 0 if this field is not included.
func (*Reader) ReadFrame ¶
ReadFrame extracts and decompresses the next frame in a CPTV recording. At the end of the recording an io.EOF error will be returned.
func (*Reader) SerialNumber ¶
Get the camera module serial number if present
type Writer ¶
type Writer struct {
// contains filtered or unexported fields
}
Writer uses a Builder and Compressor to create CPTV files.
func NewWriter ¶
func NewWriter(w io.Writer, c cptvframe.CameraSpec) *Writer
NewWriter creates and returns a new Writer component
func (*Writer) WriteFrame ¶
WriteFrame writes a CPTV frame
func (*Writer) WriteHeader ¶
WriteHeader writes a CPTV file header