mirror of https://bitbucket.org/ausocean/av.git
Merged in modify-vidforward-rtmp (pull request #497)
vidforward: modify viforward to accept multiple RTMP URLs Approved-by: Alan Noble
This commit is contained in:
commit
06a81a2b3b
|
@ -44,7 +44,7 @@ const fileName = "state.json"
|
|||
// marshal/unmarshal overriding.
|
||||
type BroadcastBasic struct {
|
||||
MAC
|
||||
URL string
|
||||
URLs []string
|
||||
Status string
|
||||
}
|
||||
|
||||
|
@ -60,7 +60,7 @@ type ManagerBasic struct {
|
|||
func (b Broadcast) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(BroadcastBasic{
|
||||
MAC: b.mac,
|
||||
URL: b.url,
|
||||
URLs: b.urls,
|
||||
Status: b.status,
|
||||
})
|
||||
}
|
||||
|
@ -75,10 +75,10 @@ func (b *Broadcast) UnmarshalJSON(data []byte) error {
|
|||
}
|
||||
|
||||
b.mac = bm.MAC
|
||||
b.url = bm.URL
|
||||
b.urls = bm.URLs
|
||||
b.status = bm.Status
|
||||
|
||||
b.rv, err = newRevid(global.GetLogger(), b.url)
|
||||
b.rv, err = newRevid(global.GetLogger(), b.urls)
|
||||
if err != nil {
|
||||
return fmt.Errorf("could not populate RV field: %w", err)
|
||||
}
|
||||
|
|
|
@ -58,11 +58,11 @@ func TestBroadcastMarshal(t *testing.T) {
|
|||
{
|
||||
in: Broadcast{
|
||||
mac: testMAC,
|
||||
url: testURL,
|
||||
urls: []string{testURL},
|
||||
status: statusActive,
|
||||
rv: newRevidForTest((*logging.TestLogger)(t), testURL, t),
|
||||
},
|
||||
expect: []byte("{\"MAC\":\"" + testMAC + "\",\"URL\":\"" + testURL + "\",\"Status\":\"" + statusActive + "\"}"),
|
||||
expect: []byte("{\"MAC\":\"" + testMAC + "\",\"URLs\":[\"" + testURL + "\"],\"Status\":\"" + statusActive + "\"}"),
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -91,11 +91,11 @@ func TestBroadcastUnmarshal(t *testing.T) {
|
|||
{
|
||||
expect: Broadcast{
|
||||
mac: testMAC,
|
||||
url: testURL,
|
||||
urls: []string{testURL},
|
||||
status: statusActive,
|
||||
rv: newRevidForTest(logger, testURL, t),
|
||||
},
|
||||
in: []byte("{\"MAC\":\"" + testMAC + "\",\"URL\":\"" + testURL + "\",\"Status\":\"" + statusActive + "\"}"),
|
||||
in: []byte("{\"MAC\":\"" + testMAC + "\",\"URLs\":[\"" + testURL + "\"],\"Status\":\"" + statusActive + "\"}"),
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -127,7 +127,7 @@ func TestBroadcastManagerMarshal(t *testing.T) {
|
|||
broadcasts: map[MAC]Broadcast{
|
||||
testMAC: Broadcast{
|
||||
testMAC,
|
||||
testURL,
|
||||
[]string{testURL},
|
||||
statusSlate,
|
||||
newRevidForTest((*logging.TestLogger)(t), testURL, t),
|
||||
},
|
||||
|
@ -136,7 +136,7 @@ func TestBroadcastManagerMarshal(t *testing.T) {
|
|||
log: logger,
|
||||
dogNotifier: newWatchdogNotifierForTest(t, logger),
|
||||
},
|
||||
expect: []byte("{\"Broadcasts\":{\"" + testMAC + "\":{\"MAC\":\"" + testMAC + "\",\"URL\":\"" + testURL + "\",\"Status\":\"" + statusSlate + "\"}},\"SlateExitSignals\":[\"" + testMAC + "\"]}"),
|
||||
expect: []byte("{\"Broadcasts\":{\"" + testMAC + "\":{\"MAC\":\"" + testMAC + "\",\"URLs\":[\"" + testURL + "\"],\"Status\":\"" + statusSlate + "\"}},\"SlateExitSignals\":[\"" + testMAC + "\"]}"),
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -163,12 +163,12 @@ func TestBroadcastManagerUnmarshal(t *testing.T) {
|
|||
expect broadcastManager
|
||||
}{
|
||||
{
|
||||
in: []byte("{\"Broadcasts\":{\"" + testMAC + "\":{\"MAC\":\"" + testMAC + "\",\"URL\":\"" + testURL + "\",\"Status\":\"" + statusSlate + "\"}},\"SlateExitSignals\":[\"" + testMAC + "\"]}"),
|
||||
in: []byte("{\"Broadcasts\":{\"" + testMAC + "\":{\"MAC\":\"" + testMAC + "\",\"URLs\":[\"" + testURL + "\"],\"Status\":\"" + statusSlate + "\"}},\"SlateExitSignals\":[\"" + testMAC + "\"]}"),
|
||||
expect: broadcastManager{
|
||||
broadcasts: map[MAC]Broadcast{
|
||||
testMAC: Broadcast{
|
||||
testMAC,
|
||||
testURL,
|
||||
[]string{testURL},
|
||||
statusSlate,
|
||||
newRevidForTest((*logging.TestLogger)(t), testURL, t),
|
||||
},
|
||||
|
@ -239,7 +239,7 @@ func watchdogNotifiersEqual(w1, w2 watchdogNotifier) bool {
|
|||
}
|
||||
|
||||
func broadcastsEqual(b1, b2 Broadcast) bool {
|
||||
if b1.mac != b2.mac || b1.url != b2.url || b1.status != b2.status ||
|
||||
if b1.mac != b2.mac || !reflect.DeepEqual(b1.urls, b2.urls) || b1.status != b2.status ||
|
||||
((b1.rv == nil || b2.rv == nil) && b1.rv != b2.rv) {
|
||||
return false
|
||||
}
|
||||
|
@ -268,7 +268,7 @@ func configsEqual(cfg1, cfg2 config.Config) bool {
|
|||
|
||||
// newRevidForTest allows us to create revid in table driven test entry.
|
||||
func newRevidForTest(log logging.Logger, url string, t *testing.T) *revid.Revid {
|
||||
r, err := newRevid(log, url)
|
||||
r, err := newRevid(log, []string{url})
|
||||
if err != nil {
|
||||
t.Fatalf("could not create revid pipeline: %v", err)
|
||||
return nil
|
||||
|
|
|
@ -80,7 +80,7 @@ const (
|
|||
// Broadcast is representative of a broadcast to be forwarded.
|
||||
type Broadcast struct {
|
||||
mac MAC // MAC address of the device from which the video is being received.
|
||||
url string // The destination youtube RTMP URL.
|
||||
urls []string // The destination youtube RTMP URLs.
|
||||
status string // The broadcast status i.e. active or slate.
|
||||
rv *revid.Revid // The revid pipeline which will handle forwarding to youtube.
|
||||
}
|
||||
|
@ -281,12 +281,17 @@ func (m *broadcastManager) createOrUpdate(broadcast Broadcast) error {
|
|||
m.mu.Lock()
|
||||
defer m.mu.Unlock()
|
||||
|
||||
var outputs []uint8
|
||||
for _ = range broadcast.urls {
|
||||
outputs = append(outputs, config.OutputRTMP)
|
||||
}
|
||||
|
||||
cfg := config.Config{
|
||||
Logger: m.log,
|
||||
Input: config.InputManual,
|
||||
InputCodec: codecutil.H264_AU,
|
||||
Outputs: []uint8{config.OutputRTMP},
|
||||
RTMPURL: broadcast.url,
|
||||
Outputs: outputs,
|
||||
RTMPURL: broadcast.urls,
|
||||
LogLevel: logging.Debug,
|
||||
}
|
||||
|
||||
|
|
|
@ -37,14 +37,14 @@ import (
|
|||
|
||||
var loggingLevel = logging.Info
|
||||
|
||||
func newRevid(log logging.Logger, url string) (*revid.Revid, error) {
|
||||
func newRevid(log logging.Logger, urls []string) (*revid.Revid, error) {
|
||||
return revid.New(
|
||||
config.Config{
|
||||
Logger: log,
|
||||
Input: config.InputManual,
|
||||
InputCodec: codecutil.H264_AU,
|
||||
Outputs: []uint8{config.OutputRTMP},
|
||||
RTMPURL: url,
|
||||
RTMPURL: urls,
|
||||
LogLevel: loggingLevel,
|
||||
}, nil)
|
||||
}
|
||||
|
|
1
go.mod
1
go.mod
|
@ -35,5 +35,4 @@ require (
|
|||
go.uber.org/multierr v1.1.0 // indirect
|
||||
go.uber.org/zap v1.10.0 // indirect
|
||||
golang.org/x/image v0.0.0-20210216034530-4410531fe030 // indirect
|
||||
golang.org/x/text v0.3.5 // indirect
|
||||
)
|
||||
|
|
11
go.sum
11
go.sum
|
@ -96,7 +96,6 @@ github.com/tarm/serial v0.0.0-20180830185346-98f6abe2eb07/go.mod h1:kDXzergiv9cb
|
|||
github.com/yobert/alsa v0.0.0-20180630182551-d38d89fa843e h1:3NIzz7weXhh3NToPgbtlQtKiVgerEaG4/nY2skGoGG0=
|
||||
github.com/yobert/alsa v0.0.0-20180630182551-d38d89fa843e/go.mod h1:CaowXBWOiSGWEpBBV8LoVnQTVPV4ycyviC9IBLj8dRw=
|
||||
github.com/yryz/ds18b20 v0.0.0-20180211073435-3cf383a40624/go.mod h1:MqFju5qeLDFh+S9PqxYT7TEla8xeW7bgGr/69q3oki0=
|
||||
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
|
||||
go.uber.org/atomic v1.3.2 h1:2Oa65PReHzfn29GpvgsYwloV9AVFHPDk8tYxt2c2tr4=
|
||||
go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
|
||||
go.uber.org/multierr v1.1.0 h1:HoEmRHQPVSqub6w2z2d2EOVs2fjyFRGyofhKuyDq0QI=
|
||||
|
@ -110,7 +109,6 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk
|
|||
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||
golang.org/x/exp v0.0.0-20180321215751-8460e604b9de/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||
golang.org/x/exp v0.0.0-20180807140117-3d87b88a115f/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||
golang.org/x/exp v0.0.0-20190125153040-c74c464bbbf2/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||
|
@ -129,14 +127,11 @@ golang.org/x/image v0.0.0-20210216034530-4410531fe030 h1:lP9pYkih3DUSC641giIXa2X
|
|||
golang.org/x/image v0.0.0-20210216034530-4410531fe030/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
|
||||
golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o=
|
||||
golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY=
|
||||
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
|
||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20200904194848-62affa334b73/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
|
||||
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
|
@ -146,22 +141,16 @@ golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7w
|
|||
golang.org/x/sys v0.0.0-20210304124612-50617c2ba197/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20210909193231-528a39cd75f3/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
||||
golang.org/x/text v0.6.0 h1:3XmdazWV+ubf7QgHSTWeykHOci5oeekaGJBLkrkaw4k=
|
||||
golang.org/x/text v0.6.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
||||
golang.org/x/tools v0.0.0-20180525024113-a5b4c53f6e8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20190206041539-40960b6deb8e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20190927191325-030b2cf1153e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
|
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
|
|
|
@ -233,7 +233,7 @@ type Config struct {
|
|||
PoolWriteTimeout uint // The pool buffer write timeout in seconds.
|
||||
RecPeriod float64 // How many seconds to record at a time.
|
||||
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 URLs. This must be defined if RTMP is to be used as an output.
|
||||
RTPAddress string // RTPAddress defines the RTP output destination.
|
||||
SampleRate uint // Samples a second (Hz).
|
||||
Saturation int
|
||||
|
|
Loading…
Reference in New Issue