Merged in rename-gvctrl (pull request #272)

device/geovision: renamed gvctrl package to config

Approved-by: Alan Noble <anoble@gmail.com>
This commit is contained in:
Saxon Milton 2019-11-09 09:53:56 +00:00
commit 9e725783be
7 changed files with 76 additions and 78 deletions

View File

@ -22,8 +22,6 @@ LICENSE
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
import (
@ -31,7 +29,7 @@ import (
"fmt"
"strconv"
"bitbucket.org/ausocean/av/device/geovision/gvctrl"
"bitbucket.org/ausocean/av/device/geovision/config"
)
func main() {
@ -48,51 +46,51 @@ func main() {
)
flag.Parse()
var options []gvctrl.Option
var options []config.Option
if *codecPtr != "" {
var c gvctrl.Codec
var c config.Codec
switch *codecPtr {
case "h264":
c = gvctrl.CodecH264
c = config.CodecH264
case "h265":
c = gvctrl.CodecH265
c = config.CodecH265
case "mjpeg":
c = gvctrl.CodecMJPEG
c = config.CodecMJPEG
default:
panic(fmt.Sprintf("invalid codec: %s", *codecPtr))
}
options = append(options, gvctrl.CodecOut(c))
options = append(options, config.CodecOut(c))
}
if *heightPtr != 0 {
options = append(options, gvctrl.Height(*heightPtr))
options = append(options, config.Height(*heightPtr))
}
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 {
options = append(options, gvctrl.VBRQuality(gvctrl.Quality(strconv.Itoa(*vbrQualityPtr))))
options = append(options, config.VBRQuality(config.Quality(strconv.Itoa(*vbrQualityPtr))))
}
if *vbrRatePtr != 0 {
options = append(options, gvctrl.VBRBitrate(*vbrRatePtr))
options = append(options, config.VBRBitrate(*vbrRatePtr))
}
if *cbrRatePtr != 0 {
options = append(options, gvctrl.CBRBitrate(*cbrRatePtr))
options = append(options, config.CBRBitrate(*cbrRatePtr))
}
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 {
panic(fmt.Sprintf("error from gvctrl.Set: %v", err))
panic(fmt.Sprintf("error from config.Set: %v", err))
}
}

View File

@ -1,6 +1,6 @@
/*
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
server used for settings control. See package documentation for further
information on the API.
@ -25,14 +25,14 @@ LICENSE
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
// developed and tested only with the GV-BX4700, and therefore may not work
// with other models without further evolution.
//
// Settings on a GeoVision camera are updated using the Set function. One or
// more option functions may be provided to control camera function.
package gvctrl
package config
import (
"errors"

View File

@ -1,6 +1,6 @@
/*
DESCRIPTION
gvctrl_test.go provides tests of functionality in the gvctrl package.
config_test.go provides tests of functionality in the config package.
AUTHORS
Saxon A. Nelson-Milton <saxon@ausocean.org>
@ -22,7 +22,7 @@ LICENSE
in gpl.txt. If not, see http://www.gnu.org/licenses.
*/
package gvctrl
package config
import (
"errors"

View File

@ -23,7 +23,7 @@ LICENSE
in gpl.txt. If not, see http://www.gnu.org/licenses.
*/
package gvctrl
package config
import (
"bytes"

View File

@ -23,7 +23,7 @@ LICENSE
in gpl.txt. If not, see http://www.gnu.org/licenses.
*/
package gvctrl
package config
import (
"crypto/md5"

View File

@ -35,11 +35,11 @@ import (
"bitbucket.org/ausocean/av/codec/codecutil"
"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/rtp"
"bitbucket.org/ausocean/av/protocol/rtsp"
"bitbucket.org/ausocean/av/revid/config"
avconfig "bitbucket.org/ausocean/av/revid/config"
"bitbucket.org/ausocean/utils/logger"
)
@ -53,7 +53,7 @@ const (
defaultServerRTCPPort = 17301
)
// TODO: remove this when gvctrl has configurable user and pass.
// TODO: remove this when config has configurable user and pass.
const (
ipCamUser = "admin"
ipCamPass = "admin"
@ -68,7 +68,7 @@ const (
defaultBitrate = 400
defaultVBRBitrate = 400
defaultMinFrames = 100
defaultVBRQuality = config.QualityStandard
defaultVBRQuality = avconfig.QualityStandard
defaultCameraChan = 2
)
@ -87,21 +87,21 @@ var (
// IP camera. This has been designed to implement the GV-BX4700-8F in particular.
// Any other models are untested.
type GeoVision struct {
cfg config.Config
log config.Logger
cfg avconfig.Config
log avconfig.Logger
rtpClt *rtp.Client
rtspClt *rtsp.Client
rtcpClt *rtcp.Client
}
// 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
// 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
// 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
if c.CameraIP == "" {
errs = append(errs, errGVBadCameraIP)
@ -136,7 +136,7 @@ func (g *GeoVision) Set(c config.Config) error {
}
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:
errs = append(errs, errGVBadVBRQuality)
c.VBRQuality = defaultVBRQuality
@ -154,31 +154,31 @@ func (g *GeoVision) Set(c config.Config) error {
g.cfg = c
err := gvctrl.Set(
err := gvconfig.Set(
g.cfg.CameraIP,
gvctrl.Channel(g.cfg.CameraChan),
gvctrl.CodecOut(
map[uint8]gvctrl.Codec{
codecutil.H264: gvctrl.CodecH264,
codecutil.H265: gvctrl.CodecH265,
codecutil.MJPEG: gvctrl.CodecMJPEG,
gvconfig.Channel(g.cfg.CameraChan),
gvconfig.CodecOut(
map[uint8]gvconfig.Codec{
codecutil.H264: gvconfig.CodecH264,
codecutil.H265: gvconfig.CodecH265,
codecutil.MJPEG: gvconfig.CodecMJPEG,
}[g.cfg.InputCodec],
),
gvctrl.Height(int(g.cfg.Height)),
gvctrl.FrameRate(int(g.cfg.FrameRate)),
gvctrl.VariableBitrate(g.cfg.VBR),
gvctrl.VBRQuality(
map[config.Quality]gvctrl.Quality{
config.QualityStandard: gvctrl.QualityStandard,
config.QualityFair: gvctrl.QualityFair,
config.QualityGood: gvctrl.QualityGood,
config.QualityGreat: gvctrl.QualityGreat,
config.QualityExcellent: gvctrl.QualityExcellent,
gvconfig.Height(int(g.cfg.Height)),
gvconfig.FrameRate(int(g.cfg.FrameRate)),
gvconfig.VariableBitrate(g.cfg.VBR),
gvconfig.VBRQuality(
map[avconfig.Quality]gvconfig.Quality{
avconfig.QualityStandard: gvconfig.QualityStandard,
avconfig.QualityFair: gvconfig.QualityFair,
avconfig.QualityGood: gvconfig.QualityGood,
avconfig.QualityGreat: gvconfig.QualityGreat,
avconfig.QualityExcellent: gvconfig.QualityExcellent,
}[g.cfg.VBRQuality],
),
gvctrl.VBRBitrate(g.cfg.VBRBitrate),
gvctrl.CBRBitrate(int(g.cfg.Bitrate)),
gvctrl.Refresh(float64(g.cfg.MinFrames)/float64(g.cfg.FrameRate)),
gvconfig.VBRBitrate(g.cfg.VBRBitrate),
gvconfig.CBRBitrate(int(g.cfg.Bitrate)),
gvconfig.Refresh(float64(g.cfg.MinFrames)/float64(g.cfg.FrameRate)),
)
if err != nil {
return fmt.Errorf("could not set IPCamera settings: %w", err)

View File

@ -40,15 +40,15 @@ import (
"time"
"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/rtp"
"bitbucket.org/ausocean/av/protocol/rtsp"
"bitbucket.org/ausocean/av/revid/config"
avconfig "bitbucket.org/ausocean/av/revid/config"
"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 (
ipCamUser = "admin"
ipCamPass = "admin"
@ -194,31 +194,31 @@ func (r *Revid) setupInputForFile() (func() error, error) {
func (r *Revid) startRTSPCamera() (func() error, error) {
r.cfg.Logger.Log(logger.Info, pkg+"starting geovision...")
err := gvctrl.Set(
err := gvconfig.Set(
r.cfg.CameraIP,
gvctrl.Channel(r.cfg.CameraChan),
gvctrl.CodecOut(
map[uint8]gvctrl.Codec{
codecutil.H264: gvctrl.CodecH264,
codecutil.H265: gvctrl.CodecH265,
codecutil.MJPEG: gvctrl.CodecMJPEG,
gvconfig.Channel(r.cfg.CameraChan),
gvconfig.CodecOut(
map[uint8]gvconfig.Codec{
codecutil.H264: gvconfig.CodecH264,
codecutil.H265: gvconfig.CodecH265,
codecutil.MJPEG: gvconfig.CodecMJPEG,
}[r.cfg.InputCodec],
),
gvctrl.Height(int(r.cfg.Height)),
gvctrl.FrameRate(int(r.cfg.FrameRate)),
gvctrl.VariableBitrate(r.cfg.VBR),
gvctrl.VBRQuality(
map[config.Quality]gvctrl.Quality{
config.QualityStandard: gvctrl.QualityStandard,
config.QualityFair: gvctrl.QualityFair,
config.QualityGood: gvctrl.QualityGood,
config.QualityGreat: gvctrl.QualityGreat,
config.QualityExcellent: gvctrl.QualityExcellent,
gvconfig.Height(int(r.cfg.Height)),
gvconfig.FrameRate(int(r.cfg.FrameRate)),
gvconfig.VariableBitrate(r.cfg.VBR),
gvconfig.VBRQuality(
map[avconfig.Quality]gvconfig.Quality{
avconfig.QualityStandard: gvconfig.QualityStandard,
avconfig.QualityFair: gvconfig.QualityFair,
avconfig.QualityGood: gvconfig.QualityGood,
avconfig.QualityGreat: gvconfig.QualityGreat,
avconfig.QualityExcellent: gvconfig.QualityExcellent,
}[r.cfg.VBRQuality],
),
gvctrl.VBRBitrate(r.cfg.VBRBitrate),
gvctrl.CBRBitrate(int(r.cfg.Bitrate)),
gvctrl.Refresh(float64(r.cfg.MinFrames)/float64(r.cfg.FrameRate)),
gvconfig.VBRBitrate(r.cfg.VBRBitrate),
gvconfig.CBRBitrate(int(r.cfg.Bitrate)),
gvconfig.Refresh(float64(r.cfg.MinFrames)/float64(r.cfg.FrameRate)),
)
if err != nil {
return nil, fmt.Errorf("could not set IPCamera settings: %w", err)