mirror of https://bitbucket.org/ausocean/av.git
rtp: wrote some code so that config validated udp and rtp stuff as well
This commit is contained in:
parent
c0e6ba2a5b
commit
fce0937810
|
@ -195,8 +195,8 @@ func handleFlags() {
|
||||||
}
|
}
|
||||||
|
|
||||||
switch *configFlags[inputCodecPtr] {
|
switch *configFlags[inputCodecPtr] {
|
||||||
case "H264Codec":
|
case "H264":
|
||||||
config.InputCodec = revid.H264Codec
|
config.InputCodec = revid.H264
|
||||||
case "":
|
case "":
|
||||||
default:
|
default:
|
||||||
logger.Log(smartlogger.Error, pkg+"bad input codec argument")
|
logger.Log(smartlogger.Error, pkg+"bad input codec argument")
|
||||||
|
|
|
@ -136,6 +136,7 @@ func (c *Config) Validate(r *Revid) error {
|
||||||
switch c.Input {
|
switch c.Input {
|
||||||
case Raspivid:
|
case Raspivid:
|
||||||
case File:
|
case File:
|
||||||
|
c.Logger.Log(smartlogger.Info, pkg+"Using file input", "input")
|
||||||
case NothingDefined:
|
case NothingDefined:
|
||||||
c.Logger.Log(smartlogger.Warning, pkg+"no input type defined, defaulting", "input",
|
c.Logger.Log(smartlogger.Warning, pkg+"no input type defined, defaulting", "input",
|
||||||
defaultInput)
|
defaultInput)
|
||||||
|
@ -159,6 +160,7 @@ func (c *Config) Validate(r *Revid) error {
|
||||||
return errors.New("bad bitrate and quantization combination for H264 input")
|
return errors.New("bad bitrate and quantization combination for H264 input")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
c.Logger.Log(smartlogger.Info, pkg+"Reading h264 codec", "inputCodec")
|
||||||
case Mjpeg:
|
case Mjpeg:
|
||||||
if c.Quantization != "" {
|
if c.Quantization != "" {
|
||||||
quantization, err := strconv.Atoi(c.Quantization)
|
quantization, err := strconv.Atoi(c.Quantization)
|
||||||
|
@ -182,6 +184,7 @@ func (c *Config) Validate(r *Revid) error {
|
||||||
|
|
||||||
switch c.Output {
|
switch c.Output {
|
||||||
case File:
|
case File:
|
||||||
|
case Udp:
|
||||||
case Rtmp, FfmpegRtmp:
|
case Rtmp, FfmpegRtmp:
|
||||||
if c.RtmpUrl == "" {
|
if c.RtmpUrl == "" {
|
||||||
c.Logger.Log(smartlogger.Info, pkg+"no RTMP URL: falling back to HTTP")
|
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 None:
|
||||||
case Mpegts:
|
case Mpegts:
|
||||||
case Flv:
|
case Flv:
|
||||||
|
case Rtp:
|
||||||
case NothingDefined:
|
case NothingDefined:
|
||||||
c.Logger.Log(smartlogger.Warning, pkg+"no packetization option defined, defaulting",
|
c.Logger.Log(smartlogger.Warning, pkg+"no packetization option defined, defaulting",
|
||||||
"packetization", defaultPacketization)
|
"packetization", defaultPacketization)
|
||||||
|
|
|
@ -487,7 +487,6 @@ func (r *Revid) setupInputForFile() error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
defer f.Close()
|
defer f.Close()
|
||||||
|
|
||||||
// TODO(kortschak): Maybe we want a context.Context-aware parser that we can stop.
|
// TODO(kortschak): Maybe we want a context.Context-aware parser that we can stop.
|
||||||
return r.lexTo(r.encoder, f, delay)
|
return r.lexTo(r.encoder, f, delay)
|
||||||
}
|
}
|
||||||
|
|
|
@ -321,6 +321,9 @@ func (s *udpSender) send() error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *udpSender) release() {}
|
func (s *udpSender) release() {
|
||||||
|
s.chunk.Close()
|
||||||
|
s.chunk = nil
|
||||||
|
}
|
||||||
|
|
||||||
func (s *udpSender) close() error { return nil }
|
func (s *udpSender) close() error { return nil }
|
||||||
|
|
|
@ -50,11 +50,11 @@ type Encoder struct {
|
||||||
|
|
||||||
// NewEncoder returns a new Encoder type given an io.Writer - the destination
|
// NewEncoder returns a new Encoder type given an io.Writer - the destination
|
||||||
// after encoding and the desired fps
|
// after encoding and the desired fps
|
||||||
func NewEncoder(dst io.Writer, fps float64) *Encoder {
|
func NewEncoder(dst io.Writer, fps int) *Encoder {
|
||||||
return &Encoder{
|
return &Encoder{
|
||||||
dst: dst,
|
dst: dst,
|
||||||
ssrc: rand.Uint32(),
|
ssrc: rand.Uint32(),
|
||||||
frameInterval: time.Duration(float64(time.Second) / fps),
|
frameInterval: time.Duration(float64(time.Second) / float64(fps)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue