revid: back to working state

This commit is contained in:
saxon 2018-11-21 18:14:36 +10:30
parent 4c01514b41
commit 315ba6bd76
3 changed files with 9 additions and 15 deletions
cmd/revid-cli
revid

View File

@ -30,6 +30,7 @@ package main
import ( import (
"flag" "flag"
"fmt"
"os" "os"
"runtime/pprof" "runtime/pprof"
"strconv" "strconv"
@ -107,10 +108,10 @@ var (
flagNames = [noOfConfigFlags]struct{ name, description string }{ flagNames = [noOfConfigFlags]struct{ name, description string }{
{"Input", "The input type: Raspivid, File"}, {"Input", "The input type: Raspivid, File"},
{"InputCodec", "The codec of the input: H264, Mjpeg"}, {"InputCodec", "The codec of the input: H264, Mjpeg"},
{"Output", "The output type: Http, Rtmp, File, Udp"}, {"Output", "The output type: Http, Rtmp, File, Udp, Rtp"},
{"RtmpMethod", "The method used to send over rtmp: Ffmpeg, Librtmp"}, {"RtmpMethod", "The method used to send over rtmp: Ffmpeg, Librtmp"},
// NOTE: we add rtp here when we have this functionality // NOTE: we add rtp here when we have this functionality
{"Packetization", "The method of data packetisation: Flv, Mpegts, Rtp, None"}, {"Packetization", "The method of data packetisation: Flv, Mpegts, None"},
{"QuantizationMode", "Whether quantization if on or off (variable bitrate): On, Off"}, {"QuantizationMode", "Whether quantization if on or off (variable bitrate): On, Off"},
{"Verbosity", "Verbosity: Info, Warning, Error, Fatal"}, {"Verbosity", "Verbosity: Info, Warning, Error, Fatal"},
{"FramesPerClip", "Number of frames per clip sent"}, {"FramesPerClip", "Number of frames per clip sent"},
@ -213,6 +214,10 @@ func handleFlags() {
config.Output = revid.FfmpegRtmp config.Output = revid.FfmpegRtmp
case "Udp": case "Udp":
config.Output = revid.Udp config.Output = revid.Udp
case "Rtp":
fmt.Println("rtp output")
config.Output = revid.Rtp
config.Packetization = revid.MpegtsRtp
case "": case "":
default: default:
logger.Log(smartlogger.Error, pkg+"bad output argument") logger.Log(smartlogger.Error, pkg+"bad output argument")

View File

@ -208,19 +208,6 @@ func (c *Config) Validate(r *Revid) error {
return errors.New("bad output type defined in config") return errors.New("bad output type defined in config")
} }
switch c.Packetization {
case None:
case Mpegts:
case Flv:
case Rtp:
case NothingDefined:
c.Logger.Log(smartlogger.Warning, pkg+"no packetization option defined, defaulting",
"packetization", defaultPacketization)
c.Packetization = defaultPacketization
default:
return errors.New("bad packetization option defined in config")
}
switch c.HorizontalFlip { switch c.HorizontalFlip {
case Yes: case Yes:
case No: case No:

View File

@ -228,6 +228,7 @@ func (r *Revid) reset(config Config) error {
case Http: case Http:
r.destination = newHttpSender(r.ns, r.config.Logger.Log) r.destination = newHttpSender(r.ns, r.config.Logger.Log)
case Rtp: case Rtp:
fmt.Println("here")
s, err := newUdpSender(r.config.RtpAddress, r.config.Logger.Log) s, err := newUdpSender(r.config.RtpAddress, r.config.Logger.Log)
if err != nil { if err != nil {
return err return err
@ -279,6 +280,7 @@ func (r *Revid) reset(config Config) error {
return err return err
} }
case MpegtsRtp: case MpegtsRtp:
fmt.Println("here")
r.config.Logger.Log(smartlogger.Info, pkg+"using RTP packetisation") r.config.Logger.Log(smartlogger.Info, pkg+"using RTP packetisation")
frameRate, _ := strconv.Atoi(r.config.FrameRate) frameRate, _ := strconv.Atoi(r.config.FrameRate)
r.encoder = rtp.NewEncoder(&r.packer, frameRate) r.encoder = rtp.NewEncoder(&r.packer, frameRate)