| 42 | } |
| 43 | |
| 44 | func appStart(ctx context.Context) func(*ari.ChannelHandle, *ari.StasisStart) { |
| 45 | return func(h *ari.ChannelHandle, startEvent *ari.StasisStart) { |
| 46 | defer h.Hangup() |
| 47 | |
| 48 | log.Info("running app", "channel", h.Key().ID) |
| 49 | |
| 50 | if err := h.Answer(); err != nil { |
| 51 | log.Error("failed to answer call", "error", err) |
| 52 | // return |
| 53 | } |
| 54 | |
| 55 | res, err := record.Record(ctx, h, |
| 56 | record.TerminateOn("any"), |
| 57 | record.IfExists("overwrite"), |
| 58 | ).Result() |
| 59 | if err != nil { |
| 60 | log.Error("failed to record", "error", err) |
| 61 | return |
| 62 | } |
| 63 | |
| 64 | if err = res.Save("test-recording"); err != nil { |
| 65 | log.Error("failed to save recording", "error", err) |
| 66 | } |
| 67 | |
| 68 | log.Info("completed recording") |
| 69 | |
| 70 | h.Hangup() |
| 71 | } |
| 72 | } |