mirror of https://bitbucket.org/ausocean/av.git
cmd/revid-cli & stream/mts/meta: added meta.NewWith function that creates a new meta.Data and adds an initial entry. Using meta.NewWith in revid-cli to initialise mts' global meta.Data with some preamble data.
This commit is contained in:
parent
d523677627
commit
2b7ab27763
|
@ -37,6 +37,8 @@ import (
|
|||
"time"
|
||||
|
||||
"bitbucket.org/ausocean/av/revid"
|
||||
"bitbucket.org/ausocean/av/stream/mts"
|
||||
"bitbucket.org/ausocean/av/stream/mts/meta"
|
||||
"bitbucket.org/ausocean/iot/pi/netsender"
|
||||
"bitbucket.org/ausocean/iot/pi/smartlogger"
|
||||
"bitbucket.org/ausocean/utils/logger"
|
||||
|
@ -65,7 +67,16 @@ var canProfile = true
|
|||
// The logger that will be used throughout
|
||||
var log *logger.Logger
|
||||
|
||||
var (
|
||||
metaPreambleKey = []byte{0x63, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68, 0x74}
|
||||
metaPreambleData = []byte{0x61, 0x75, 0x73, 0x6f, 0x63, 0x65, 0x61, 0x6e, 0x2e,
|
||||
0x6f, 0x72, 0x67, 0x2f, 0x6c, 0x69, 0x63, 0x65, 0x6e, 0x73, 0x65, 0x2f, 0x63,
|
||||
0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x32, 0x30, 0x31, 0x39}
|
||||
)
|
||||
|
||||
func main() {
|
||||
mts.Meta = meta.NewWith(string(metaPreambleKey), string(metaPreambleData))
|
||||
|
||||
useNetsender := flag.Bool("NetSender", false, "Are we checking vars through netsender?")
|
||||
runDurationPtr := flag.Duration("runDuration", defaultRunDuration, "How long do you want revid to run for?")
|
||||
|
||||
|
|
|
@ -88,17 +88,8 @@ const (
|
|||
psiSndCnt = 7
|
||||
)
|
||||
|
||||
const (
|
||||
copyright = "copyright"
|
||||
license = "ausocean.org/license/content2019"
|
||||
)
|
||||
|
||||
// global Meta
|
||||
var Meta = meta.New()
|
||||
|
||||
func init() {
|
||||
Meta.Add(copyright, license)
|
||||
}
|
||||
var Meta *meta.Data
|
||||
|
||||
var (
|
||||
patTable = standardPat.Bytes()
|
||||
|
|
|
@ -76,6 +76,20 @@ func New() *Data {
|
|||
}
|
||||
}
|
||||
|
||||
func NewWith(key, data string) *Data {
|
||||
meta := &Data{
|
||||
data: make(map[string]string),
|
||||
enc: []byte{
|
||||
0x00, // Reserved byte
|
||||
(majVer << 4) | minVer, // MS and LS versions
|
||||
0x00, // Data len byte1
|
||||
0x00, // Data len byte2
|
||||
},
|
||||
}
|
||||
meta.Add(key, data)
|
||||
return meta
|
||||
}
|
||||
|
||||
// Add adds metadata with key and val.
|
||||
func (m *Data) Add(key, val string) {
|
||||
m.mu.Lock()
|
||||
|
|
Loading…
Reference in New Issue