From 2b7ab27763e882c2c4d10f02464bb325ee881e7a Mon Sep 17 00:00:00 2001 From: saxon Date: Wed, 6 Feb 2019 10:19:12 +1030 Subject: [PATCH] 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. --- cmd/revid-cli/main.go | 11 +++++++++++ stream/mts/encoder.go | 11 +---------- stream/mts/meta/meta.go | 14 ++++++++++++++ 3 files changed, 26 insertions(+), 10 deletions(-) diff --git a/cmd/revid-cli/main.go b/cmd/revid-cli/main.go index 5b826b91..d7f79721 100644 --- a/cmd/revid-cli/main.go +++ b/cmd/revid-cli/main.go @@ -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?") diff --git a/stream/mts/encoder.go b/stream/mts/encoder.go index 7bda82c7..2ebe5dc6 100644 --- a/stream/mts/encoder.go +++ b/stream/mts/encoder.go @@ -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() diff --git a/stream/mts/meta/meta.go b/stream/mts/meta/meta.go index 1e2182c0..97725252 100644 --- a/stream/mts/meta/meta.go +++ b/stream/mts/meta/meta.go @@ -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()