set properties to sink
This commit is contained in:
1 parent
d1f553e852
commit
6887efd093
3 files changed
+36
-20
No files matched your search
Vendored
+1
@@ -15,6 +15,7 @@
|
|||||||
"VIDEO_SRC_DEVICE": "/dev/video4",
|
"VIDEO_SRC_DEVICE": "/dev/video4",
|
||||||
//"AUDIO_SRC_DEVICE": "plughw:4,0,0",
|
//"AUDIO_SRC_DEVICE": "plughw:4,0,0",
|
||||||
"AUDIO_SRC": "pulsesrc",
|
"AUDIO_SRC": "pulsesrc",
|
||||||
|
"AUDIO_SINK": "pulsesink",
|
||||||
"INPUT_DEVICE": "/dev/input/event5",
|
"INPUT_DEVICE": "/dev/input/event5",
|
||||||
"JINGLE_PATH": "${workspaceFolder}/audio",
|
"JINGLE_PATH": "${workspaceFolder}/audio",
|
||||||
"SONOS_TARGET": "Living Room",
|
"SONOS_TARGET": "Living Room",
|
||||||
|
|||||||
+17
-16
@@ -49,29 +49,30 @@ type ConfigHTTP struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type ConfigVideoSourceStream struct {
|
type ConfigVideoSourceStream struct {
|
||||||
Source string `arg:"--video-src,env:VIDEO_SRC" default:"v4l2src"`
|
Source string `arg:"--video-src,env:VIDEO_SRC" default:"v4l2src"`
|
||||||
Device string `arg:"--video-device,env:VIDEO_SRC_DEVICE" default:"/dev/video0"`
|
Device string `arg:"--video-src-device,env:VIDEO_SRC_DEVICE" default:"/dev/video0"`
|
||||||
Codec StreamCodec `arg:"--video-codec,env:VIDEO_SRC_CODEC" default:"vp8"`
|
Codec StreamCodec `arg:"--video-src-codec,env:VIDEO_SRC_CODEC" default:"vp8"`
|
||||||
Height uint `arg:"--video-height,env:VIDEO_SRC_HEIGHT" default:"480"`
|
Height uint `arg:"--video-src-height,env:VIDEO_SRC_HEIGHT" default:"480"`
|
||||||
Width uint `arg:"--video-width,env:VIDEO_SRC_WIDTH" default:"640"`
|
Width uint `arg:"--video-src-width,env:VIDEO_SRC_WIDTH" default:"640"`
|
||||||
USE_QUEUE bool `arg:"--video-queue,env:VIDEO_SRC_QUEUE" default:"false"`
|
Queue bool `arg:"--video-src-queue,env:VIDEO_SRC_QUEUE" default:"false"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ConfigAudioSourceStream struct {
|
type ConfigAudioSourceStream struct {
|
||||||
Source string `arg:"--audio-src,env:AUDIO_SRC" default:"alsasrc"`
|
Source string `arg:"--audio-src,env:AUDIO_SRC" default:"alsasrc"`
|
||||||
DeviceName string `arg:"--audio-device-name,env:AUDIO_SRC_DEVICE_NAME" default:"default"`
|
DeviceName string `arg:"--audio-src-device-name,env:AUDIO_SRC_DEVICE_NAME" default:"default"`
|
||||||
Device *string `arg:"--audio-device,env:AUDIO_SRC_DEVICE"`
|
Device *string `arg:"--audio-src-device,env:AUDIO_SRC_DEVICE"`
|
||||||
Codec StreamCodec `arg:"--audio-codec,env:AUDIO_SRC_CODEC" default:"opus"`
|
Codec StreamCodec `arg:"--audio-src-codec,env:AUDIO_SRC_CODEC" default:"opus"`
|
||||||
Channels uint `arg:"--audio-channels,env:AUDIO_SRC_CHANNELS" default:"1"`
|
Channels uint `arg:"--audio-src-channels,env:AUDIO_SRC_CHANNELS" default:"1"`
|
||||||
USE_QUEUE bool `arg:"--audio-queue,env:AUDIO_SRC_QUEUE" default:"false"`
|
Queue bool `arg:"--audio-src-queue,env:AUDIO_SRC_QUEUE" default:"false"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ConfigAudioSinkStream struct {
|
type ConfigAudioSinkStream struct {
|
||||||
Sink string `arg:"--audio-in-src,env:AUDIO_SINK" default:"alsasink"`
|
Sink string `arg:"--audio-sink,env:AUDIO_SINK" default:"alsasink"`
|
||||||
DeviceName string `arg:"--audio-in-device-name,env:AUDIO_SINK_DEVICE_NAME" default:"default"`
|
DeviceName string `arg:"--audio-sink-device-name,env:AUDIO_SINK_DEVICE_NAME" default:"default"`
|
||||||
Device *string `arg:"--audio-in-device,env:AUDIO_SINK_DEVICE"`
|
Device *string `arg:"--audio-sink-device,env:AUDIO_SINK_DEVICE"`
|
||||||
Codec string `arg:"--audio-in-codec,env:AUDIO_SINK_CODEC" default:"opus"`
|
Codec string `arg:"--audio-sink-codec,env:AUDIO_SINK_CODEC" default:"opus"`
|
||||||
Channels uint `arg:"--audio-in-channels,env:AUDIO_SINK_CHANNELS" default:"1"`
|
Channels uint `arg:"--audio-sink-channels,env:AUDIO_SINK_CHANNELS" default:"1"`
|
||||||
|
Queue bool `arg:"--audio-sink-queue,env:AUDIO_SINK_QUEUE" default:"false"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Config) Stream() *ConfigStream {
|
func (c *Config) Stream() *ConfigStream {
|
||||||
|
|||||||
+18
-4
@@ -109,7 +109,7 @@ func (wh *WebrtcHandler) stopPipelines() {
|
|||||||
|
|
||||||
func (wh *WebrtcHandler) handleAudioSamples(ctx context.Context, cfg *common.ConfigAudioSourceStream) error {
|
func (wh *WebrtcHandler) handleAudioSamples(ctx context.Context, cfg *common.ConfigAudioSourceStream) error {
|
||||||
properties := map[string]interface{}{}
|
properties := map[string]interface{}{}
|
||||||
if cfg.Source == "alsasrc" {
|
if cfg.Source == "alsasrc" || cfg.Source == "pulsesrc" {
|
||||||
if cfg.Device != nil {
|
if cfg.Device != nil {
|
||||||
properties["device"] = *cfg.Device
|
properties["device"] = *cfg.Device
|
||||||
} else {
|
} else {
|
||||||
@@ -125,7 +125,7 @@ func (wh *WebrtcHandler) handleAudioSamples(ctx context.Context, cfg *common.Con
|
|||||||
Channels: cfg.Channels,
|
Channels: cfg.Channels,
|
||||||
Rate: 48000,
|
Rate: 48000,
|
||||||
},
|
},
|
||||||
Queue: cfg.USE_QUEUE,
|
Queue: cfg.Queue,
|
||||||
Codec: cfg.Codec,
|
Codec: cfg.Codec,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -170,7 +170,7 @@ func (wh *WebrtcHandler) handleVideoSamples(ctx context.Context, cfg *common.Con
|
|||||||
Width: cfg.Width,
|
Width: cfg.Width,
|
||||||
Height: cfg.Height,
|
Height: cfg.Height,
|
||||||
},
|
},
|
||||||
Queue: cfg.USE_QUEUE,
|
Queue: cfg.Queue,
|
||||||
Codec: cfg.Codec,
|
Codec: cfg.Codec,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -225,12 +225,22 @@ func (wh *WebrtcHandler) createPeerHandle(rctx context.Context, sh *server.Signa
|
|||||||
// for the given codec
|
// for the given codec
|
||||||
peerConnection.OnTrack(func(track *webrtc.TrackRemote, receiver *webrtc.RTPReceiver) {
|
peerConnection.OnTrack(func(track *webrtc.TrackRemote, receiver *webrtc.RTPReceiver) {
|
||||||
wh.lg.Info("received track", zap.String("kind", track.Kind().String()), zap.String("codec", track.Codec().MimeType))
|
wh.lg.Info("received track", zap.String("kind", track.Kind().String()), zap.String("codec", track.Codec().MimeType))
|
||||||
|
cfg := wh.cfg.AudioSink
|
||||||
|
|
||||||
if track.Codec().MimeType != "audio/opus" {
|
if track.Codec().MimeType != "audio/opus" {
|
||||||
wh.lg.Error("mimetype not supported", zap.String("mime", track.Codec().MimeType))
|
wh.lg.Error("mimetype not supported", zap.String("mime", track.Codec().MimeType))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
properties := map[string]interface{}{}
|
||||||
|
if cfg.Sink == "alsasink" || cfg.Sink == "pulsesink" {
|
||||||
|
if cfg.Device != nil {
|
||||||
|
properties["device"] = *cfg.Device
|
||||||
|
} else {
|
||||||
|
properties["device"] = cfg.DeviceName
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Send a PLI on an interval so that the publisher is pushing a keyframe every rtcpPLIInterval
|
// Send a PLI on an interval so that the publisher is pushing a keyframe every rtcpPLIInterval
|
||||||
go func() {
|
go func() {
|
||||||
ticker := time.NewTicker(time.Second * 3)
|
ticker := time.NewTicker(time.Second * 3)
|
||||||
@@ -253,7 +263,11 @@ func (wh *WebrtcHandler) createPeerHandle(rctx context.Context, sh *server.Signa
|
|||||||
}()
|
}()
|
||||||
|
|
||||||
pipeline, err := streamer.CreateAudioPipelineSrc(streamer.StreamElement{
|
pipeline, err := streamer.CreateAudioPipelineSrc(streamer.StreamElement{
|
||||||
Kind: "autoaudiosink",
|
Kind: cfg.Sink,
|
||||||
|
Properties: map[string]interface{}{
|
||||||
|
"device": cfg.Device,
|
||||||
|
},
|
||||||
|
Queue: cfg.Queue,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
wh.lg.Error("failed to create src pipeline", zap.Error(err))
|
wh.lg.Error("failed to create src pipeline", zap.Error(err))
|
||||||
|
|||||||
Reference in new issue
Block a user