Merged in revid/waiturl (pull request #24)

revid: wait for URL from netreceiver

Approved-by: Alan Noble <anoble@gmail.com>
This commit is contained in:
kortschak 2018-06-08 00:30:45 +00:00 committed by Alan Noble
commit 576815a10f
4 changed files with 66 additions and 64 deletions

View File

@ -44,27 +44,29 @@ import (
// Indexes for configFlags
const (
inputPtr = 0
inputCodecPtr = 1
outputPtr = 2
rtmpMethodPtr = 3
packetizationPtr = 4
quantizationModePtr = 5
verbosityPtr = 6
framesPerClipPtr = 7
rtmpUrlPtr = 8
bitratePtr = 9
outputFileNamePtr = 10
inputFileNamePtr = 11
heightPtr = 12
widthPtr = 13
frameRatePtr = 14
httpAddressPtr = 15
quantizationPtr = 16
timeoutPtr = 17
intraRefreshPeriodPtr = 18
verticalFlipPtr = 19
horizontalFlipPtr = 20
inputPtr = iota
inputCodecPtr
outputPtr
rtmpMethodPtr
packetizationPtr
quantizationModePtr
verbosityPtr
framesPerClipPtr
rtmpUrlPtr
bitratePtr
outputFileNamePtr
inputFileNamePtr
heightPtr
widthPtr
frameRatePtr
httpAddressPtr
quantizationPtr
timeoutPtr
intraRefreshPeriodPtr
verticalFlipPtr
horizontalFlipPtr
noOfConfigFlags
)
// Other misc consts
@ -73,7 +75,6 @@ const (
netSendRetryTime = 5
sleepTime = 2 * 43200
defaultRunDuration = 2 * 43200
noOfConfigFlags = 21
revidStopTime = 5
prepTime = 20
loggerVerbosity = 3
@ -93,7 +94,7 @@ var (
)
func main() {
flagNames := [noOfConfigFlags][2]string{
flagNames := [noOfConfigFlags]struct{ name, description string }{
{"Input", "The input type"},
{"InputCodec", "The codec of the input"},
{"Output", "The output type"},
@ -119,8 +120,8 @@ func main() {
// Create the configFlags based on the flagNames array
configFlags := make([](*string), noOfConfigFlags)
for i := 0; i < noOfConfigFlags; i++ {
configFlags[i] = flag.String(flagNames[i][0], "", flagNames[i][1])
for i, f := range &flagNames {
configFlags[i] = flag.String(f.name, "", f.description)
}
// Do we want a netsender session
@ -265,7 +266,7 @@ func main() {
}
if vs != ns.GetVarSum() {
// vars changed
// vars changed
vars, err := ns.GetVars()
if err != nil {
config.Logger.Log(progName, "Error", err.Error())
@ -326,6 +327,9 @@ func startRevid() {
func stopRevid() {
revidInst.Stop()
// FIXME(kortschak): Is this waiting on completion of work?
// Use a wait group and Wait method if it is.
time.Sleep(time.Duration(revidStopTime) * time.Second)
}

View File

@ -3,7 +3,6 @@
# This script launches revid-cli at boot time
REVIDPATH=/home/pi/go/src/bitbucket.org/ausocean/av/cmd/revid-cli
RTMPURL=rtmp://a.rtmp.youtube.com/live2/vq8y-wzxh-731t-7rtb
# kernel settings to improve performance on Raspberry Pi
# tell Linux to fork optimistically
@ -27,6 +26,6 @@ exec 1>&2
# set working dir and run revid-cli
cd $REVIDPATH
sudo "PATH=$PATH:$REVIDPATH" ./revid-cli -Verbosity=Yes -Input=Raspivid -Output=NativeRtmp -QuantizationMode=QuantizationOff -RtmpUrl=$RTMPURL -Bitrate=500000 -Packetization=Flv -NetSender &
sudo "PATH=$PATH:$REVIDPATH" ./revid-cli -Verbosity=Yes -Input=Raspivid -Output=NativeRtmp -QuantizationMode=QuantizationOff -Bitrate=500000 -Packetization=Flv -NetSender &
exit 0

View File

@ -6,10 +6,10 @@ DESCRIPTION
See Readme.md
AUTHORS
Saxon A. Nelson-Milton <saxon@ausocean.org>
Saxon A. Nelson-Milton <saxon@ausocean.org>
LICENSE
Config.go is Copyright (C) 2017 the Australian Ocean Lab (AusOcean)
Config.go is Copyright (C) 2017-2018 the Australian Ocean Lab (AusOcean)
It is free software: you can redistribute it and/or modify them
under the terms of the GNU General Public License as published by the
@ -22,7 +22,7 @@ LICENSE
for more details.
You should have received a copy of the GNU General Public License
along with revid in gpl.txt. If not, see [GNU licenses](http://www.gnu.org/licenses).
along with revid in gpl.txt. If not, see http://www.gnu.org/licenses.
*/
package revid
@ -63,33 +63,32 @@ type Config struct {
// Enums for config struct
const (
NothingDefined = 0
Raspivid = 1
Rtp = 2
H264Codec = 3
File = 4
Http = 5
H264 = 6
Mjpeg = 7
None = 8
Mpegts = 9
Ffmpeg = 11
Flv = 13
LibRtmp = 14
QuantizationOn = 15
QuantizationOff = 16
Yes = 17
No = 18
NativeRtmp = 19
FfmpegRtmp = 20
NothingDefined = iota
Raspivid
Rtp
H264Codec
File
Http
H264
Mjpeg
None
Mpegts
Ffmpeg
Flv
LibRtmp
QuantizationOn
QuantizationOff
Yes
No
NativeRtmp
FfmpegRtmp
)
// Default config settings
const (
defaultInput = Raspivid
defaultOutput = NativeRtmp
defaultOutput = Http
defaultPacketization = Flv
defaultRtmpUrl = "rtmp://a.rtmp.youtube.com/live2/vq8y-wzxh-731t-7rtb"
defaultFrameRate = "25"
defaultWidth = "1280"
defaultHeight = "720"
@ -174,15 +173,11 @@ func (config *Config) Validate(r *revid) error {
switch config.Output {
case Http:
case File:
case NativeRtmp:
case NativeRtmp, FfmpegRtmp:
if config.RtmpUrl == "" {
return errors.New("Bad RTMP URL")
}
r.Log(Info, "Defaulting frames per clip to 1 for rtmp output!")
config.FramesPerClip = "1"
case FfmpegRtmp:
if config.RtmpUrl == "" {
return errors.New("Bad RTMP URL")
r.Log(Info, "No RTMP URL: falling back to HTTP")
config.Output = Http
break
}
r.Log(Info, "Defaulting frames per clip to 1 for rtmp output!")
config.FramesPerClip = "1"

View File

@ -6,11 +6,11 @@ DESCRIPTION
See Readme.md
AUTHORS
Saxon A. Nelson-Milton <saxon@ausocean.org>
Alan Noble <alan@ausocean.org>
Saxon A. Nelson-Milton <saxon@ausocean.org>
Alan Noble <alan@ausocean.org>
LICENSE
revid is Copyright (C) 2017 the Australian Ocean Lab (AusOcean)
revid is Copyright (C) 2017-2018 the Australian Ocean Lab (AusOcean)
It is free software: you can redistribute it and/or modify them
under the terms of the GNU General Public License as published by the
@ -23,7 +23,7 @@ LICENSE
for more details.
You should have received a copy of the GNU General Public License
along with revid in gpl.txt. If not, see [GNU licenses](http://www.gnu.org/licenses).
along with revid in gpl.txt. If not, see http://www.gnu.org/licenses.
*/
// revid is a testbed for re-muxing and re-directing video streams as MPEG-TS over various protocols.
@ -216,6 +216,10 @@ noPacketizationSetup:
// ChangeConfig changes the current configuration of the revid instance.
func (r *revid) ChangeConfig(config Config) (err error) {
// FIXME(kortschak): This is reimplemented in cmd/revid-cli/main.go.
// The implementation in the command is used and this is not.
// Decide on one or the other.
r.Stop()
r, err = NewRevid(config)
if err != nil {