revid: config fields that are exported and acronyms now capitalized.

This commit is contained in:
Saxon 2019-05-13 16:23:38 +09:30
parent 51fcb18505
commit 835f97203a
4 changed files with 18 additions and 18 deletions

View File

@ -217,17 +217,17 @@ func handleFlags() revid.Config {
cfg.FlipHorizontal = *horizontalFlipPtr cfg.FlipHorizontal = *horizontalFlipPtr
cfg.FlipVertical = *verticalFlipPtr cfg.FlipVertical = *verticalFlipPtr
cfg.FramesPerClip = *framesPerClipPtr cfg.FramesPerClip = *framesPerClipPtr
cfg.RtmpUrl = *rtmpUrlPtr cfg.RTMPURL = *rtmpUrlPtr
cfg.Bitrate = *bitratePtr cfg.Bitrate = *bitratePtr
cfg.OutputPath = *outputPathPtr cfg.OutputPath = *outputPathPtr
cfg.InputPath = *inputFilePtr cfg.InputPath = *inputFilePtr
cfg.Height = *heightPtr cfg.Height = *heightPtr
cfg.Width = *widthPtr cfg.Width = *widthPtr
cfg.FrameRate = *frameRatePtr cfg.FrameRate = *frameRatePtr
cfg.HttpAddress = *httpAddressPtr cfg.HTTPAddress = *httpAddressPtr
cfg.Quantization = *quantizationPtr cfg.Quantization = *quantizationPtr
cfg.IntraRefreshPeriod = *intraRefreshPeriodPtr cfg.IntraRefreshPeriod = *intraRefreshPeriodPtr
cfg.RtpAddress = *rtpAddrPtr cfg.RTPAddress = *rtpAddrPtr
cfg.SendRetry = *sendRetryPtr cfg.SendRetry = *sendRetryPtr
cfg.Brightness = *brightnessPtr cfg.Brightness = *brightnessPtr
cfg.Saturation = *saturationPtr cfg.Saturation = *saturationPtr

View File

@ -141,13 +141,13 @@ type Config struct {
// File: // File:
// Location must be defined by the OutputPath field. MPEG-TS packetization // Location must be defined by the OutputPath field. MPEG-TS packetization
// is used. // is used.
// Http: // HTTP:
// Destination is defined by the sh field located in /etc/netsender.conf. // Destination is defined by the sh field located in /etc/netsender.conf.
// MPEGT-TS packetization is used. // MPEGT-TS packetization is used.
// Rtmp: // RTMP:
// Destination URL must be defined in the RtmpUrl field. FLV packetization // Destination URL must be defined in the RtmpUrl field. FLV packetization
// is used. // is used.
// Rtp: // RTP:
// Destination is defined by RtpAddr field, otherwise it will default to // Destination is defined by RtpAddr field, otherwise it will default to
// localhost:6970. MPEGT-TS packetization is used. // localhost:6970. MPEGT-TS packetization is used.
Outputs []uint8 Outputs []uint8
@ -164,17 +164,17 @@ type Config struct {
// RtmpUrl specifies the Rtmp output destination URL. This must be defined if // RtmpUrl specifies the Rtmp output destination URL. This must be defined if
// RTMP is to be used as an output. // RTMP is to be used as an output.
RtmpUrl string RTMPURL string
Bitrate uint Bitrate uint
OutputPath string OutputPath string
InputPath string InputPath string
Height uint Height uint
Width uint Width uint
FrameRate uint FrameRate uint
HttpAddress string HTTPAddress string
Quantization uint Quantization uint
IntraRefreshPeriod uint IntraRefreshPeriod uint
RtpAddress string RTPAddress string
Logger Logger Logger Logger
SendRetry bool SendRetry bool
BurstPeriod uint BurstPeriod uint
@ -242,7 +242,7 @@ func (c *Config) Validate(r *Revid) error {
switch o { switch o {
case File: case File:
case RTMP: case RTMP:
if c.RtmpUrl == "" { if c.RTMPURL == "" {
c.Logger.Log(logger.Info, pkg+"no RTMP URL: falling back to HTTP") c.Logger.Log(logger.Info, pkg+"no RTMP URL: falling back to HTTP")
c.Outputs[i] = HTTP c.Outputs[i] = HTTP
// FIXME(kortschak): Does this want the same line as below? // FIXME(kortschak): Does this want the same line as below?
@ -308,8 +308,8 @@ func (c *Config) Validate(r *Revid) error {
return errors.New("quantisation is over threshold") return errors.New("quantisation is over threshold")
} }
if c.RtpAddress == "" { if c.RTPAddress == "" {
c.RtpAddress = defaultRtpAddr c.RTPAddress = defaultRtpAddr
} }
switch { switch {

View File

@ -216,7 +216,7 @@ func (r *Revid) setupPipeline(mtsEnc, flvEnc func(dst io.WriteCloser, rate int)
w = newMtsSender(newHttpSender(r.ns, r.config.Logger.Log), r.config.Logger.Log, rbSize, rbElementSize, 0) w = newMtsSender(newHttpSender(r.ns, r.config.Logger.Log), r.config.Logger.Log, rbSize, rbElementSize, 0)
mtsSenders = append(mtsSenders, w) mtsSenders = append(mtsSenders, w)
case RTP: case RTP:
w, err := newRtpSender(r.config.RtpAddress, r.config.Logger.Log, r.config.FrameRate) w, err := newRtpSender(r.config.RTPAddress, r.config.Logger.Log, r.config.FrameRate)
if err != nil { if err != nil {
r.config.Logger.Log(logger.Warning, pkg+"rtp connect error", "error", err.Error()) r.config.Logger.Log(logger.Warning, pkg+"rtp connect error", "error", err.Error())
} }
@ -228,7 +228,7 @@ func (r *Revid) setupPipeline(mtsEnc, flvEnc func(dst io.WriteCloser, rate int)
} }
mtsSenders = append(mtsSenders, w) mtsSenders = append(mtsSenders, w)
case RTMP: case RTMP:
w, err := newRtmpSender(r.config.RtmpUrl, rtmpConnectionTimeout, rtmpConnectionMaxTries, r.config.Logger.Log) w, err := newRtmpSender(r.config.RTMPURL, rtmpConnectionTimeout, rtmpConnectionMaxTries, r.config.Logger.Log)
if err != nil { if err != nil {
r.config.Logger.Log(logger.Warning, pkg+"rtmp connect error", "error", err.Error()) r.config.Logger.Log(logger.Warning, pkg+"rtmp connect error", "error", err.Error())
} }
@ -378,9 +378,9 @@ func (r *Revid) Update(vars map[string]string) error {
} }
case "RtmpUrl": case "RtmpUrl":
r.config.RtmpUrl = value r.config.RTMPURL = value
case "RtpAddress": case "RtpAddress":
r.config.RtpAddress = value r.config.RTPAddress = value
case "Bitrate": case "Bitrate":
v, err := strconv.ParseUint(value, 10, 0) v, err := strconv.ParseUint(value, 10, 0)
if err != nil { if err != nil {
@ -421,7 +421,7 @@ func (r *Revid) Update(vars map[string]string) error {
} }
r.config.Rotation = uint(v) r.config.Rotation = uint(v)
case "HttpAddress": case "HttpAddress":
r.config.HttpAddress = value r.config.HTTPAddress = value
case "Quantization": case "Quantization":
q, err := strconv.ParseUint(value, 10, 0) q, err := strconv.ParseUint(value, 10, 0)
if err != nil { if err != nil {

View File

@ -224,7 +224,7 @@ func TestResetEncoderSenderSetup(t *testing.T) {
for testNum, test := range tests { for testNum, test := range tests {
// Create a new config and reset revid with it. // Create a new config and reset revid with it.
const dummyURL = "rtmp://dummy" const dummyURL = "rtmp://dummy"
c := Config{Logger: &testLogger{}, Outputs: test.outputs, RtmpUrl: dummyURL} c := Config{Logger: &testLogger{}, Outputs: test.outputs, RTMPURL: dummyURL}
err := rv.setConfig(c) err := rv.setConfig(c)
if err != nil { if err != nil {
t.Fatalf("unexpected error: %v for test %v", err, testNum) t.Fatalf("unexpected error: %v for test %v", err, testNum)