mirror of https://bitbucket.org/ausocean/av.git
revid: accept multiple RTMP outputs
This change modifies the revid config RTMPURL field to be a slice instead of a single string. This allows use to have multiple RTMP outputs.
This commit is contained in:
parent
66daab5e7c
commit
f8fe900207
|
@ -226,16 +226,16 @@ type Config struct {
|
||||||
// localhost:6970. MPEGT-TS packetization is used.
|
// localhost:6970. MPEGT-TS packetization is used.
|
||||||
Outputs []uint8
|
Outputs []uint8
|
||||||
|
|
||||||
PSITime uint // Sets the time between a packet being sent.
|
PSITime uint // Sets the time between a packet being sent.
|
||||||
Quantization uint // Quantization defines the quantization level, which will determine variable bitrate quality in the case of input from the Pi Camera.
|
Quantization uint // Quantization defines the quantization level, which will determine variable bitrate quality in the case of input from the Pi Camera.
|
||||||
PoolCapacity uint // The number of bytes the pool buffer will occupy.
|
PoolCapacity uint // The number of bytes the pool buffer will occupy.
|
||||||
PoolStartElementSize uint // The starting element size of the pool buffer from which element size will increase to accomodate frames.
|
PoolStartElementSize uint // The starting element size of the pool buffer from which element size will increase to accomodate frames.
|
||||||
PoolWriteTimeout uint // The pool buffer write timeout in seconds.
|
PoolWriteTimeout uint // The pool buffer write timeout in seconds.
|
||||||
RecPeriod float64 // How many seconds to record at a time.
|
RecPeriod float64 // How many seconds to record at a time.
|
||||||
Rotation uint // Rotation defines the video rotation angle in degrees Raspivid input.
|
Rotation uint // Rotation defines the video rotation angle in degrees Raspivid input.
|
||||||
RTMPURL string // RTMPURL specifies the Rtmp output destination URL. This must be defined if RTMP is to be used as an output.
|
RTMPURL []string // RTMPURL specifies the Rtmp output destination URL. This must be defined if RTMP is to be used as an output.
|
||||||
RTPAddress string // RTPAddress defines the RTP output destination.
|
RTPAddress string // RTPAddress defines the RTP output destination.
|
||||||
SampleRate uint // Samples a second (Hz).
|
SampleRate uint // Samples a second (Hz).
|
||||||
Saturation int
|
Saturation int
|
||||||
|
|
||||||
// Sharpness is the sharpness of capture image/video from a capture device.
|
// Sharpness is the sharpness of capture image/video from a capture device.
|
||||||
|
|
|
@ -166,7 +166,7 @@ func TestUpdate(t *testing.T) {
|
||||||
PoolCapacity: 100000,
|
PoolCapacity: 100000,
|
||||||
PoolWriteTimeout: 50,
|
PoolWriteTimeout: 50,
|
||||||
Rotation: 180,
|
Rotation: 180,
|
||||||
RTMPURL: "rtmp://url",
|
RTMPURL: []string{"rtmp://url"},
|
||||||
RTPAddress: "ip:port",
|
RTPAddress: "ip:port",
|
||||||
Saturation: -10,
|
Saturation: -10,
|
||||||
VBRBitrate: 300000,
|
VBRBitrate: 300000,
|
||||||
|
|
|
@ -582,9 +582,15 @@ var Variables = []struct {
|
||||||
Update: func(c *Config, v string) { c.Rotation = parseUint(KeyRotation, v, c) },
|
Update: func(c *Config, v string) { c.Rotation = parseUint(KeyRotation, v, c) },
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: KeyRTMPURL,
|
Name: KeyRTMPURL,
|
||||||
Type: typeString,
|
Type: typeString,
|
||||||
Update: func(c *Config, v string) { c.RTMPURL = v },
|
Update: func(c *Config, v string) {
|
||||||
|
v = strings.ReplaceAll(v, " ", "")
|
||||||
|
split := strings.Split(v, ",")
|
||||||
|
for _, s := range split {
|
||||||
|
c.RTMPURL = append(c.RTMPURL, s)
|
||||||
|
}
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: KeyRTPAddress,
|
Name: KeyRTPAddress,
|
||||||
|
|
|
@ -178,6 +178,7 @@ func (r *Revid) setupPipeline(mtsEnc func(dst io.WriteCloser, rate float64) (io.
|
||||||
// to mtsSenders if the output requires MPEGTS encoding, or flvSenders if the
|
// to mtsSenders if the output requires MPEGTS encoding, or flvSenders if the
|
||||||
// output requires FLV encoding.
|
// output requires FLV encoding.
|
||||||
var w io.WriteCloser
|
var w io.WriteCloser
|
||||||
|
rtmpUrlIdx := 0
|
||||||
for _, out := range r.cfg.Outputs {
|
for _, out := range r.cfg.Outputs {
|
||||||
switch out {
|
switch out {
|
||||||
case config.OutputHTTP:
|
case config.OutputHTTP:
|
||||||
|
@ -215,11 +216,16 @@ func (r *Revid) setupPipeline(mtsEnc func(dst io.WriteCloser, rate float64) (io.
|
||||||
mtsSenders = append(mtsSenders, w)
|
mtsSenders = append(mtsSenders, w)
|
||||||
case config.OutputRTMP:
|
case config.OutputRTMP:
|
||||||
r.cfg.Logger.Debug("using RTMP output")
|
r.cfg.Logger.Debug("using RTMP output")
|
||||||
|
if rtmpUrlIdx > len(r.cfg.RTMPURL)-1 {
|
||||||
|
r.cfg.Logger.Warning("rtmp outputs exceed available rtmp urls")
|
||||||
|
break
|
||||||
|
}
|
||||||
pb := pool.NewBuffer(int(r.cfg.PoolStartElementSize), int(nElements), writeTimeout)
|
pb := pool.NewBuffer(int(r.cfg.PoolStartElementSize), int(nElements), writeTimeout)
|
||||||
w, err := newRtmpSender(r.cfg.RTMPURL, rtmpConnectionMaxTries, pb, r.cfg.Logger, r.bitrate.Report)
|
w, err := newRtmpSender(r.cfg.RTMPURL[rtmpUrlIdx], rtmpConnectionMaxTries, pb, r.cfg.Logger, r.bitrate.Report)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
r.cfg.Logger.Warning("rtmp connect error", "error", err.Error())
|
r.cfg.Logger.Warning("rtmp connect error", "error", err.Error())
|
||||||
}
|
}
|
||||||
|
rtmpUrlIdx++
|
||||||
flvSenders = append(flvSenders, w)
|
flvSenders = append(flvSenders, w)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -203,7 +203,7 @@ func TestResetEncoderSenderSetup(t *testing.T) {
|
||||||
for testNum, test := range tests {
|
for testNum, test := range tests {
|
||||||
// Create a new config and reset revid with it.
|
// Create a new config and reset revid with it.
|
||||||
const dummyURL = "rtmp://dummy"
|
const dummyURL = "rtmp://dummy"
|
||||||
c := config.Config{Logger: &testLogger{}, Outputs: test.outputs, RTMPURL: dummyURL}
|
c := config.Config{Logger: &testLogger{}, Outputs: test.outputs, RTMPURL: []string{dummyURL}}
|
||||||
err := rv.setConfig(c)
|
err := rv.setConfig(c)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unexpected error: %v for test %v", err, testNum)
|
t.Fatalf("unexpected error: %v for test %v", err, testNum)
|
||||||
|
|
Loading…
Reference in New Issue