set properties to sink
This commit is contained in:
Vendored
+1
@@ -15,6 +15,7 @@
|
||||
"VIDEO_SRC_DEVICE": "/dev/video4",
|
||||
//"AUDIO_SRC_DEVICE": "plughw:4,0,0",
|
||||
"AUDIO_SRC": "pulsesrc",
|
||||
"AUDIO_SINK": "pulsesink",
|
||||
"INPUT_DEVICE": "/dev/input/event5",
|
||||
"JINGLE_PATH": "${workspaceFolder}/audio",
|
||||
"SONOS_TARGET": "Living Room",
|
||||
|
||||
+17
-16
@@ -49,29 +49,30 @@ type ConfigHTTP struct {
|
||||
}
|
||||
|
||||
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"`
|
||||
Source string `arg:"--video-src,env:VIDEO_SRC" default:"v4l2src"`
|
||||
Device string `arg:"--video-src-device,env:VIDEO_SRC_DEVICE" default:"/dev/video0"`
|
||||
Codec StreamCodec `arg:"--video-src-codec,env:VIDEO_SRC_CODEC" default:"vp8"`
|
||||
Height uint `arg:"--video-src-height,env:VIDEO_SRC_HEIGHT" default:"480"`
|
||||
Width uint `arg:"--video-src-width,env:VIDEO_SRC_WIDTH" default:"640"`
|
||||
Queue bool `arg:"--video-src-queue,env:VIDEO_SRC_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_NAME" 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"`
|
||||
DeviceName string `arg:"--audio-src-device-name,env:AUDIO_SRC_DEVICE_NAME" default:"default"`
|
||||
Device *string `arg:"--audio-src-device,env:AUDIO_SRC_DEVICE"`
|
||||
Codec StreamCodec `arg:"--audio-src-codec,env:AUDIO_SRC_CODEC" default:"opus"`
|
||||
Channels uint `arg:"--audio-src-channels,env:AUDIO_SRC_CHANNELS" default:"1"`
|
||||
Queue bool `arg:"--audio-src-queue,env:AUDIO_SRC_QUEUE" default:"false"`
|
||||
}
|
||||
|
||||
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"`
|
||||
Sink string `arg:"--audio-sink,env:AUDIO_SINK" default:"alsasink"`
|
||||
DeviceName string `arg:"--audio-sink-device-name,env:AUDIO_SINK_DEVICE_NAME" default:"default"`
|
||||
Device *string `arg:"--audio-sink-device,env:AUDIO_SINK_DEVICE"`
|
||||
Codec string `arg:"--audio-sink-codec,env:AUDIO_SINK_CODEC" default:"opus"`
|
||||
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 {
|
||||
|
||||
+18
-4
@@ -109,7 +109,7 @@ func (wh *WebrtcHandler) stopPipelines() {
|
||||
|
||||
func (wh *WebrtcHandler) handleAudioSamples(ctx context.Context, cfg *common.ConfigAudioSourceStream) error {
|
||||
properties := map[string]interface{}{}
|
||||
if cfg.Source == "alsasrc" {
|
||||
if cfg.Source == "alsasrc" || cfg.Source == "pulsesrc" {
|
||||
if cfg.Device != nil {
|
||||
properties["device"] = *cfg.Device
|
||||
} else {
|
||||
@@ -125,7 +125,7 @@ func (wh *WebrtcHandler) handleAudioSamples(ctx context.Context, cfg *common.Con
|
||||
Channels: cfg.Channels,
|
||||
Rate: 48000,
|
||||
},
|
||||
Queue: cfg.USE_QUEUE,
|
||||
Queue: cfg.Queue,
|
||||
Codec: cfg.Codec,
|
||||
}
|
||||
|
||||
@@ -170,7 +170,7 @@ func (wh *WebrtcHandler) handleVideoSamples(ctx context.Context, cfg *common.Con
|
||||
Width: cfg.Width,
|
||||
Height: cfg.Height,
|
||||
},
|
||||
Queue: cfg.USE_QUEUE,
|
||||
Queue: cfg.Queue,
|
||||
Codec: cfg.Codec,
|
||||
}
|
||||
|
||||
@@ -225,12 +225,22 @@ func (wh *WebrtcHandler) createPeerHandle(rctx context.Context, sh *server.Signa
|
||||
// for the given codec
|
||||
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))
|
||||
cfg := wh.cfg.AudioSink
|
||||
|
||||
if track.Codec().MimeType != "audio/opus" {
|
||||
wh.lg.Error("mimetype not supported", zap.String("mime", track.Codec().MimeType))
|
||||
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
|
||||
go func() {
|
||||
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{
|
||||
Kind: "autoaudiosink",
|
||||
Kind: cfg.Sink,
|
||||
Properties: map[string]interface{}{
|
||||
"device": cfg.Device,
|
||||
},
|
||||
Queue: cfg.Queue,
|
||||
})
|
||||
if err != nil {
|
||||
wh.lg.Error("failed to create src pipeline", zap.Error(err))
|
||||
|
||||
Reference in New Issue
Block a user