mirror of https://bitbucket.org/ausocean/av.git
mts: change meta const names eg. WriteRateStr to WriteRateKey
This commit is contained in:
parent
3ec7201d9c
commit
357cb196b9
|
@ -103,9 +103,9 @@ const (
|
||||||
|
|
||||||
// Used to consistently read and write MTS metadata entries.
|
// Used to consistently read and write MTS metadata entries.
|
||||||
const (
|
const (
|
||||||
WriteRateStr = "writeRate"
|
WriteRateKey = "writeRate"
|
||||||
TSStr = "ts"
|
TimestampKey = "ts"
|
||||||
LocStr = "loc"
|
LocationKey = "loc"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Meta allows addition of metadata to encoded mts from outside of this pkg.
|
// Meta allows addition of metadata to encoded mts from outside of this pkg.
|
||||||
|
@ -171,7 +171,7 @@ func NewEncoder(dst io.WriteCloser, log logger.LoggerIF, options ...func(*Encode
|
||||||
}
|
}
|
||||||
log.Debug("encoder options applied")
|
log.Debug("encoder options applied")
|
||||||
|
|
||||||
Meta.Add(WriteRateStr, fmt.Sprintf("%f", 1/float64(e.writePeriod.Seconds())))
|
Meta.Add(WriteRateKey, fmt.Sprintf("%f", 1/float64(e.writePeriod.Seconds())))
|
||||||
|
|
||||||
e.pmt.SyntaxSection.SpecificData.(*psi.PMT).StreamSpecificData.StreamType = e.streamID
|
e.pmt.SyntaxSection.SpecificData.(*psi.PMT).StreamSpecificData.StreamType = e.streamID
|
||||||
e.pmt.SyntaxSection.SpecificData.(*psi.PMT).StreamSpecificData.PID = e.mediaPID
|
e.pmt.SyntaxSection.SpecificData.(*psi.PMT).StreamSpecificData.PID = e.mediaPID
|
||||||
|
@ -339,7 +339,7 @@ func updateMeta(b []byte, log logger.LoggerIF) ([]byte, error) {
|
||||||
p := psi.PSIBytes(b)
|
p := psi.PSIBytes(b)
|
||||||
if RealTime.IsSet() {
|
if RealTime.IsSet() {
|
||||||
t := strconv.Itoa(int(RealTime.Get().Unix()))
|
t := strconv.Itoa(int(RealTime.Get().Unix()))
|
||||||
Meta.Add(TSStr, t)
|
Meta.Add(TimestampKey, t)
|
||||||
log.Debug("latest time added to meta", "time", t)
|
log.Debug("latest time added to meta", "time", t)
|
||||||
}
|
}
|
||||||
err := p.AddDescriptor(psi.MetadataTag, Meta.Encode())
|
err := p.AddDescriptor(psi.MetadataTag, Meta.Encode())
|
||||||
|
|
|
@ -276,7 +276,7 @@ func TestMetaEncode1(t *testing.T) {
|
||||||
t.Fatalf("could not create encoder, failed with error: %v", err)
|
t.Fatalf("could not create encoder, failed with error: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
Meta.Add(TSStr, "12345678")
|
Meta.Add(TimestampKey, "12345678")
|
||||||
if err := e.writePSI(); err != nil {
|
if err := e.writePSI(); err != nil {
|
||||||
t.Errorf("unexpected error: %v\n", err.Error())
|
t.Errorf("unexpected error: %v\n", err.Error())
|
||||||
}
|
}
|
||||||
|
@ -289,8 +289,8 @@ func TestMetaEncode1(t *testing.T) {
|
||||||
0x23, // Length of bytes to follow
|
0x23, // Length of bytes to follow
|
||||||
0x00, 0x10, 0x00, 0x1f,
|
0x00, 0x10, 0x00, 0x1f,
|
||||||
}
|
}
|
||||||
rate := "writeRate=" + fmt.Sprintf("%f", float64(defaultRate)) + "\t" + TSStr + "=12345678" // timestamp
|
rate := WriteRateKey + "=" + fmt.Sprintf("%f", float64(defaultRate)) + "\t" + TimestampKey + "=12345678" // timestamp
|
||||||
want = append(want, []byte(rate)...) // writeRate
|
want = append(want, []byte(rate)...) // writeRate
|
||||||
want = append(want, []byte{0x1b, 0xe1, 0x00, 0xf0, 0x00}...)
|
want = append(want, []byte{0x1b, 0xe1, 0x00, 0xf0, 0x00}...)
|
||||||
want = psi.AddCRC(want)
|
want = psi.AddCRC(want)
|
||||||
want = psi.AddPadding(want)
|
want = psi.AddPadding(want)
|
||||||
|
@ -310,8 +310,8 @@ func TestMetaEncode2(t *testing.T) {
|
||||||
t.Fatalf("could not create MTS encoder, failed with error: %v", err)
|
t.Fatalf("could not create MTS encoder, failed with error: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
Meta.Add(TSStr, "12345678")
|
Meta.Add(TimestampKey, "12345678")
|
||||||
Meta.Add(LocStr, "1234,4321,1234")
|
Meta.Add(LocationKey, "1234,4321,1234")
|
||||||
if err := e.writePSI(); err != nil {
|
if err := e.writePSI(); err != nil {
|
||||||
t.Errorf("did not expect error: %v from writePSI", err.Error())
|
t.Errorf("did not expect error: %v from writePSI", err.Error())
|
||||||
}
|
}
|
||||||
|
@ -323,8 +323,8 @@ func TestMetaEncode2(t *testing.T) {
|
||||||
0x36, // Length of bytes to follow
|
0x36, // Length of bytes to follow
|
||||||
0x00, 0x10, 0x00, 0x32,
|
0x00, 0x10, 0x00, 0x32,
|
||||||
}
|
}
|
||||||
s := WriteRateStr + "=" + fmt.Sprintf("%f", float64(defaultRate)) + "\t" +
|
s := WriteRateKey + "=" + fmt.Sprintf("%f", float64(defaultRate)) + "\t" +
|
||||||
TSStr + "=12345678\t" + LocStr + "=1234,4321,1234"
|
TimestampKey + "=12345678\t" + LocationKey + "=1234,4321,1234"
|
||||||
want = append(want, []byte(s)...)
|
want = append(want, []byte(s)...)
|
||||||
want = append(want, []byte{0x1b, 0xe1, 0x00, 0xf0, 0x00}...)
|
want = append(want, []byte{0x1b, 0xe1, 0x00, 0xf0, 0x00}...)
|
||||||
want = psi.AddCRC(want)
|
want = psi.AddCRC(want)
|
||||||
|
@ -344,8 +344,8 @@ func TestExtractMeta(t *testing.T) {
|
||||||
t.Fatalf("could not create MTS encoder, failed with error: %v", err)
|
t.Fatalf("could not create MTS encoder, failed with error: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
Meta.Add(TSStr, "12345678")
|
Meta.Add(TimestampKey, "12345678")
|
||||||
Meta.Add(LocStr, "1234,4321,1234")
|
Meta.Add(LocationKey, "1234,4321,1234")
|
||||||
if err := e.writePSI(); err != nil {
|
if err := e.writePSI(); err != nil {
|
||||||
t.Errorf("did not expect error: %v", err.Error())
|
t.Errorf("did not expect error: %v", err.Error())
|
||||||
}
|
}
|
||||||
|
@ -356,9 +356,9 @@ func TestExtractMeta(t *testing.T) {
|
||||||
}
|
}
|
||||||
rate := fmt.Sprintf("%f", float64(defaultRate))
|
rate := fmt.Sprintf("%f", float64(defaultRate))
|
||||||
want := map[string]string{
|
want := map[string]string{
|
||||||
"ts": "12345678",
|
TimestampKey: "12345678",
|
||||||
"loc": "1234,4321,1234",
|
LocationKey: "1234,4321,1234",
|
||||||
"writeRate": rate,
|
WriteRateKey: rate,
|
||||||
}
|
}
|
||||||
if !reflect.DeepEqual(got, want) {
|
if !reflect.DeepEqual(got, want) {
|
||||||
t.Errorf("did not get expected result.\ngot: %v\nwant: %v\n", got, want)
|
t.Errorf("did not get expected result.\ngot: %v\nwant: %v\n", got, want)
|
||||||
|
|
|
@ -38,11 +38,11 @@ import (
|
||||||
|
|
||||||
// Used to reliably read, write, and test audio metadata entry keys.
|
// Used to reliably read, write, and test audio metadata entry keys.
|
||||||
const (
|
const (
|
||||||
SampleRateStr = "sampleRate"
|
SampleRateKey = "sampleRate"
|
||||||
ChannelsStr = "channels"
|
ChannelsKey = "channels"
|
||||||
PeriodStr = "period"
|
PeriodKey = "period"
|
||||||
BitDepthStr = "bitDepth"
|
BitDepthKey = "bitDepth"
|
||||||
CodecStr = "codec"
|
CodecKey = "codec"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (r *Revid) setupAudio() error {
|
func (r *Revid) setupAudio() error {
|
||||||
|
@ -68,11 +68,11 @@ func (r *Revid) setupAudio() error {
|
||||||
r.lexTo = l.Lex
|
r.lexTo = l.Lex
|
||||||
|
|
||||||
// Add metadata.
|
// Add metadata.
|
||||||
mts.Meta.Add(SampleRateStr, strconv.Itoa(int(r.cfg.SampleRate)))
|
mts.Meta.Add(SampleRateKey, strconv.Itoa(int(r.cfg.SampleRate)))
|
||||||
mts.Meta.Add(ChannelsStr, strconv.Itoa(int(r.cfg.Channels)))
|
mts.Meta.Add(ChannelsKey, strconv.Itoa(int(r.cfg.Channels)))
|
||||||
mts.Meta.Add(PeriodStr, fmt.Sprintf("%.6f", r.cfg.RecPeriod))
|
mts.Meta.Add(PeriodKey, fmt.Sprintf("%.6f", r.cfg.RecPeriod))
|
||||||
mts.Meta.Add(BitDepthStr, strconv.Itoa(int(r.cfg.BitDepth)))
|
mts.Meta.Add(BitDepthKey, strconv.Itoa(int(r.cfg.BitDepth)))
|
||||||
mts.Meta.Add(CodecStr, r.cfg.InputCodec)
|
mts.Meta.Add(CodecKey, r.cfg.InputCodec)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -153,7 +153,7 @@ func extractMeta(r string, log func(lvl int8, msg string, args ...interface{}))
|
||||||
log(logger.Debug, "No location in reply")
|
log(logger.Debug, "No location in reply")
|
||||||
} else {
|
} else {
|
||||||
log(logger.Debug, fmt.Sprintf("got location: %v", g))
|
log(logger.Debug, fmt.Sprintf("got location: %v", g))
|
||||||
mts.Meta.Add(mts.LocStr, g)
|
mts.Meta.Add(mts.LocationKey, g)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|
Loading…
Reference in New Issue