From de8a2c971397c585abea5bbc515cd77c2008ca81 Mon Sep 17 00:00:00 2001 From: Benny Prijono Date: Wed, 22 Jan 2014 08:02:56 +0000 Subject: More re #1655: added CLI command to toggle audio output route git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@4709 74dad513-b988-da41-8d7b-12977e46ad98 --- pjsip-apps/src/pjsua/pjsua_app_cli.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'pjsip-apps') diff --git a/pjsip-apps/src/pjsua/pjsua_app_cli.c b/pjsip-apps/src/pjsua/pjsua_app_cli.c index a7f8c4eb..e8639d3f 100644 --- a/pjsip-apps/src/pjsua/pjsua_app_cli.c +++ b/pjsip-apps/src/pjsua/pjsua_app_cli.c @@ -85,6 +85,7 @@ #define CMD_MEDIA_CONF_DISCONNECT ((CMD_MEDIA*10)+3) #define CMD_MEDIA_ADJUST_VOL ((CMD_MEDIA*10)+4) #define CMD_MEDIA_CODEC_PRIO ((CMD_MEDIA*10)+5) +#define CMD_MEDIA_SPEAKER_TOGGLE ((CMD_MEDIA*10)+6) /* status & config level 2 command */ #define CMD_CONFIG_DUMP_STAT ((CMD_CONFIG*10)+1) @@ -1342,6 +1343,31 @@ pj_status_t cmd_media_handler(pj_cli_cmd_val *cval) case CMD_MEDIA_CODEC_PRIO: status = cmd_set_codec_prio(cval); break; + case CMD_MEDIA_SPEAKER_TOGGLE: + { + static int route = PJMEDIA_AUD_DEV_ROUTE_DEFAULT; + status = pjsua_snd_get_setting(PJMEDIA_AUD_DEV_CAP_OUTPUT_ROUTE, + &route); + if (status != PJ_SUCCESS) { + PJ_PERROR(2, (THIS_FILE, status, + "Warning: unable to retrieve route setting")); + } + + if (route == PJMEDIA_AUD_DEV_ROUTE_LOUDSPEAKER) + route = PJMEDIA_AUD_DEV_ROUTE_DEFAULT; + else + route = PJMEDIA_AUD_DEV_ROUTE_LOUDSPEAKER; + + PJ_LOG(4,(THIS_FILE, "Setting output route to %s %s", + (route==PJMEDIA_AUD_DEV_ROUTE_DEFAULT? + "default" : "loudspeaker"), + (status? "anyway" : ""))); + + status = pjsua_snd_set_setting(PJMEDIA_AUD_DEV_CAP_OUTPUT_ROUTE, + &route, PJ_TRUE); + PJ_PERROR(4,(THIS_FILE, status, "Result")); + } + break; } return status; @@ -2830,6 +2856,7 @@ static pj_status_t add_media_command(pj_cli_t *cli) " " " " " " + " " " " " " -- cgit v1.2.3