From 8337d87a25d3e437e4c9f4a946079608a19d1094 Mon Sep 17 00:00:00 2001 From: Saxon Date: Mon, 13 May 2019 15:42:16 +0930 Subject: [PATCH 1/6] revid/config.go: cleaned up enums for inputs, outputs and codecs. --- revid/config.go | 165 +++++++++++++++++++++++------------------------- 1 file changed, 79 insertions(+), 86 deletions(-) diff --git a/revid/config.go b/revid/config.go index 010af3fd..d26a72d5 100644 --- a/revid/config.go +++ b/revid/config.go @@ -33,8 +33,85 @@ import ( "bitbucket.org/ausocean/utils/logger" ) +// Possible modes for raspivid --exposure parameter. +var ExposureModes = [...]string{ + "auto", + "night", + "nightpreview", + "backlight", + "spotlight", + "sports", + "snow", + "beach", + "verylong", + "fixedfps", + "antishake", + "fireworks", +} + +// Possible modes for raspivid --awb parameter. +var AutoWhiteBalanceModes = [...]string{ + "off", + "auto", + "sun", + "cloud", + "shade", + "tungsten", + "fluorescent", + "incandescent", + "flash", + "horizon", +} + +// Enums to define inputs, outputs and codecs. +const ( + // Indicates no option has been set. + NothingDefined = iota + + // Input/Output. + File + + // Inputs. + Raspivid + V4L + + // Outputs. + Rtmp + Rtp + Http + Mpegts + + // Codecs. + H264 + Mjpeg +) + +// Default config settings +const ( + defaultInput = Raspivid + defaultOutput = Http + defaultFrameRate = 25 + defaultWidth = 1280 + defaultHeight = 720 + defaultIntraRefreshPeriod = 100 + defaultTimeout = 0 + defaultQuantization = 40 + defaultBitrate = 400000 + defaultFramesPerClip = 1 + httpFramesPerClip = 560 + defaultInputCodec = H264 + defaultVerbosity = logger.Error + defaultRtpAddr = "localhost:6970" + defaultBurstPeriod = 10 // Seconds + defaultRotation = 0 // Degrees + defaultBrightness = 50 + defaultExposure = "auto" + defaultAutoWhiteBalance = "auto" +) + // Config provides parameters relevant to a revid instance. A new config must -// be passed to the constructor. +// be passed to the constructor. Default values for these fields are defined +// as consts at the beginning of this file. type Config struct { LogLevel int8 @@ -76,87 +153,6 @@ type Config struct { AutoWhiteBalance string } -// Possible modes for raspivid --exposure parameter. -var ExposureModes = [...]string{ - "auto", - "night", - "nightpreview", - "backlight", - "spotlight", - "sports", - "snow", - "beach", - "verylong", - "fixedfps", - "antishake", - "fireworks", -} - -// Possible modes for raspivid --awb parameter. -var AutoWhiteBalanceModes = [...]string{ - "off", - "auto", - "sun", - "cloud", - "shade", - "tungsten", - "fluorescent", - "incandescent", - "flash", - "horizon", -} - -// Enums for config struct -const ( - NothingDefined = iota - Raspivid - V4L - H264Codec - File - Http - H264 - Mjpeg - None - Mpegts - Ffmpeg - Flv - LibRtmp - QuantizationOn - QuantizationOff - Yes - No - Rtmp - FfmpegRtmp - Udp - MpegtsRtp - Rtp -) - -// Default config settings -const ( - defaultInput = Raspivid - defaultOutput = Http - defaultPacketization = Flv - defaultFrameRate = 25 - defaultWidth = 1280 - defaultHeight = 720 - defaultIntraRefreshPeriod = 100 - defaultTimeout = 0 - defaultQuantization = 40 - defaultBitrate = 400000 - defaultQuantizationMode = QuantizationOff - defaultFramesPerClip = 1 - httpFramesPerClip = 560 - defaultInputCodec = H264 - defaultVerbosity = logger.Error - defaultRtpAddr = "localhost:6970" - defaultBurstPeriod = 10 // Seconds - defaultRotation = 0 // Degrees - defaultBrightness = 50 - defaultExposure = "auto" - defaultAutoWhiteBalance = "auto" -) - // Validate checks for any errors in the config fields and defaults settings // if particular parameters have not been defined. func (c *Config) Validate(r *Revid) error { @@ -209,13 +205,11 @@ func (c *Config) Validate(r *Revid) error { if c.Outputs == nil { c.Logger.Log(logger.Info, pkg+"no output defined, defaulting", "output", defaultOutput) c.Outputs = append(c.Outputs, defaultOutput) - c.Packetization = defaultPacketization } else { for i, o := range c.Outputs { switch o { case File: - case Udp: - case Rtmp, FfmpegRtmp: + case Rtmp: if c.RtmpUrl == "" { c.Logger.Log(logger.Info, pkg+"no RTMP URL: falling back to HTTP") c.Outputs[i] = Http @@ -225,7 +219,6 @@ 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.Packetization = Flv c.SendRetry = true case Http, Rtp: c.Logger.Log(logger.Info, pkg+"defaulting frames per clip for http out", "framesPerClip", httpFramesPerClip) From 001c8696aaeb26d02cce4930cadda762a6b9a5da Mon Sep 17 00:00:00 2001 From: Saxon Date: Mon, 13 May 2019 16:12:08 +0930 Subject: [PATCH 2/6] revid/config.go: started commenting config fields --- revid/config.go | 55 ++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 43 insertions(+), 12 deletions(-) diff --git a/revid/config.go b/revid/config.go index d26a72d5..ff6f198e 100644 --- a/revid/config.go +++ b/revid/config.go @@ -111,27 +111,59 @@ const ( // Config provides parameters relevant to a revid instance. A new config must // be passed to the constructor. Default values for these fields are defined -// as consts at the beginning of this file. +// as consts above. type Config struct { + // LogLevel is the revid logging verbosity level. + // Valid values are defined by enums from the logger package: logger.Debug, + // logger.Info, logger.Warning logger.Error, logger.Fatal. LogLevel int8 - Input uint8 - InputCodec uint8 - Outputs []uint8 - RtmpMethod uint8 - Packetization uint8 + // Input defines the input data source. + // + // Valid values are defined by enums: + // Raspivid: + // Read data from a Raspberry Pi Camera. + // V4l: + // Read from webcam. + // File: + // Location must be specified in InputPath field. + Input uint8 - // Quantize specifies whether the input to - // revid will have constant or variable + // InputCodec defines the input codec we wish to use, and therefore define the + // lexer for use in the pipeline. In most cases this defaults according to a + // particular input. Both Raspivid and V4l use H264, but File input may use + // H264 or MJPEG. + InputCodec uint8 + + // Outputs define the outputs we wish to output data too. + // + // Valid outputs are defined by enums: + // File: + // Location must be defined by the OutputPath field. MPEG-TS packetization + // is used. + // Http: + // Destination is defined by the sh field located in /etc/netsender.conf. + // MPEGT-TS packetization is used. + // Rtmp: + // Destination URL must be defined in the RtmpUrl field. FLV packetization + // is used. + // Rtp: + // Destination is defined by RtpAddr field, otherwise it will default to + // localhost:6970. MPEGT-TS packetization is used. + Outputs []uint8 + + // Quantize specifies whether the input to revid will have constant or variable // bitrate. Quantize bool - // FlipHorizonatla and FlipVertical specify - // whether video frames should be flipped. + // FlipHorizonatla and FlipVertical specify whether video frames should be flipped. FlipHorizontal bool FlipVertical bool - FramesPerClip uint + FramesPerClip uint + + // RtmpUrl specifies the Rtmp output destination URL. This must be defined if + // RTMP is to be used as an output. RtmpUrl string Bitrate uint OutputPath string @@ -223,7 +255,6 @@ func (c *Config) Validate(r *Revid) error { case Http, Rtp: c.Logger.Log(logger.Info, pkg+"defaulting frames per clip for http out", "framesPerClip", httpFramesPerClip) c.FramesPerClip = httpFramesPerClip - c.Packetization = Mpegts default: return errors.New("bad output type defined in config") } From 51fcb18505799b580abca48d112cd74710033528 Mon Sep 17 00:00:00 2001 From: Saxon Date: Mon, 13 May 2019 16:18:41 +0930 Subject: [PATCH 3/6] revid: capitalize exported enums that are acronyms like Rtmp->RTMP, Mpegts->MPEGTS etc. --- cmd/revid-cli/main.go | 17 +++-------------- revid/config.go | 20 ++++++++++---------- revid/revid.go | 16 ++++++++-------- revid/revid_test.go | 12 ++++++------ 4 files changed, 27 insertions(+), 38 deletions(-) diff --git a/cmd/revid-cli/main.go b/cmd/revid-cli/main.go index fc90dbcc..51b3d31f 100644 --- a/cmd/revid-cli/main.go +++ b/cmd/revid-cli/main.go @@ -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: : (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 } diff --git a/revid/config.go b/revid/config.go index ff6f198e..b42059f4 100644 --- a/revid/config.go +++ b/revid/config.go @@ -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: diff --git a/revid/revid.go b/revid/revid.go index 43c4f982..92f8b35f 100644 --- a/revid/revid.go +++ b/revid/revid.go @@ -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, " ")) diff --git a/revid/revid_test.go b/revid/revid_test.go index 18086912..e17740df 100644 --- a/revid/revid_test.go +++ b/revid/revid_test.go @@ -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, From 835f97203a030acf153be501d8565f8f9a806342 Mon Sep 17 00:00:00 2001 From: Saxon Date: Mon, 13 May 2019 16:23:38 +0930 Subject: [PATCH 4/6] revid: config fields that are exported and acronyms now capitalized. --- cmd/revid-cli/main.go | 6 +++--- revid/config.go | 18 +++++++++--------- revid/revid.go | 10 +++++----- revid/revid_test.go | 2 +- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/cmd/revid-cli/main.go b/cmd/revid-cli/main.go index 51b3d31f..c4729b2a 100644 --- a/cmd/revid-cli/main.go +++ b/cmd/revid-cli/main.go @@ -217,17 +217,17 @@ func handleFlags() revid.Config { cfg.FlipHorizontal = *horizontalFlipPtr cfg.FlipVertical = *verticalFlipPtr cfg.FramesPerClip = *framesPerClipPtr - cfg.RtmpUrl = *rtmpUrlPtr + cfg.RTMPURL = *rtmpUrlPtr cfg.Bitrate = *bitratePtr cfg.OutputPath = *outputPathPtr cfg.InputPath = *inputFilePtr cfg.Height = *heightPtr cfg.Width = *widthPtr cfg.FrameRate = *frameRatePtr - cfg.HttpAddress = *httpAddressPtr + cfg.HTTPAddress = *httpAddressPtr cfg.Quantization = *quantizationPtr cfg.IntraRefreshPeriod = *intraRefreshPeriodPtr - cfg.RtpAddress = *rtpAddrPtr + cfg.RTPAddress = *rtpAddrPtr cfg.SendRetry = *sendRetryPtr cfg.Brightness = *brightnessPtr cfg.Saturation = *saturationPtr diff --git a/revid/config.go b/revid/config.go index b42059f4..b71256a1 100644 --- a/revid/config.go +++ b/revid/config.go @@ -141,13 +141,13 @@ type Config struct { // File: // Location must be defined by the OutputPath field. MPEG-TS packetization // is used. - // Http: + // HTTP: // Destination is defined by the sh field located in /etc/netsender.conf. // MPEGT-TS packetization is used. - // Rtmp: + // RTMP: // Destination URL must be defined in the RtmpUrl field. FLV packetization // is used. - // Rtp: + // RTP: // Destination is defined by RtpAddr field, otherwise it will default to // localhost:6970. MPEGT-TS packetization is used. Outputs []uint8 @@ -164,17 +164,17 @@ type Config struct { // RtmpUrl specifies the Rtmp output destination URL. This must be defined if // RTMP is to be used as an output. - RtmpUrl string + RTMPURL string Bitrate uint OutputPath string InputPath string Height uint Width uint FrameRate uint - HttpAddress string + HTTPAddress string Quantization uint IntraRefreshPeriod uint - RtpAddress string + RTPAddress string Logger Logger SendRetry bool BurstPeriod uint @@ -242,7 +242,7 @@ func (c *Config) Validate(r *Revid) error { switch o { case File: case RTMP: - if c.RtmpUrl == "" { + if c.RTMPURL == "" { c.Logger.Log(logger.Info, pkg+"no RTMP URL: falling back to HTTP") c.Outputs[i] = HTTP // 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") } - if c.RtpAddress == "" { - c.RtpAddress = defaultRtpAddr + if c.RTPAddress == "" { + c.RTPAddress = defaultRtpAddr } switch { diff --git a/revid/revid.go b/revid/revid.go index 92f8b35f..88657a2d 100644 --- a/revid/revid.go +++ b/revid/revid.go @@ -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) mtsSenders = append(mtsSenders, w) 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 { 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) 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 { 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": - r.config.RtmpUrl = value + r.config.RTMPURL = value case "RtpAddress": - r.config.RtpAddress = value + r.config.RTPAddress = value case "Bitrate": v, err := strconv.ParseUint(value, 10, 0) if err != nil { @@ -421,7 +421,7 @@ func (r *Revid) Update(vars map[string]string) error { } r.config.Rotation = uint(v) case "HttpAddress": - r.config.HttpAddress = value + r.config.HTTPAddress = value case "Quantization": q, err := strconv.ParseUint(value, 10, 0) if err != nil { diff --git a/revid/revid_test.go b/revid/revid_test.go index e17740df..36cc913d 100644 --- a/revid/revid_test.go +++ b/revid/revid_test.go @@ -224,7 +224,7 @@ func TestResetEncoderSenderSetup(t *testing.T) { for testNum, test := range tests { // Create a new config and reset revid with it. 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) if err != nil { t.Fatalf("unexpected error: %v for test %v", err, testNum) From 1762adf3383b332d16e573359df3415459304fcf Mon Sep 17 00:00:00 2001 From: Saxon Date: Mon, 13 May 2019 16:55:20 +0930 Subject: [PATCH 5/6] revid/config.go: finished commenting config fields, and removed unused options. --- cmd/revid-cli/main.go | 2 -- revid/config.go | 82 ++++++++++++++++++++++++++++++------------- 2 files changed, 57 insertions(+), 27 deletions(-) diff --git a/cmd/revid-cli/main.go b/cmd/revid-cli/main.go index c4729b2a..98804a5b 100644 --- a/cmd/revid-cli/main.go +++ b/cmd/revid-cli/main.go @@ -116,7 +116,6 @@ func handleFlags() revid.Config { outputPathPtr = flag.String("OutputPath", "", "The directory of the output file") inputFilePtr = flag.String("InputPath", "", "The directory of the input file") httpAddressPtr = flag.String("HttpAddress", "", "Destination address of http posts") - sendRetryPtr = flag.Bool("retry", false, "Specify whether a failed send should be retried.") verticalFlipPtr = flag.Bool("VerticalFlip", false, "Flip video vertically: Yes, No") horizontalFlipPtr = flag.Bool("HorizontalFlip", false, "Flip video horizontally: Yes, No") framesPerClipPtr = flag.Uint("FramesPerClip", 0, "Number of frames per clip sent") @@ -228,7 +227,6 @@ func handleFlags() revid.Config { cfg.Quantization = *quantizationPtr cfg.IntraRefreshPeriod = *intraRefreshPeriodPtr cfg.RTPAddress = *rtpAddrPtr - cfg.SendRetry = *sendRetryPtr cfg.Brightness = *brightnessPtr cfg.Saturation = *saturationPtr cfg.Exposure = *exposurePtr diff --git a/revid/config.go b/revid/config.go index b71256a1..b33eb7ad 100644 --- a/revid/config.go +++ b/revid/config.go @@ -153,36 +153,69 @@ type Config struct { Outputs []uint8 // Quantize specifies whether the input to revid will have constant or variable - // bitrate. + // bitrate, if configurable with the chosen input. Raspivid supports quantization. Quantize bool - // FlipHorizonatla and FlipVertical specify whether video frames should be flipped. - FlipHorizontal bool - FlipVertical bool - + // FramesPerClip defines the number of packetization units to pack into a clip + // per HTTP send. FramesPerClip uint - // 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. - RTMPURL string - Bitrate uint - OutputPath string - InputPath string - Height uint - Width uint - FrameRate uint - HTTPAddress string - Quantization uint + RTMPURL string + + // OutputPath defines the output destination for File output. This must be + // defined if File output is to be used. + OutputPath string + + // InputPath defines the input file location for File Input. This must be + // defined if File input is to be used. + InputPath string + + // FrameRate defines the input frame rate if configurable by the chosen input. + // Raspivid input supports custom framerate. + FrameRate uint + + // HTTPAddress defines a custom HTTP destination if we do not wish to use that + // defined in /etc/netsender.conf. + HTTPAddress string + + // Quantization defines the quantization level, which may be a value between + // 0-40. This will only take effect if the Quantize field is true and if we + // are using Raspivid input. + Quantization uint + + // IntraRefreshPeriod defines the frequency of video parameter NAL units for + // Raspivid input. IntraRefreshPeriod uint - RTPAddress string - Logger Logger - SendRetry bool - BurstPeriod uint - Rotation uint - Brightness uint - Saturation int - Exposure string - AutoWhiteBalance string + + // Logger holds an implementation of the Logger interface as defined in revid.go. + // This must be set for revid to work correctly. + Logger Logger + + // Brightness and saturation define the brightness and saturation levels for + // Raspivid input. + Brightness uint + Saturation int + + // Exposure defines the exposure mode used by the Raspivid input. Valid modes + // are defined in the exported []string ExposureModes defined at the start + // of the file. + Exposure string + + // AutoWhiteBalance defines the auto white balance mode used by Raspivid input. + // Valid modes are defined in the exported []string AutoWhiteBalanceModes + // defined at the start of the file. + AutoWhiteBalance string + + RTPAddress string // RTPAddress defines the RTP output destination. + BurstPeriod uint // BurstPeriod defines the revid burst period in seconds. + Rotation uint // Rotation defines the video rotation angle in degrees Raspivid input. + Height uint // Height defines the input video height Raspivid input. + Width uint // Width defines the input video width Raspivid input. + Bitrate uint // Bitrate specifies the input bitrate for Raspivid input. + FlipHorizontal bool // FlipHorizontal flips video horizontally for Raspivid input. + FlipVertical bool // FlipVertial flips video vertically for Raspivid input. } // Validate checks for any errors in the config fields and defaults settings @@ -251,7 +284,6 @@ 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: c.Logger.Log(logger.Info, pkg+"defaulting frames per clip for http out", "framesPerClip", httpFramesPerClip) c.FramesPerClip = httpFramesPerClip From 061b01529705afa593665306ef7b83ecf88b2a65 Mon Sep 17 00:00:00 2001 From: Saxon Date: Tue, 28 May 2019 12:37:50 +0930 Subject: [PATCH 6/6] revid/config.go: updated commend for Config's InputCodec field. --- revid/config.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/revid/config.go b/revid/config.go index f2d04193..4046f320 100644 --- a/revid/config.go +++ b/revid/config.go @@ -133,10 +133,9 @@ type Config struct { // RTSPURL must also be defined. Input uint8 - // InputCodec defines the input codec we wish to use, and therefore define the - // lexer for use in the pipeline. In most cases this defaults according to a - // particular input. Both Raspivid and V4l use H264, but File input may use - // H264 or MJPEG. + // InputCodec defines the input codec we wish to use, and therefore defines the + // lexer for use in the pipeline. This defaults to H264, but H265 is also a + // valid option if we expect this from the input. InputCodec uint8 // Outputs define the outputs we wish to output data too.