mirror of
https://github.com/m1k1o/neko.git
synced 2024-07-24 14:40:50 +12:00
Merge pull request #9 from m1k1o/broadcast
Custom Broadcast Pipeline + stereo
This commit is contained in:
commit
030e695e4f
@ -20,6 +20,7 @@ func init() {
|
|||||||
neko.Service.Server,
|
neko.Service.Server,
|
||||||
neko.Service.WebRTC,
|
neko.Service.WebRTC,
|
||||||
neko.Service.Remote,
|
neko.Service.Remote,
|
||||||
|
neko.Service.Broadcast,
|
||||||
neko.Service.WebSocket,
|
neko.Service.WebSocket,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,14 +12,16 @@ type BroadcastManager struct {
|
|||||||
logger zerolog.Logger
|
logger zerolog.Logger
|
||||||
pipeline *gst.Pipeline
|
pipeline *gst.Pipeline
|
||||||
remote *config.Remote
|
remote *config.Remote
|
||||||
|
config *config.Broadcast
|
||||||
enabled bool
|
enabled bool
|
||||||
url string
|
url string
|
||||||
}
|
}
|
||||||
|
|
||||||
func New(remote *config.Remote) *BroadcastManager {
|
func New(remote *config.Remote, config *config.Broadcast) *BroadcastManager {
|
||||||
return &BroadcastManager{
|
return &BroadcastManager{
|
||||||
logger: log.With().Str("module", "remote").Logger(),
|
logger: log.With().Str("module", "remote").Logger(),
|
||||||
remote: remote,
|
remote: remote,
|
||||||
|
config: config,
|
||||||
enabled: false,
|
enabled: false,
|
||||||
url: "",
|
url: "",
|
||||||
}
|
}
|
||||||
@ -34,6 +36,7 @@ func (manager *BroadcastManager) Start() {
|
|||||||
manager.pipeline, err = gst.CreateRTMPPipeline(
|
manager.pipeline, err = gst.CreateRTMPPipeline(
|
||||||
manager.remote.Device,
|
manager.remote.Device,
|
||||||
manager.remote.Display,
|
manager.remote.Display,
|
||||||
|
manager.config.Pipeline,
|
||||||
manager.url,
|
manager.url,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ const (
|
|||||||
audioClockRate = 48000
|
audioClockRate = 48000
|
||||||
pcmClockRate = 8000
|
pcmClockRate = 8000
|
||||||
videoSrc = "ximagesrc xid=%s show-pointer=true use-damage=false ! video/x-raw ! videoconvert ! queue ! "
|
videoSrc = "ximagesrc xid=%s show-pointer=true use-damage=false ! video/x-raw ! videoconvert ! queue ! "
|
||||||
audioSrc = "pulsesrc device=%s ! audioconvert ! "
|
audioSrc = "pulsesrc device=%s ! audio/x-raw,channels=2 ! audioconvert ! "
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
@ -65,11 +65,18 @@ func init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// CreateRTMPPipeline creates a GStreamer Pipeline
|
// CreateRTMPPipeline creates a GStreamer Pipeline
|
||||||
func CreateRTMPPipeline(pipelineDevice string, pipelineDisplay string, pipelineRTMP string) (*Pipeline, error) {
|
func CreateRTMPPipeline(pipelineDevice string, pipelineDisplay string, pipelineSrc string, pipelineRTMP string) (*Pipeline, error) {
|
||||||
video := fmt.Sprintf(videoSrc, pipelineDisplay)
|
video := fmt.Sprintf(videoSrc, pipelineDisplay)
|
||||||
audio := fmt.Sprintf(audioSrc, pipelineDevice)
|
audio := fmt.Sprintf(audioSrc, pipelineDevice)
|
||||||
|
|
||||||
return CreatePipeline(fmt.Sprintf("flvmux name=mux ! rtmpsink location='%s live=1' %s voaacenc ! mux. %s x264enc bframes=0 key-int-max=60 byte-stream=true tune=zerolatency speed-preset=veryfast ! mux.", pipelineRTMP, audio, video), "", 0)
|
var pipelineStr string
|
||||||
|
if pipelineSrc != "" {
|
||||||
|
pipelineStr = fmt.Sprintf(pipelineSrc, pipelineRTMP, pipelineDevice, pipelineDisplay)
|
||||||
|
} else {
|
||||||
|
pipelineStr = fmt.Sprintf("flvmux name=mux ! rtmpsink location='%s live=1' %s audio/x-raw,channels=2 ! audioconvert ! voaacenc ! mux. %s x264enc bframes=0 key-int-max=60 byte-stream=true tune=zerolatency speed-preset=veryfast ! mux.", pipelineRTMP, audio, video)
|
||||||
|
}
|
||||||
|
|
||||||
|
return CreatePipeline(pipelineStr, "", 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreateAppPipeline creates a GStreamer Pipeline
|
// CreateAppPipeline creates a GStreamer Pipeline
|
||||||
|
23
server/internal/types/config/broadcast.go
Normal file
23
server/internal/types/config/broadcast.go
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
package config
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
"github.com/spf13/viper"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Broadcast struct {
|
||||||
|
Pipeline string
|
||||||
|
}
|
||||||
|
|
||||||
|
func (Broadcast) Init(cmd *cobra.Command) error {
|
||||||
|
cmd.PersistentFlags().String("broadcast_pipeline", "", "audio codec parameters to use for broadcasting")
|
||||||
|
if err := viper.BindPFlag("broadcast_pipeline", cmd.PersistentFlags().Lookup("broadcast_pipeline")); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *Broadcast) Set() {
|
||||||
|
s.Pipeline = viper.GetString("broadcast_pipeline")
|
||||||
|
}
|
@ -62,6 +62,7 @@ func init() {
|
|||||||
Root: &config.Root{},
|
Root: &config.Root{},
|
||||||
Server: &config.Server{},
|
Server: &config.Server{},
|
||||||
Remote: &config.Remote{},
|
Remote: &config.Remote{},
|
||||||
|
Broadcast: &config.Broadcast{},
|
||||||
WebRTC: &config.WebRTC{},
|
WebRTC: &config.WebRTC{},
|
||||||
WebSocket: &config.WebSocket{},
|
WebSocket: &config.WebSocket{},
|
||||||
}
|
}
|
||||||
@ -100,6 +101,7 @@ type Neko struct {
|
|||||||
Version *Version
|
Version *Version
|
||||||
Root *config.Root
|
Root *config.Root
|
||||||
Remote *config.Remote
|
Remote *config.Remote
|
||||||
|
Broadcast *config.Broadcast
|
||||||
Server *config.Server
|
Server *config.Server
|
||||||
WebRTC *config.WebRTC
|
WebRTC *config.WebRTC
|
||||||
WebSocket *config.WebSocket
|
WebSocket *config.WebSocket
|
||||||
@ -118,7 +120,7 @@ func (neko *Neko) Preflight() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (neko *Neko) Start() {
|
func (neko *Neko) Start() {
|
||||||
broadcastManager := broadcast.New(neko.Remote)
|
broadcastManager := broadcast.New(neko.Remote, neko.Broadcast)
|
||||||
|
|
||||||
remoteManager := remote.New(neko.Remote, broadcastManager)
|
remoteManager := remote.New(neko.Remote, broadcastManager)
|
||||||
remoteManager.Start()
|
remoteManager.Start()
|
||||||
|
Loading…
Reference in New Issue
Block a user