rtp: wrote some code so that config validated udp and rtp stuff as well

This commit is contained in:
saxon 2018-11-18 18:13:38 +10:30
parent c0e6ba2a5b
commit fce0937810
5 changed files with 12 additions and 6 deletions

View File

@ -195,8 +195,8 @@ func handleFlags() {
}
switch *configFlags[inputCodecPtr] {
case "H264Codec":
config.InputCodec = revid.H264Codec
case "H264":
config.InputCodec = revid.H264
case "":
default:
logger.Log(smartlogger.Error, pkg+"bad input codec argument")

View File

@ -136,6 +136,7 @@ func (c *Config) Validate(r *Revid) error {
switch c.Input {
case Raspivid:
case File:
c.Logger.Log(smartlogger.Info, pkg+"Using file input", "input")
case NothingDefined:
c.Logger.Log(smartlogger.Warning, pkg+"no input type defined, defaulting", "input",
defaultInput)
@ -159,6 +160,7 @@ func (c *Config) Validate(r *Revid) error {
return errors.New("bad bitrate and quantization combination for H264 input")
}
}
c.Logger.Log(smartlogger.Info, pkg+"Reading h264 codec", "inputCodec")
case Mjpeg:
if c.Quantization != "" {
quantization, err := strconv.Atoi(c.Quantization)
@ -182,6 +184,7 @@ func (c *Config) Validate(r *Revid) error {
switch c.Output {
case File:
case Udp:
case Rtmp, FfmpegRtmp:
if c.RtmpUrl == "" {
c.Logger.Log(smartlogger.Info, pkg+"no RTMP URL: falling back to HTTP")
@ -208,6 +211,7 @@ func (c *Config) Validate(r *Revid) error {
case None:
case Mpegts:
case Flv:
case Rtp:
case NothingDefined:
c.Logger.Log(smartlogger.Warning, pkg+"no packetization option defined, defaulting",
"packetization", defaultPacketization)

View File

@ -487,7 +487,6 @@ func (r *Revid) setupInputForFile() error {
return err
}
defer f.Close()
// TODO(kortschak): Maybe we want a context.Context-aware parser that we can stop.
return r.lexTo(r.encoder, f, delay)
}

View File

@ -321,6 +321,9 @@ func (s *udpSender) send() error {
return err
}
func (s *udpSender) release() {}
func (s *udpSender) release() {
s.chunk.Close()
s.chunk = nil
}
func (s *udpSender) close() error { return nil }

View File

@ -50,11 +50,11 @@ type Encoder struct {
// NewEncoder returns a new Encoder type given an io.Writer - the destination
// after encoding and the desired fps
func NewEncoder(dst io.Writer, fps float64) *Encoder {
func NewEncoder(dst io.Writer, fps int) *Encoder {
return &Encoder{
dst: dst,
ssrc: rand.Uint32(),
frameInterval: time.Duration(float64(time.Second) / fps),
frameInterval: time.Duration(float64(time.Second) / float64(fps)),
}
}