Browse Source

Pipeline API is now optional and disabled by default.

release-0.25
Simon Eisenmann 9 years ago
parent
commit
597d06d764
  1. 4
      go/channelling/api/api.go
  2. 14
      go/channelling/pipeline_manager.go
  3. 2
      server.conf.in
  4. 13
      src/app/spreed-webrtc-server/main.go

4
go/channelling/api/api.go

@ -148,7 +148,9 @@ func (api *channellingAPI) OnIncoming(sender channelling.Sender, session *channe @@ -148,7 +148,9 @@ func (api *channellingAPI) OnIncoming(sender channelling.Sender, session *channe
api.BusManager.Trigger(channelling.BusManagerBye, session.Id, msg.Bye.To, nil, pipeline)
session.Unicast(msg.Bye.To, msg.Bye, pipeline)
pipeline.Close()
if pipeline != nil {
pipeline.Close()
}
case "Status":
if msg.Status == nil {
log.Println("Received invalid status message.", msg)

14
go/channelling/pipeline_manager.go

@ -54,6 +54,7 @@ type pipelineManager struct { @@ -54,6 +54,7 @@ type pipelineManager struct {
sessionSinkTable map[string]Sink
duration time.Duration
defaultSinkID string
enabled bool
}
func NewPipelineManager(busManager BusManager, sessionStore SessionStore, userStore UserStore, sessionCreator SessionCreator) PipelineManager {
@ -68,12 +69,17 @@ func NewPipelineManager(busManager BusManager, sessionStore SessionStore, userSt @@ -68,12 +69,17 @@ func NewPipelineManager(busManager BusManager, sessionStore SessionStore, userSt
sessionSinkTable: make(map[string]Sink),
duration: 60 * time.Second,
}
return plm
}
func (plm *pipelineManager) Start() {
plm.enabled = true
plm.start()
plm.Subscribe("channelling.session.create", plm.sessionCreate)
plm.Subscribe("channelling.session.close", plm.sessionClose)
return plm
}
func (plm *pipelineManager) cleanup() {
@ -185,6 +191,10 @@ func (plm *pipelineManager) PipelineID(namespace string, sender Sender, session @@ -185,6 +191,10 @@ func (plm *pipelineManager) PipelineID(namespace string, sender Sender, session
}
func (plm *pipelineManager) GetPipeline(namespace string, sender Sender, session *Session, to string) *Pipeline {
if !plm.enabled {
return nil
}
id := plm.PipelineID(namespace, sender, session, to)
plm.mutex.Lock()

2
server.conf.in

@ -88,6 +88,8 @@ encryptionSecret = tne-default-encryption-block-key @@ -88,6 +88,8 @@ encryptionSecret = tne-default-encryption-block-key
; Whether a user account is required to create a room. This only has an effect
; if user accounts are enabled. Optional, defaults to false.
;authorizeRoomCreation = false
; Wether the pipelines API should be enabled. Optional, defaults to false.
;pipelinesEnabled = false
; Server token is a public random string which is used to enhance security of
; server generated security tokens. When the serverToken is changed all existing
; nonces become invalid. Use 32 or 64 characters (eg. 16 or 32 byte hex).

13
src/app/spreed-webrtc-server/main.go

@ -80,11 +80,6 @@ func runner(runtime phoenix.Runtime) error { @@ -80,11 +80,6 @@ func runner(runtime phoenix.Runtime) error {
statsEnabled = false
}
pipelinesEnabled, err := runtime.GetBool("http", "pipelines")
if err != nil {
pipelinesEnabled = false
}
pprofListen, err := runtime.GetString("http", "pprofListen")
if err == nil && pprofListen != "" {
log.Printf("Starting pprof HTTP server on %s", pprofListen)
@ -93,6 +88,11 @@ func runner(runtime phoenix.Runtime) error { @@ -93,6 +88,11 @@ func runner(runtime phoenix.Runtime) error {
}()
}
pipelinesEnabled, err := runtime.GetBool("app", "pipelinesEnabled")
if err != nil {
pipelinesEnabled = false
}
var sessionSecret []byte
sessionSecretString, err := runtime.GetString("app", "sessionSecret")
if err != nil {
@ -313,8 +313,9 @@ func runner(runtime phoenix.Runtime) error { @@ -313,8 +313,9 @@ func runner(runtime phoenix.Runtime) error {
log.Println("Stats are enabled!")
}
if pipelinesEnabled {
pipelineManager.Start()
rest.AddResource(&server.Pipelines{pipelineManager, channellingAPI}, "/pipelines/{id}")
log.Println("Pipelines are enabled!")
log.Println("Pipelines RESTful API is enabled!")
}
// Add extra/static support if configured and exists.

Loading…
Cancel
Save