revid: capitalize exported enums that are acronyms like Rtmp->RTMP, Mpegts->MPEGTS etc.

This commit is contained in:
Saxon 2019-05-13 16:18:41 +09:30
parent 001c8696aa
commit 51fcb18505
4 changed files with 27 additions and 38 deletions

View File

@ -107,7 +107,6 @@ func handleFlags() revid.Config {
inputPtr = flag.String("Input", "", "The input type: Raspivid, File, Webcam")
inputCodecPtr = flag.String("InputCodec", "", "The codec of the input: H264, Mjpeg")
rtmpMethodPtr = flag.String("RtmpMethod", "", "The method used to send over rtmp: Ffmpeg, Librtmp")
quantizePtr = flag.Bool("Quantize", false, "Quantize input (non-variable bitrate)")
verbosityPtr = flag.String("Verbosity", "Info", "Verbosity: Debug, Info, Warning, Error, Fatal")
rtpAddrPtr = flag.String("RtpAddr", "", "Rtp destination address: <IP>:<port> (port is generally 6970-6999)")
@ -198,27 +197,17 @@ func handleFlags() revid.Config {
case "File":
cfg.Outputs = append(cfg.Outputs, revid.File)
case "Http":
cfg.Outputs = append(cfg.Outputs, revid.Http)
cfg.Outputs = append(cfg.Outputs, revid.HTTP)
case "Rtmp":
cfg.Outputs = append(cfg.Outputs, revid.Rtmp)
cfg.Outputs = append(cfg.Outputs, revid.RTMP)
case "Rtp":
cfg.Outputs = append(cfg.Outputs, revid.Rtp)
cfg.Outputs = append(cfg.Outputs, revid.RTP)
case "":
default:
log.Log(logger.Error, pkg+"bad output argument", "arg", o)
}
}
switch *rtmpMethodPtr {
case "Ffmpeg":
cfg.RtmpMethod = revid.Ffmpeg
case "LibRtmp":
cfg.RtmpMethod = revid.LibRtmp
case "":
default:
log.Log(logger.Error, pkg+"bad rtmp method argument")
}
if *configFilePtr != "" {
netsender.ConfigFile = *configFilePtr
}

View File

@ -76,20 +76,20 @@ const (
V4L
// Outputs.
Rtmp
Rtp
Http
Mpegts
RTMP
RTP
HTTP
MPEGTS
// Codecs.
H264
Mjpeg
MJPEG
)
// Default config settings
const (
defaultInput = Raspivid
defaultOutput = Http
defaultOutput = HTTP
defaultFrameRate = 25
defaultWidth = 1280
defaultHeight = 720
@ -220,7 +220,7 @@ func (c *Config) Validate(r *Revid) error {
return errors.New("bad bitrate and quantization combination for H264 input")
}
case Mjpeg:
case MJPEG:
if c.Quantization > 0 || c.Bitrate == 0 {
return errors.New("bad bitrate or quantization for mjpeg input")
}
@ -241,10 +241,10 @@ func (c *Config) Validate(r *Revid) error {
for i, o := range c.Outputs {
switch o {
case File:
case Rtmp:
case RTMP:
if c.RtmpUrl == "" {
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?
// c.FramesPerClip = httpFramesPerClip
break
@ -252,7 +252,7 @@ func (c *Config) Validate(r *Revid) error {
c.Logger.Log(logger.Info, pkg+"defaulting frames per clip for rtmp out", "framesPerClip", defaultFramesPerClip)
c.FramesPerClip = defaultFramesPerClip
c.SendRetry = true
case Http, Rtp:
case HTTP, RTP:
c.Logger.Log(logger.Info, pkg+"defaulting frames per clip for http out", "framesPerClip", httpFramesPerClip)
c.FramesPerClip = httpFramesPerClip
default:

View File

@ -212,10 +212,10 @@ func (r *Revid) setupPipeline(mtsEnc, flvEnc func(dst io.WriteCloser, rate int)
var w io.WriteCloser
for _, out := range r.config.Outputs {
switch out {
case Http:
case HTTP:
w = newMtsSender(newHttpSender(r.ns, r.config.Logger.Log), r.config.Logger.Log, rbSize, rbElementSize, 0)
mtsSenders = append(mtsSenders, w)
case Rtp:
case RTP:
w, err := newRtpSender(r.config.RtpAddress, r.config.Logger.Log, r.config.FrameRate)
if err != nil {
r.config.Logger.Log(logger.Warning, pkg+"rtp connect error", "error", err.Error())
@ -227,7 +227,7 @@ func (r *Revid) setupPipeline(mtsEnc, flvEnc func(dst io.WriteCloser, rate int)
return err
}
mtsSenders = append(mtsSenders, w)
case Rtmp:
case RTMP:
w, err := newRtmpSender(r.config.RtmpUrl, rtmpConnectionTimeout, rtmpConnectionMaxTries, r.config.Logger.Log)
if err != nil {
r.config.Logger.Log(logger.Warning, pkg+"rtmp connect error", "error", err.Error())
@ -272,7 +272,7 @@ func (r *Revid) setupPipeline(mtsEnc, flvEnc func(dst io.WriteCloser, rate int)
case H264:
r.config.Logger.Log(logger.Info, pkg+"using H264 lexer")
r.lexTo = lex.H264
case Mjpeg:
case MJPEG:
r.config.Logger.Log(logger.Info, pkg+"using MJPEG lexer")
r.lexTo = lex.MJPEG
}
@ -366,11 +366,11 @@ func (r *Revid) Update(vars map[string]string) error {
case "File":
r.config.Outputs[i] = File
case "Http":
r.config.Outputs[i] = Http
r.config.Outputs[i] = HTTP
case "Rtmp":
r.config.Outputs[i] = Rtmp
r.config.Outputs[i] = RTMP
case "Rtp":
r.config.Outputs[i] = Rtp
r.config.Outputs[i] = RTP
default:
r.config.Logger.Log(logger.Warning, pkg+"invalid output param", "value", value)
continue
@ -527,7 +527,7 @@ func (r *Revid) startRaspivid() (func() error, error) {
if r.config.Quantize {
args = append(args, "-qp", fmt.Sprint(r.config.Quantization))
}
case Mjpeg:
case MJPEG:
args = append(args, "--codec", "MJPEG")
}
r.config.Logger.Log(logger.Info, pkg+"raspivid args", "raspividArgs", strings.Join(args, " "))

View File

@ -148,7 +148,7 @@ func TestResetEncoderSenderSetup(t *testing.T) {
encoders []encoder
}{
{
outputs: []uint8{Http},
outputs: []uint8{HTTP},
encoders: []encoder{
{
encoderType: mtsEncoderStr,
@ -157,7 +157,7 @@ func TestResetEncoderSenderSetup(t *testing.T) {
},
},
{
outputs: []uint8{Rtmp},
outputs: []uint8{RTMP},
encoders: []encoder{
{
encoderType: flvEncoderStr,
@ -166,7 +166,7 @@ func TestResetEncoderSenderSetup(t *testing.T) {
},
},
{
outputs: []uint8{Rtp},
outputs: []uint8{RTP},
encoders: []encoder{
{
encoderType: mtsEncoderStr,
@ -175,7 +175,7 @@ func TestResetEncoderSenderSetup(t *testing.T) {
},
},
{
outputs: []uint8{Http, Rtmp},
outputs: []uint8{HTTP, RTMP},
encoders: []encoder{
{
encoderType: mtsEncoderStr,
@ -188,7 +188,7 @@ func TestResetEncoderSenderSetup(t *testing.T) {
},
},
{
outputs: []uint8{Http, Rtp, Rtmp},
outputs: []uint8{HTTP, RTP, RTMP},
encoders: []encoder{
{
encoderType: mtsEncoderStr,
@ -201,7 +201,7 @@ func TestResetEncoderSenderSetup(t *testing.T) {
},
},
{
outputs: []uint8{Rtp, Rtmp},
outputs: []uint8{RTP, RTMP},
encoders: []encoder{
{
encoderType: mtsEncoderStr,