implemented menu module module functionality in baresip.c
This commit is contained in:
@@ -140,11 +140,11 @@ module_app contact.so
|
|||||||
module_app debug_cmd.so
|
module_app debug_cmd.so
|
||||||
#module_app dtmfio.so
|
#module_app dtmfio.so
|
||||||
#module_app echo.so
|
#module_app echo.so
|
||||||
module_app menu.so
|
#module_app menu.so
|
||||||
#module_app mwi.so
|
#module_app mwi.so
|
||||||
#module_app natbd.so
|
#module_app natbd.so
|
||||||
#module_app presence.so
|
#module_app presence.so
|
||||||
module_app vidloop.so
|
#module_app vidloop.so
|
||||||
|
|
||||||
|
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -30,6 +30,8 @@ typedef struct update_context {
|
|||||||
|
|
||||||
UpdateContext g_ctx;
|
UpdateContext g_ctx;
|
||||||
|
|
||||||
|
struct play *play = NULL;
|
||||||
|
|
||||||
static int vprintf_null(const char *p, size_t size, void *arg)
|
static int vprintf_null(const char *p, size_t size, void *arg)
|
||||||
{
|
{
|
||||||
(void)p;
|
(void)p;
|
||||||
@@ -72,6 +74,17 @@ static const char *ua_event_reg_str(enum ua_event ev)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const char *translate_errorcode(uint16_t scode)
|
||||||
|
{
|
||||||
|
switch (scode) {
|
||||||
|
|
||||||
|
case 404: return "notfound.wav";
|
||||||
|
case 486: return "busy.wav";
|
||||||
|
case 487: return NULL; /* ignore */
|
||||||
|
default: return "error.wav";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void ua_event_handler(struct ua *ua, enum ua_event ev,
|
static void ua_event_handler(struct ua *ua, enum ua_event ev,
|
||||||
struct call *call, const char *prm, void *arg)
|
struct call *call, const char *prm, void *arg)
|
||||||
{
|
{
|
||||||
@@ -80,6 +93,8 @@ static void ua_event_handler(struct ua *ua, enum ua_event ev,
|
|||||||
char ua_buf[256];
|
char ua_buf[256];
|
||||||
char call_buf[256];
|
char call_buf[256];
|
||||||
|
|
||||||
|
struct player *player = baresip_player();
|
||||||
|
|
||||||
LOGD("ua event (%s) %s\n", uag_event_str(ev), prm);
|
LOGD("ua event (%s) %s\n", uag_event_str(ev), prm);
|
||||||
|
|
||||||
switch (ev) {
|
switch (ev) {
|
||||||
@@ -90,15 +105,26 @@ static void ua_event_handler(struct ua *ua, enum ua_event ev,
|
|||||||
re_snprintf(event_buf, sizeof event_buf, "%s", ua_event_reg_str(ev));
|
re_snprintf(event_buf, sizeof event_buf, "%s", ua_event_reg_str(ev));
|
||||||
break;
|
break;
|
||||||
case UA_EVENT_CALL_RINGING:
|
case UA_EVENT_CALL_RINGING:
|
||||||
|
play = mem_deref(play);
|
||||||
|
(void)play_file(&play, player, "ringback.wav", -1);
|
||||||
re_snprintf(event_buf, sizeof event_buf, "%s", "call ringing");
|
re_snprintf(event_buf, sizeof event_buf, "%s", "call ringing");
|
||||||
break;
|
break;
|
||||||
case UA_EVENT_CALL_PROGRESS:
|
case UA_EVENT_CALL_PROGRESS:
|
||||||
re_snprintf(event_buf, sizeof event_buf, "%s", "call progress");
|
re_snprintf(event_buf, sizeof event_buf, "%s", "call progress");
|
||||||
break;
|
break;
|
||||||
case UA_EVENT_CALL_ESTABLISHED:
|
case UA_EVENT_CALL_ESTABLISHED:
|
||||||
|
play = mem_deref(play);
|
||||||
re_snprintf(event_buf, sizeof event_buf, "%s", "call established");
|
re_snprintf(event_buf, sizeof event_buf, "%s", "call established");
|
||||||
break;
|
break;
|
||||||
case UA_EVENT_CALL_INCOMING:
|
case UA_EVENT_CALL_INCOMING:
|
||||||
|
uag_current_set(ua);
|
||||||
|
play = mem_deref(play);
|
||||||
|
if (list_count(ua_calls(ua)) > 1) {
|
||||||
|
(void)play_file(&play, player, "callwaiting.wav", 3);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
(void)play_file(&play, player, "ring.wav", -1);
|
||||||
|
}
|
||||||
re_snprintf(event_buf, sizeof event_buf, "%s", "call incoming");
|
re_snprintf(event_buf, sizeof event_buf, "%s", "call incoming");
|
||||||
break;
|
break;
|
||||||
case UA_EVENT_CALL_MENC:
|
case UA_EVENT_CALL_MENC:
|
||||||
@@ -110,6 +136,14 @@ static void ua_event_handler(struct ua *ua, enum ua_event ev,
|
|||||||
re_snprintf(event_buf, sizeof event_buf, "%s", "unknown menc event");
|
re_snprintf(event_buf, sizeof event_buf, "%s", "unknown menc event");
|
||||||
break;
|
break;
|
||||||
case UA_EVENT_CALL_CLOSED:
|
case UA_EVENT_CALL_CLOSED:
|
||||||
|
play = mem_deref(play);
|
||||||
|
if (call_scode(call)) {
|
||||||
|
const char *tone;
|
||||||
|
tone = translate_errorcode(call_scode(call));
|
||||||
|
if (tone) {
|
||||||
|
(void)play_file(&play, player, tone, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
re_snprintf(event_buf, sizeof event_buf, "%s", "call closed");
|
re_snprintf(event_buf, sizeof event_buf, "%s", "call closed");
|
||||||
break;
|
break;
|
||||||
case UA_EVENT_EXIT:
|
case UA_EVENT_EXIT:
|
||||||
|
|||||||
Reference in New Issue
Block a user