vendor update
This commit is contained in:
1 parent
1248b36a80
commit
c3f9a5ec61
1387 files changed
+230249
-84685
No files matched your search
+39
-33
@@ -8,18 +8,18 @@ import (
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
VideoOut ConfigVideoOutputStream `arg:"group:VideoOut"`
|
||||
AudioOut ConfigAudioOutputStream `arg:"group:AudioOut"`
|
||||
AudioIn ConfigAudioInputStream `arg:"group:AudioIn"`
|
||||
Logging ConfigLogging `arg:"group:Logging"`
|
||||
Ring ConfigRing `arg:"group:Ring"`
|
||||
Http ConfigHTTP `arg:"group:Http"`
|
||||
VideoSrc ConfigVideoSourceStream
|
||||
AudioSrc ConfigAudioSourceStream
|
||||
AudioSink ConfigAudioSinkStream
|
||||
Logging ConfigLogging
|
||||
Ring ConfigRing
|
||||
Http ConfigHTTP
|
||||
}
|
||||
|
||||
type ConfigStream struct {
|
||||
VideoOut ConfigVideoOutputStream
|
||||
AudioOut ConfigAudioOutputStream
|
||||
AudioIn ConfigAudioInputStream
|
||||
VideoSrc ConfigVideoSourceStream // video src for webrtc send
|
||||
AudioSrc ConfigAudioSourceStream // audio src for webrtc send
|
||||
AudioSink ConfigAudioSinkStream // audio sink for webrtc receive
|
||||
}
|
||||
|
||||
type ConfigLogging struct {
|
||||
@@ -34,6 +34,7 @@ type ConfigRing struct {
|
||||
SonosTarget string `arg:"--sonos-target,env:SONOS_TARGET" default:"-"`
|
||||
SonosVolume int `arg:"--sonos-volume,env:SONOS_VOLUME" default:"50"`
|
||||
HomeassistantWebhook *string `arg:"--ha-webhook,env:HA_WEBHOOK"`
|
||||
NoIPv6 bool `arg:"--disable-ipv6,env:NO_IPV6" default:"false"`
|
||||
}
|
||||
|
||||
type ConfigHTTP struct {
|
||||
@@ -47,37 +48,37 @@ type ConfigHTTP struct {
|
||||
StaticPath *string `arg:"--http-static,env:HTTP_STATIC"`
|
||||
}
|
||||
|
||||
type ConfigVideoOutputStream struct {
|
||||
Source string `arg:"--video-out-src,env:VIDEO_OUT_SRC" default:"v4l2src"`
|
||||
Device string `arg:"--video-out-device,env:VIDEO_OUT_DEVICE" default:"/dev/video0"`
|
||||
Codec StreamCodec `arg:"--video-out-codec,env:VIDEO_OUT_CODEC" default:"vp8"`
|
||||
Height uint `arg:"--video-out-height,env:VIDEO_OUT_HEIGHT" default:"480"`
|
||||
Width uint `arg:"--video-out-width,env:VIDEO_OUT_WIDTH" default:"640"`
|
||||
USE_QUEUE bool `arg:"--video-out-queue,env:VIDEO_OUT_QUEUE" default:"false"`
|
||||
type ConfigVideoSourceStream struct {
|
||||
Source string `arg:"--video-src,env:VIDEO_SRC" default:"v4l2src"`
|
||||
Device string `arg:"--video-device,env:VIDEO_SRC_DEVICE" default:"/dev/video0"`
|
||||
Codec StreamCodec `arg:"--video-codec,env:VIDEO_SRC_CODEC" default:"vp8"`
|
||||
Height uint `arg:"--video-height,env:VIDEO_SRC_HEIGHT" default:"480"`
|
||||
Width uint `arg:"--video-width,env:VIDEO_SRC_WIDTH" default:"640"`
|
||||
USE_QUEUE bool `arg:"--video-queue,env:VIDEO_SRC_QUEUE" default:"false"`
|
||||
}
|
||||
|
||||
type ConfigAudioOutputStream struct {
|
||||
Source string `arg:"--audio-out-src,env:AUDIO_OUT_SRC" default:"alsasrc"`
|
||||
DeviceName string `arg:"--audio-out-device-name,env:AUDIO_OUT_DEVICE" default:"default"`
|
||||
Device *string `arg:"--audio-out-device,env:AUDIO_OUT_DEVICE"`
|
||||
Codec StreamCodec `arg:"--audio-out-codec,env:AUDIO_OUT_CODEC" default:"opus"`
|
||||
Channels uint `arg:"--audio-out-channels,env:AUDIO_OUT_CHANNELS" default:"1"`
|
||||
USE_QUEUE bool `arg:"--audio-out-queue,env:AUDIO_OUT_QUEUE" default:"false"`
|
||||
type ConfigAudioSourceStream struct {
|
||||
Source string `arg:"--audio-src,env:AUDIO_SRC" default:"alsasrc"`
|
||||
DeviceName string `arg:"--audio-device-name,env:AUDIO_SRC_DEVICE" default:"default"`
|
||||
Device *string `arg:"--audio-device,env:AUDIO_SRC_DEVICE"`
|
||||
Codec StreamCodec `arg:"--audio-codec,env:AUDIO_SRC_CODEC" default:"opus"`
|
||||
Channels uint `arg:"--audio-channels,env:AUDIO_SRC_CHANNELS" default:"1"`
|
||||
USE_QUEUE bool `arg:"--audio-queue,env:AUDIO_SRC_QUEUE" default:"false"`
|
||||
}
|
||||
|
||||
type ConfigAudioInputStream struct {
|
||||
Sink string `arg:"--audio-in-src,env:AUDIO_IN_SINK" default:"alsasink"`
|
||||
DeviceName string `arg:"--audio-in-device-name,env:AUDIO_IN_DEVICE" default:"default"`
|
||||
Device *string `arg:"--audio-in-device,env:AUDIO_IN_DEVICE"`
|
||||
Codec string `arg:"--audio-in-codec,env:AUDIO_IN_CODEC" default:"opus"`
|
||||
Channels uint `arg:"--audio-in-channels,env:AUDIO_IN_CHANNELS" default:"1"`
|
||||
type ConfigAudioSinkStream struct {
|
||||
Sink string `arg:"--audio-in-src,env:AUDIO_SINK" default:"alsasink"`
|
||||
DeviceName string `arg:"--audio-in-device-name,env:AUDIO_SINK_DEVICE_NAME" default:"default"`
|
||||
Device *string `arg:"--audio-in-device,env:AUDIO_SINK_DEVICE"`
|
||||
Codec string `arg:"--audio-in-codec,env:AUDIO_SINK_CODEC" default:"opus"`
|
||||
Channels uint `arg:"--audio-in-channels,env:AUDIO_SINK_CHANNELS" default:"1"`
|
||||
}
|
||||
|
||||
func (c *Config) Stream() *ConfigStream {
|
||||
return &ConfigStream{
|
||||
VideoOut: c.VideoOut,
|
||||
AudioOut: c.AudioOut,
|
||||
AudioIn: c.AudioIn,
|
||||
VideoSrc: c.VideoSrc,
|
||||
AudioSrc: c.AudioSrc,
|
||||
AudioSink: c.AudioSink,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,5 +87,10 @@ func (c *ConfigHTTP) Address() string {
|
||||
}
|
||||
|
||||
func (c *Config) MustParse() {
|
||||
arg.MustParse(c)
|
||||
arg.MustParse(&c.VideoSrc)
|
||||
arg.MustParse(&c.AudioSrc)
|
||||
arg.MustParse(&c.AudioSink)
|
||||
arg.MustParse(&c.Logging)
|
||||
arg.MustParse(&c.Http)
|
||||
arg.MustParse(&c.Ring)
|
||||
}
|
||||
@@ -177,8 +177,15 @@ func (h *SonosHandler) Watch(ctx context.Context) error {
|
||||
}
|
||||
}()
|
||||
|
||||
params := mdns.DefaultParams("_sonos._tcp")
|
||||
params.Entries = entriesCh
|
||||
|
||||
if h.cfg.NoIPv6 {
|
||||
params.DisableIPv6 = true
|
||||
}
|
||||
|
||||
// Start the lookup
|
||||
return mdns.Lookup("_sonos._tcp", entriesCh)
|
||||
return mdns.Query(params)
|
||||
}
|
||||
|
||||
func (h *SonosHandler) Play(uri *url.URL) error {
|
||||
|
||||
@@ -3,10 +3,10 @@ package streamer
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/go-gst/go-gst/gst"
|
||||
"github.com/go-gst/go-gst/gst/app"
|
||||
"github.com/kaedwen/webrtc/pkg/common"
|
||||
"github.com/pion/webrtc/v3/pkg/media"
|
||||
"github.com/tinyzimmer/go-gst/gst"
|
||||
"github.com/tinyzimmer/go-gst/gst/app"
|
||||
)
|
||||
|
||||
func setCallback(sink *app.Sink, ch chan media.Sample) {
|
||||
@@ -30,7 +30,7 @@ func setCallback(sink *app.Sink, ch chan media.Sample) {
|
||||
data := buffer.Map(gst.MapRead).AsUint8Slice()
|
||||
defer buffer.Unmap()
|
||||
|
||||
ch <- media.Sample{Data: data, Duration: buffer.Duration()}
|
||||
ch <- media.Sample{Data: data, Duration: *buffer.Duration().AsDuration()}
|
||||
|
||||
return gst.FlowOK
|
||||
},
|
||||
|
||||
+29
-35
@@ -3,8 +3,8 @@ package streamer
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/tinyzimmer/go-gst/gst"
|
||||
"github.com/tinyzimmer/go-gst/gst/app"
|
||||
"github.com/go-gst/go-gst/gst"
|
||||
"github.com/go-gst/go-gst/gst/app"
|
||||
)
|
||||
|
||||
type SrcPipeline struct {
|
||||
@@ -12,6 +12,13 @@ type SrcPipeline struct {
|
||||
src *app.Source
|
||||
}
|
||||
|
||||
func NewSrcPipeline(p *gst.Pipeline, src *app.Source) *SrcPipeline {
|
||||
return &SrcPipeline{
|
||||
Pipeline: p,
|
||||
src: src,
|
||||
}
|
||||
}
|
||||
|
||||
func CreateAudioPipelineSrc(dst StreamElement) (*SrcPipeline, error) {
|
||||
// Create a pipeline
|
||||
pipeline, err := gst.NewPipeline("")
|
||||
@@ -19,54 +26,41 @@ func CreateAudioPipelineSrc(dst StreamElement) (*SrcPipeline, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
elems := make([]*gst.Element, 0)
|
||||
|
||||
// Create the src
|
||||
appsrc, err := app.NewAppSrc()
|
||||
elems, err := gst.NewElementMany("appsrc", "rtpjitterbuffer", "rtpopusdepay", "opusdec", dst.Kind)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
elems = append(elems, appsrc.Element)
|
||||
|
||||
caps := gst.NewEmptySimpleCaps("application/x-rtp")
|
||||
caps.SetValue("media", "audio")
|
||||
caps.SetValue("clock-rate", 48000)
|
||||
caps.SetValue("payload", 96)
|
||||
caps.SetValue("encoding-name", "OPUS")
|
||||
|
||||
appsrc := app.SrcFromElement(elems[0])
|
||||
appsrc.SetFormat(gst.FormatTime)
|
||||
appsrc.SetDoTimestamp(true)
|
||||
appsrc.SetLive(true)
|
||||
|
||||
// Create the opus decoder
|
||||
decCodec, err := gst.NewElement("rtpopusdepay")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
elems = append(elems, decCodec)
|
||||
|
||||
// Create the bin decoder
|
||||
decBin, err := gst.NewElement("decodebin")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
elems = append(elems, decBin)
|
||||
appsrc.SetCaps(caps)
|
||||
|
||||
// Create the sink
|
||||
sink, err := gst.NewElement(dst.Kind)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
elems = append(elems, sink)
|
||||
sink := elems[len(elems)-1]
|
||||
|
||||
for name, value := range dst.Properties {
|
||||
sink.SetProperty(name, value)
|
||||
}
|
||||
|
||||
// Add the elements to the pipeline
|
||||
pipeline.AddMany(elems...)
|
||||
// Add the elements to the pipeline and link them
|
||||
err = pipeline.AddMany(elems...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
err = gst.ElementLinkMany(elems...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// link the elements
|
||||
gst.ElementLinkMany(elems...)
|
||||
|
||||
return &SrcPipeline{
|
||||
Pipeline: pipeline,
|
||||
src: appsrc,
|
||||
}, nil
|
||||
return NewSrcPipeline(pipeline, appsrc), nil
|
||||
}
|
||||
|
||||
func (p *SrcPipeline) Push(data []byte) error {
|
||||
|
||||
+3
-4
@@ -4,11 +4,10 @@ import (
|
||||
"fmt"
|
||||
"reflect"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/go-gst/go-gst/gst"
|
||||
"github.com/go-gst/go-gst/gst/app"
|
||||
"github.com/kaedwen/webrtc/pkg/common"
|
||||
"github.com/tinyzimmer/go-gst/gst"
|
||||
"github.com/tinyzimmer/go-gst/gst/app"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
@@ -79,7 +78,7 @@ func LoopBus(lg *zap.Logger, pipeline *gst.Pipeline) {
|
||||
// Loop over messsages from the pipeline
|
||||
go func() {
|
||||
for {
|
||||
msg := bus.TimedPop(time.Duration(-1))
|
||||
msg := bus.TimedPop(gst.ClockTimeNone)
|
||||
if msg == nil {
|
||||
return
|
||||
}
|
||||
|
||||
+17
-10
@@ -7,13 +7,13 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/go-gst/go-gst/gst"
|
||||
"github.com/kaedwen/webrtc/pkg/common"
|
||||
"github.com/kaedwen/webrtc/pkg/server"
|
||||
"github.com/kaedwen/webrtc/pkg/streamer"
|
||||
"github.com/pion/rtcp"
|
||||
"github.com/pion/webrtc/v3"
|
||||
"github.com/pion/webrtc/v3/pkg/media"
|
||||
"github.com/tinyzimmer/go-gst/gst"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
@@ -41,12 +41,12 @@ func NewWebrtcHandler(ctx context.Context, lg *zap.Logger, cfg *common.ConfigStr
|
||||
peerHandles: make(map[string]*PeerHandle, 0),
|
||||
}
|
||||
|
||||
err := wh.handleAudioSamples(ctx, &cfg.AudioOut)
|
||||
err := wh.handleAudioSamples(ctx, &cfg.AudioSrc)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = wh.handleVideoSamples(ctx, &cfg.VideoOut)
|
||||
err = wh.handleVideoSamples(ctx, &cfg.VideoSrc)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -74,7 +74,7 @@ func NewWebrtcHandler(ctx context.Context, lg *zap.Logger, cfg *common.ConfigStr
|
||||
|
||||
func (wh *WebrtcHandler) startPipelines() {
|
||||
|
||||
if wh.audioPipeline.GetState() != gst.StatePlaying {
|
||||
if wh.audioPipeline.GetCurrentState() != gst.StatePlaying {
|
||||
err := wh.audioPipeline.SetState(gst.StatePlaying)
|
||||
if err != nil {
|
||||
wh.lg.Fatal("failed to start audio pipeline", zap.Error(err))
|
||||
@@ -82,7 +82,7 @@ func (wh *WebrtcHandler) startPipelines() {
|
||||
wh.lg.Info("started audio pipeline")
|
||||
}
|
||||
|
||||
if wh.videoPipeline.GetState() != gst.StatePlaying {
|
||||
if wh.videoPipeline.GetCurrentState() != gst.StatePlaying {
|
||||
err := wh.videoPipeline.SetState(gst.StatePlaying)
|
||||
if err != nil {
|
||||
wh.lg.Fatal("failed to start video pipeline", zap.Error(err))
|
||||
@@ -107,7 +107,7 @@ func (wh *WebrtcHandler) stopPipelines() {
|
||||
|
||||
}
|
||||
|
||||
func (wh *WebrtcHandler) handleAudioSamples(ctx context.Context, cfg *common.ConfigAudioOutputStream) error {
|
||||
func (wh *WebrtcHandler) handleAudioSamples(ctx context.Context, cfg *common.ConfigAudioSourceStream) error {
|
||||
properties := map[string]interface{}{}
|
||||
if cfg.Source == "alsasrc" {
|
||||
if cfg.Device != nil {
|
||||
@@ -158,7 +158,7 @@ func (wh *WebrtcHandler) handleAudioSamples(ctx context.Context, cfg *common.Con
|
||||
return nil
|
||||
}
|
||||
|
||||
func (wh *WebrtcHandler) handleVideoSamples(ctx context.Context, cfg *common.ConfigVideoOutputStream) error {
|
||||
func (wh *WebrtcHandler) handleVideoSamples(ctx context.Context, cfg *common.ConfigVideoSourceStream) error {
|
||||
src := streamer.StreamElement{
|
||||
Kind: cfg.Source,
|
||||
Properties: map[string]interface{}{
|
||||
@@ -234,6 +234,8 @@ func (wh *WebrtcHandler) createPeerHandle(rctx context.Context, sh *server.Signa
|
||||
// Send a PLI on an interval so that the publisher is pushing a keyframe every rtcpPLIInterval
|
||||
go func() {
|
||||
ticker := time.NewTicker(time.Second * 3)
|
||||
defer ticker.Stop()
|
||||
|
||||
for {
|
||||
select {
|
||||
case <-ticker.C:
|
||||
@@ -258,7 +260,12 @@ func (wh *WebrtcHandler) createPeerHandle(rctx context.Context, sh *server.Signa
|
||||
return
|
||||
}
|
||||
|
||||
pipeline.Start()
|
||||
err = pipeline.Start()
|
||||
if err != nil {
|
||||
wh.lg.Error("failed to start pipeline", zap.Error(err))
|
||||
return
|
||||
}
|
||||
|
||||
buf := make([]byte, 1400)
|
||||
for {
|
||||
n, _, readErr := track.Read(buf)
|
||||
@@ -303,7 +310,7 @@ func (wh *WebrtcHandler) createPeerHandle(rctx context.Context, sh *server.Signa
|
||||
})
|
||||
|
||||
// Create a audio track
|
||||
audioTrack, err := webrtc.NewTrackLocalStaticSample(webrtc.RTPCodecCapability{MimeType: wh.cfg.AudioOut.Codec.Mime()}, "audio", "pion1")
|
||||
audioTrack, err := webrtc.NewTrackLocalStaticSample(webrtc.RTPCodecCapability{MimeType: wh.cfg.AudioSrc.Codec.Mime()}, "audio", "pion1")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -313,7 +320,7 @@ func (wh *WebrtcHandler) createPeerHandle(rctx context.Context, sh *server.Signa
|
||||
}
|
||||
|
||||
// Create a video track
|
||||
videoTrack, err := webrtc.NewTrackLocalStaticSample(webrtc.RTPCodecCapability{MimeType: wh.cfg.VideoOut.Codec.Mime()}, "video", "pion2")
|
||||
videoTrack, err := webrtc.NewTrackLocalStaticSample(webrtc.RTPCodecCapability{MimeType: wh.cfg.VideoSrc.Codec.Mime()}, "video", "pion2")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user