mirror of https://bitbucket.org/ausocean/av.git
device/geovision: renamed gvctrl package to config
This commit is contained in:
parent
9c027d857f
commit
772c381293
|
@ -22,8 +22,6 @@ LICENSE
|
||||||
in gpl.txt. If not, see http://www.gnu.org/licenses.
|
in gpl.txt. If not, see http://www.gnu.org/licenses.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Package gvctrl-cli provides a command line interface for controlling GeoVision
|
|
||||||
// camera settings using the gvctrl package.
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -31,7 +29,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"bitbucket.org/ausocean/av/device/geovision/gvctrl"
|
"bitbucket.org/ausocean/av/device/geovision/config"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
@ -48,51 +46,51 @@ func main() {
|
||||||
)
|
)
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
var options []gvctrl.Option
|
var options []config.Option
|
||||||
|
|
||||||
if *codecPtr != "" {
|
if *codecPtr != "" {
|
||||||
var c gvctrl.Codec
|
var c config.Codec
|
||||||
switch *codecPtr {
|
switch *codecPtr {
|
||||||
case "h264":
|
case "h264":
|
||||||
c = gvctrl.CodecH264
|
c = config.CodecH264
|
||||||
case "h265":
|
case "h265":
|
||||||
c = gvctrl.CodecH265
|
c = config.CodecH265
|
||||||
case "mjpeg":
|
case "mjpeg":
|
||||||
c = gvctrl.CodecMJPEG
|
c = config.CodecMJPEG
|
||||||
default:
|
default:
|
||||||
panic(fmt.Sprintf("invalid codec: %s", *codecPtr))
|
panic(fmt.Sprintf("invalid codec: %s", *codecPtr))
|
||||||
}
|
}
|
||||||
options = append(options, gvctrl.CodecOut(c))
|
options = append(options, config.CodecOut(c))
|
||||||
}
|
}
|
||||||
|
|
||||||
if *heightPtr != 0 {
|
if *heightPtr != 0 {
|
||||||
options = append(options, gvctrl.Height(*heightPtr))
|
options = append(options, config.Height(*heightPtr))
|
||||||
}
|
}
|
||||||
|
|
||||||
if *fpsPtr != 0 {
|
if *fpsPtr != 0 {
|
||||||
options = append(options, gvctrl.FrameRate(*fpsPtr))
|
options = append(options, config.FrameRate(*fpsPtr))
|
||||||
}
|
}
|
||||||
|
|
||||||
options = append(options, gvctrl.VariableBitrate(*vbrPtr))
|
options = append(options, config.VariableBitrate(*vbrPtr))
|
||||||
|
|
||||||
if *vbrQualityPtr != -1 {
|
if *vbrQualityPtr != -1 {
|
||||||
options = append(options, gvctrl.VBRQuality(gvctrl.Quality(strconv.Itoa(*vbrQualityPtr))))
|
options = append(options, config.VBRQuality(config.Quality(strconv.Itoa(*vbrQualityPtr))))
|
||||||
}
|
}
|
||||||
|
|
||||||
if *vbrRatePtr != 0 {
|
if *vbrRatePtr != 0 {
|
||||||
options = append(options, gvctrl.VBRBitrate(*vbrRatePtr))
|
options = append(options, config.VBRBitrate(*vbrRatePtr))
|
||||||
}
|
}
|
||||||
|
|
||||||
if *cbrRatePtr != 0 {
|
if *cbrRatePtr != 0 {
|
||||||
options = append(options, gvctrl.CBRBitrate(*cbrRatePtr))
|
options = append(options, config.CBRBitrate(*cbrRatePtr))
|
||||||
}
|
}
|
||||||
|
|
||||||
if *refreshPtr != 0 {
|
if *refreshPtr != 0 {
|
||||||
options = append(options, gvctrl.Refresh(*refreshPtr))
|
options = append(options, config.Refresh(*refreshPtr))
|
||||||
}
|
}
|
||||||
|
|
||||||
err := gvctrl.Set(*hostPtr, options...)
|
err := config.Set(*hostPtr, options...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(fmt.Sprintf("error from gvctrl.Set: %v", err))
|
panic(fmt.Sprintf("error from config.Set: %v", err))
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
DESCRIPTION
|
DESCRIPTION
|
||||||
gvctrl.go provides exported functionality of a basic API to allow programmatic
|
config.go provides exported functionality of a basic API to allow programmatic
|
||||||
control over the GeoVision camera (namely the GV-BX4700) through the HTTP
|
control over the GeoVision camera (namely the GV-BX4700) through the HTTP
|
||||||
server used for settings control. See package documentation for further
|
server used for settings control. See package documentation for further
|
||||||
information on the API.
|
information on the API.
|
||||||
|
@ -25,14 +25,14 @@ LICENSE
|
||||||
in gpl.txt. If not, see http://www.gnu.org/licenses.
|
in gpl.txt. If not, see http://www.gnu.org/licenses.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Package gvctrl provides a basic API for programmatic control of the
|
// Package config provides a basic API for programmatic control of the
|
||||||
// web based interface provided by GeoVision cameras. This API has been
|
// web based interface provided by GeoVision cameras. This API has been
|
||||||
// developed and tested only with the GV-BX4700, and therefore may not work
|
// developed and tested only with the GV-BX4700, and therefore may not work
|
||||||
// with other models without further evolution.
|
// with other models without further evolution.
|
||||||
//
|
//
|
||||||
// Settings on a GeoVision camera are updated using the Set function. One or
|
// Settings on a GeoVision camera are updated using the Set function. One or
|
||||||
// more option functions may be provided to control camera function.
|
// more option functions may be provided to control camera function.
|
||||||
package gvctrl
|
package config
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
DESCRIPTION
|
DESCRIPTION
|
||||||
gvctrl_test.go provides tests of functionality in the gvctrl package.
|
config_test.go provides tests of functionality in the config package.
|
||||||
|
|
||||||
AUTHORS
|
AUTHORS
|
||||||
Saxon A. Nelson-Milton <saxon@ausocean.org>
|
Saxon A. Nelson-Milton <saxon@ausocean.org>
|
||||||
|
@ -22,7 +22,7 @@ LICENSE
|
||||||
in gpl.txt. If not, see http://www.gnu.org/licenses.
|
in gpl.txt. If not, see http://www.gnu.org/licenses.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package gvctrl
|
package config
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
|
@ -23,7 +23,7 @@ LICENSE
|
||||||
in gpl.txt. If not, see http://www.gnu.org/licenses.
|
in gpl.txt. If not, see http://www.gnu.org/licenses.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package gvctrl
|
package config
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
|
@ -23,7 +23,7 @@ LICENSE
|
||||||
in gpl.txt. If not, see http://www.gnu.org/licenses.
|
in gpl.txt. If not, see http://www.gnu.org/licenses.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package gvctrl
|
package config
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"crypto/md5"
|
"crypto/md5"
|
|
@ -35,11 +35,11 @@ import (
|
||||||
|
|
||||||
"bitbucket.org/ausocean/av/codec/codecutil"
|
"bitbucket.org/ausocean/av/codec/codecutil"
|
||||||
"bitbucket.org/ausocean/av/device"
|
"bitbucket.org/ausocean/av/device"
|
||||||
"bitbucket.org/ausocean/av/device/geovision/gvctrl"
|
gvconfig "bitbucket.org/ausocean/av/device/geovision/config"
|
||||||
"bitbucket.org/ausocean/av/protocol/rtcp"
|
"bitbucket.org/ausocean/av/protocol/rtcp"
|
||||||
"bitbucket.org/ausocean/av/protocol/rtp"
|
"bitbucket.org/ausocean/av/protocol/rtp"
|
||||||
"bitbucket.org/ausocean/av/protocol/rtsp"
|
"bitbucket.org/ausocean/av/protocol/rtsp"
|
||||||
"bitbucket.org/ausocean/av/revid/config"
|
avconfig "bitbucket.org/ausocean/av/revid/config"
|
||||||
"bitbucket.org/ausocean/utils/logger"
|
"bitbucket.org/ausocean/utils/logger"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ const (
|
||||||
defaultServerRTCPPort = 17301
|
defaultServerRTCPPort = 17301
|
||||||
)
|
)
|
||||||
|
|
||||||
// TODO: remove this when gvctrl has configurable user and pass.
|
// TODO: remove this when config has configurable user and pass.
|
||||||
const (
|
const (
|
||||||
ipCamUser = "admin"
|
ipCamUser = "admin"
|
||||||
ipCamPass = "admin"
|
ipCamPass = "admin"
|
||||||
|
@ -68,7 +68,7 @@ const (
|
||||||
defaultBitrate = 400
|
defaultBitrate = 400
|
||||||
defaultVBRBitrate = 400
|
defaultVBRBitrate = 400
|
||||||
defaultMinFrames = 100
|
defaultMinFrames = 100
|
||||||
defaultVBRQuality = config.QualityStandard
|
defaultVBRQuality = avconfig.QualityStandard
|
||||||
defaultCameraChan = 2
|
defaultCameraChan = 2
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -87,21 +87,21 @@ var (
|
||||||
// IP camera. This has been designed to implement the GV-BX4700-8F in particular.
|
// IP camera. This has been designed to implement the GV-BX4700-8F in particular.
|
||||||
// Any other models are untested.
|
// Any other models are untested.
|
||||||
type GeoVision struct {
|
type GeoVision struct {
|
||||||
cfg config.Config
|
cfg avconfig.Config
|
||||||
log config.Logger
|
log avconfig.Logger
|
||||||
rtpClt *rtp.Client
|
rtpClt *rtp.Client
|
||||||
rtspClt *rtsp.Client
|
rtspClt *rtsp.Client
|
||||||
rtcpClt *rtcp.Client
|
rtcpClt *rtcp.Client
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewGeoVision returns a new GeoVision.
|
// NewGeoVision returns a new GeoVision.
|
||||||
func NewGeoVision(l config.Logger) *GeoVision { return &GeoVision{log: l} }
|
func NewGeoVision(l avconfig.Logger) *GeoVision { return &GeoVision{log: l} }
|
||||||
|
|
||||||
// Set will take a Config struct, check the validity of the relevant fields
|
// Set will take a Config struct, check the validity of the relevant fields
|
||||||
// and then performs any configuration necessary using gvctrl to control the
|
// and then performs any configuration necessary using config to control the
|
||||||
// GeoVision web interface. If fields are not valid, an error is added to the
|
// GeoVision web interface. If fields are not valid, an error is added to the
|
||||||
// multiError and a default value is used for that particular field.
|
// multiError and a default value is used for that particular field.
|
||||||
func (g *GeoVision) Set(c config.Config) error {
|
func (g *GeoVision) Set(c avconfig.Config) error {
|
||||||
var errs device.MultiError
|
var errs device.MultiError
|
||||||
if c.CameraIP == "" {
|
if c.CameraIP == "" {
|
||||||
errs = append(errs, errGVBadCameraIP)
|
errs = append(errs, errGVBadCameraIP)
|
||||||
|
@ -136,7 +136,7 @@ func (g *GeoVision) Set(c config.Config) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
switch c.VBRQuality {
|
switch c.VBRQuality {
|
||||||
case config.QualityStandard, config.QualityFair, config.QualityGood, config.QualityGreat, config.QualityExcellent:
|
case avconfig.QualityStandard, avconfig.QualityFair, avconfig.QualityGood, avconfig.QualityGreat, avconfig.QualityExcellent:
|
||||||
default:
|
default:
|
||||||
errs = append(errs, errGVBadVBRQuality)
|
errs = append(errs, errGVBadVBRQuality)
|
||||||
c.VBRQuality = defaultVBRQuality
|
c.VBRQuality = defaultVBRQuality
|
||||||
|
@ -154,31 +154,31 @@ func (g *GeoVision) Set(c config.Config) error {
|
||||||
|
|
||||||
g.cfg = c
|
g.cfg = c
|
||||||
|
|
||||||
err := gvctrl.Set(
|
err := gvconfig.Set(
|
||||||
g.cfg.CameraIP,
|
g.cfg.CameraIP,
|
||||||
gvctrl.Channel(g.cfg.CameraChan),
|
gvconfig.Channel(g.cfg.CameraChan),
|
||||||
gvctrl.CodecOut(
|
gvconfig.CodecOut(
|
||||||
map[uint8]gvctrl.Codec{
|
map[uint8]gvconfig.Codec{
|
||||||
codecutil.H264: gvctrl.CodecH264,
|
codecutil.H264: gvconfig.CodecH264,
|
||||||
codecutil.H265: gvctrl.CodecH265,
|
codecutil.H265: gvconfig.CodecH265,
|
||||||
codecutil.MJPEG: gvctrl.CodecMJPEG,
|
codecutil.MJPEG: gvconfig.CodecMJPEG,
|
||||||
}[g.cfg.InputCodec],
|
}[g.cfg.InputCodec],
|
||||||
),
|
),
|
||||||
gvctrl.Height(int(g.cfg.Height)),
|
gvconfig.Height(int(g.cfg.Height)),
|
||||||
gvctrl.FrameRate(int(g.cfg.FrameRate)),
|
gvconfig.FrameRate(int(g.cfg.FrameRate)),
|
||||||
gvctrl.VariableBitrate(g.cfg.VBR),
|
gvconfig.VariableBitrate(g.cfg.VBR),
|
||||||
gvctrl.VBRQuality(
|
gvconfig.VBRQuality(
|
||||||
map[config.Quality]gvctrl.Quality{
|
map[avconfig.Quality]gvconfig.Quality{
|
||||||
config.QualityStandard: gvctrl.QualityStandard,
|
avconfig.QualityStandard: gvconfig.QualityStandard,
|
||||||
config.QualityFair: gvctrl.QualityFair,
|
avconfig.QualityFair: gvconfig.QualityFair,
|
||||||
config.QualityGood: gvctrl.QualityGood,
|
avconfig.QualityGood: gvconfig.QualityGood,
|
||||||
config.QualityGreat: gvctrl.QualityGreat,
|
avconfig.QualityGreat: gvconfig.QualityGreat,
|
||||||
config.QualityExcellent: gvctrl.QualityExcellent,
|
avconfig.QualityExcellent: gvconfig.QualityExcellent,
|
||||||
}[g.cfg.VBRQuality],
|
}[g.cfg.VBRQuality],
|
||||||
),
|
),
|
||||||
gvctrl.VBRBitrate(g.cfg.VBRBitrate),
|
gvconfig.VBRBitrate(g.cfg.VBRBitrate),
|
||||||
gvctrl.CBRBitrate(int(g.cfg.Bitrate)),
|
gvconfig.CBRBitrate(int(g.cfg.Bitrate)),
|
||||||
gvctrl.Refresh(float64(g.cfg.MinFrames)/float64(g.cfg.FrameRate)),
|
gvconfig.Refresh(float64(g.cfg.MinFrames)/float64(g.cfg.FrameRate)),
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("could not set IPCamera settings: %w", err)
|
return fmt.Errorf("could not set IPCamera settings: %w", err)
|
||||||
|
|
|
@ -40,7 +40,7 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"bitbucket.org/ausocean/av/codec/codecutil"
|
"bitbucket.org/ausocean/av/codec/codecutil"
|
||||||
"bitbucket.org/ausocean/av/device/geovision/gvctrl"
|
gvconfig "bitbucket.org/ausocean/av/device/geovision/config"
|
||||||
"bitbucket.org/ausocean/av/protocol/rtcp"
|
"bitbucket.org/ausocean/av/protocol/rtcp"
|
||||||
"bitbucket.org/ausocean/av/protocol/rtp"
|
"bitbucket.org/ausocean/av/protocol/rtp"
|
||||||
"bitbucket.org/ausocean/av/protocol/rtsp"
|
"bitbucket.org/ausocean/av/protocol/rtsp"
|
||||||
|
@ -48,7 +48,7 @@ import (
|
||||||
"bitbucket.org/ausocean/utils/logger"
|
"bitbucket.org/ausocean/utils/logger"
|
||||||
)
|
)
|
||||||
|
|
||||||
// TODO: remove this when gvctrl has configurable user and pass.
|
// TODO: remove this when config has configurable user and pass.
|
||||||
const (
|
const (
|
||||||
ipCamUser = "admin"
|
ipCamUser = "admin"
|
||||||
ipCamPass = "admin"
|
ipCamPass = "admin"
|
||||||
|
@ -194,31 +194,31 @@ func (r *Revid) setupInputForFile() (func() error, error) {
|
||||||
func (r *Revid) startRTSPCamera() (func() error, error) {
|
func (r *Revid) startRTSPCamera() (func() error, error) {
|
||||||
r.cfg.Logger.Log(logger.Info, pkg+"starting geovision...")
|
r.cfg.Logger.Log(logger.Info, pkg+"starting geovision...")
|
||||||
|
|
||||||
err := gvctrl.Set(
|
err := gvconfig.Set(
|
||||||
r.cfg.CameraIP,
|
r.cfg.CameraIP,
|
||||||
gvctrl.Channel(r.cfg.CameraChan),
|
gvconfig.Channel(r.cfg.CameraChan),
|
||||||
gvctrl.CodecOut(
|
gvconfig.CodecOut(
|
||||||
map[uint8]gvctrl.Codec{
|
map[uint8]gvconfig.Codec{
|
||||||
codecutil.H264: gvctrl.CodecH264,
|
codecutil.H264: gvconfig.CodecH264,
|
||||||
codecutil.H265: gvctrl.CodecH265,
|
codecutil.H265: gvconfig.CodecH265,
|
||||||
codecutil.MJPEG: gvctrl.CodecMJPEG,
|
codecutil.MJPEG: gvconfig.CodecMJPEG,
|
||||||
}[r.cfg.InputCodec],
|
}[r.cfg.InputCodec],
|
||||||
),
|
),
|
||||||
gvctrl.Height(int(r.cfg.Height)),
|
gvconfig.Height(int(r.cfg.Height)),
|
||||||
gvctrl.FrameRate(int(r.cfg.FrameRate)),
|
gvconfig.FrameRate(int(r.cfg.FrameRate)),
|
||||||
gvctrl.VariableBitrate(r.cfg.VBR),
|
gvconfig.VariableBitrate(r.cfg.VBR),
|
||||||
gvctrl.VBRQuality(
|
gvconfig.VBRQuality(
|
||||||
map[config.Quality]gvctrl.Quality{
|
map[config.Quality]gvconfig.Quality{
|
||||||
config.QualityStandard: gvctrl.QualityStandard,
|
config.QualityStandard: gvconfig.QualityStandard,
|
||||||
config.QualityFair: gvctrl.QualityFair,
|
config.QualityFair: gvconfig.QualityFair,
|
||||||
config.QualityGood: gvctrl.QualityGood,
|
config.QualityGood: gvconfig.QualityGood,
|
||||||
config.QualityGreat: gvctrl.QualityGreat,
|
config.QualityGreat: gvconfig.QualityGreat,
|
||||||
config.QualityExcellent: gvctrl.QualityExcellent,
|
config.QualityExcellent: gvconfig.QualityExcellent,
|
||||||
}[r.cfg.VBRQuality],
|
}[r.cfg.VBRQuality],
|
||||||
),
|
),
|
||||||
gvctrl.VBRBitrate(r.cfg.VBRBitrate),
|
gvconfig.VBRBitrate(r.cfg.VBRBitrate),
|
||||||
gvctrl.CBRBitrate(int(r.cfg.Bitrate)),
|
gvconfig.CBRBitrate(int(r.cfg.Bitrate)),
|
||||||
gvctrl.Refresh(float64(r.cfg.MinFrames)/float64(r.cfg.FrameRate)),
|
gvconfig.Refresh(float64(r.cfg.MinFrames)/float64(r.cfg.FrameRate)),
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("could not set IPCamera settings: %w", err)
|
return nil, fmt.Errorf("could not set IPCamera settings: %w", err)
|
||||||
|
|
Loading…
Reference in New Issue