Skip to content

Commit

Permalink
ringtone -> dialtone
Browse files Browse the repository at this point in the history
  • Loading branch information
biglittlebigben committed Oct 22, 2024
1 parent 4c2195f commit 20d6d46
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion pkg/sip/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ func (c *Client) createSIPParticipant(ctx context.Context, req *rpc.InternalCrea
user: req.Username,
pass: req.Password,
dtmf: req.Dtmf,
ringtone: req.PlayRingtone,
dialtone: req.PlayDialtone,
headers: req.Headers,
headersToAttrs: req.HeadersToAttributes,
ringingTimeout: req.RingingTimeout.AsDuration(),
Expand Down
4 changes: 2 additions & 2 deletions pkg/sip/inbound.go
Original file line number Diff line number Diff line change
Expand Up @@ -773,10 +773,10 @@ func (c *inboundCall) handleDTMF(tone dtmf.Event) {
}
}

func (c *inboundCall) transferCall(ctx context.Context, transferTo string, ringtone bool) error {
func (c *inboundCall) transferCall(ctx context.Context, transferTo string, dialtone bool) error {
var err error

if ringtone && c.started.IsBroken() && !c.done.Load() {
if dialtone && c.started.IsBroken() && !c.done.Load() {
const ringVolume = math.MaxInt16 / 2
rctx, rcancel := context.WithCancel(ctx)
defer rcancel()
Expand Down
12 changes: 6 additions & 6 deletions pkg/sip/outbound.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ type sipOutboundConfig struct {
user string
pass string
dtmf string
ringtone bool
dialtone bool
headers map[string]string
headersToAttrs map[string]string
ringingTimeout time.Duration
Expand Down Expand Up @@ -248,7 +248,7 @@ func (c *outboundCall) connectToRoom(ctx context.Context, lkNew RoomConfig) erro
if err := r.Connect(c.c.conf, lkNew); err != nil {
return err
}
// We have to create the track early because we might play a ringtone while SIP connects.
// We have to create the track early because we might play a dialtone while SIP connects.
// Thus, we are forced to set full sample rate here instead of letting the codec adapt to the SIP source sample rate.
local, err := r.NewParticipantTrack(RoomSampleRate)
if err != nil {
Expand All @@ -261,12 +261,12 @@ func (c *outboundCall) connectToRoom(ctx context.Context, lkNew RoomConfig) erro
}

func (c *outboundCall) dialSIP(ctx context.Context) error {
if c.sipConf.ringtone {
if c.sipConf.dialtone {
const ringVolume = math.MaxInt16 / 2
rctx, rcancel := context.WithCancel(ctx)
defer rcancel()

// Play a ringtone to the room while participant connects
// Play dialtone to the room while participant connects
go func() {
rctx, span := tracer.Start(rctx, "tones.Play")
defer span.End()
Expand Down Expand Up @@ -432,10 +432,10 @@ func (c *outboundCall) handleDTMF(ev dtmf.Event) {
}, lksdk.WithDataPublishReliable(true))
}

func (c *outboundCall) transferCall(ctx context.Context, transferTo string, ringtone bool) error {
func (c *outboundCall) transferCall(ctx context.Context, transferTo string, dialtone bool) error {
var err error

if ringtone && c.started.IsBroken() && !c.stopped.IsBroken() {
if dialtone && c.started.IsBroken() && !c.stopped.IsBroken() {
const ringVolume = math.MaxInt16 / 2
rctx, rcancel := context.WithCancel(ctx)
defer rcancel()
Expand Down
8 changes: 4 additions & 4 deletions pkg/sip/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ func (s *Service) TransferSIPParticipant(ctx context.Context, req *rpc.InternalT
ctx, cdone := context.WithTimeout(context.WithoutCancel(ctx), 30*time.Second)
defer cdone()

err := s.processParticipantTransfer(ctx, req.SipCallId, req.TransferTo, req.PlayRingtone)
err := s.processParticipantTransfer(ctx, req.SipCallId, req.TransferTo, req.PlayDialtone)
transfetResult.Store(&err)
close(done)

Expand All @@ -177,14 +177,14 @@ func (s *Service) TransferSIPParticipant(ctx context.Context, req *rpc.InternalT
}
}

func (s *Service) processParticipantTransfer(ctx context.Context, callID string, transferTo string, ringtone bool) error {
func (s *Service) processParticipantTransfer(ctx context.Context, callID string, transferTo string, dialtone bool) error {
// Look for call both in client (outbound) and server (inbound)
s.cli.cmu.Lock()
out := s.cli.activeCalls[LocalTag(callID)]
s.cli.cmu.Unlock()

if out != nil {
err := out.transferCall(ctx, transferTo, ringtone)
err := out.transferCall(ctx, transferTo, dialtone)
if err != nil {
return err
}
Expand All @@ -197,7 +197,7 @@ func (s *Service) processParticipantTransfer(ctx context.Context, callID string,
s.srv.cmu.Unlock()

if in != nil {
err := in.transferCall(ctx, transferTo, ringtone)
err := in.transferCall(ctx, transferTo, dialtone)
if err != nil {
return err
}
Expand Down

0 comments on commit 20d6d46

Please sign in to comment.