Skip to content

Commit 50cfdff

Browse files
authored
Add func to enable whip proxy (#376)
1 parent 0cce7fd commit 50cfdff

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

cmd/server/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ func runService(_ context.Context, c *cli.Command) error {
158158
}
159159
}
160160
if whipsrv != nil {
161-
err = whipsrv.Start(conf, svc.HandleWHIPPublishRequest, svc.GetHealthHandlers())
161+
err = whipsrv.Start(conf, svc.HandleWHIPPublishRequest, nil, svc.GetHealthHandlers())
162162
if err != nil {
163163
return err
164164
}

pkg/whip/server.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ type WHIPServer struct {
6161

6262
handlersLock sync.Mutex
6363
handlers map[string]WHIPHandler
64+
65+
getWhipProxyEnabled func(ctx context.Context, streamKey string) bool
6466
}
6567

6668
type WHIPHandler interface {
@@ -93,6 +95,7 @@ func NewWHIPServer(bus psrpc.MessageBus) (*WHIPServer, error) {
9395
func (s *WHIPServer) Start(
9496
conf *config.Config,
9597
onPublish func(streamKey, resourceId string) (*params.Params, func(mimeTypes map[types.StreamKind]string, err error) *stats.LocalMediaStatsGatherer, func(error), error),
98+
getWhipProxyEnabled func(ctx context.Context, streamKey string) bool,
9699
healthHandlers HealthHandlers,
97100
) error {
98101
s.ctx, s.cancel = context.WithCancel(context.Background())
@@ -104,6 +107,7 @@ func (s *WHIPServer) Start(
104107
}
105108

106109
s.onPublish = onPublish
110+
s.getWhipProxyEnabled = getWhipProxyEnabled
107111
s.conf = conf
108112

109113
var err error
@@ -359,7 +363,8 @@ func (s *WHIPServer) createStream(streamKey string, sdpOffer string, ua string)
359363
}
360364

361365
var h WHIPHandler
362-
if *p.EnableTranscoding || !s.conf.SFUTranscodingBypassedWHIP {
366+
if *p.EnableTranscoding || (!s.conf.SFUTranscodingBypassedWHIP &&
367+
(s.getWhipProxyEnabled == nil || !s.getWhipProxyEnabled(ctx, streamKey))) {
363368
logger.Infow("Using native WHIP handler", "ingressID", p.IngressId, "resourceID", resourceId, "streamKey", streamKey)
364369

365370
var bus psrpc.MessageBus

0 commit comments

Comments
 (0)