summaryrefslogtreecommitdiff
path: root/pjsip
diff options
context:
space:
mode:
authorBenny Prijono <bennylp@teluu.com>2006-02-23 02:09:10 +0000
committerBenny Prijono <bennylp@teluu.com>2006-02-23 02:09:10 +0000
commit6d68baecdefbc8b90749dc7cff8def2a5a88af30 (patch)
tree6a83cbd3ae5c1246a443293b09606e658e211342 /pjsip
parent084ee2728e8ee98944c9b8525704d5937aafa3b3 (diff)
Added support for playing WAV file
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@222 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjsip')
-rw-r--r--pjsip/src/pjsua/main.c31
-rw-r--r--pjsip/src/pjsua/pjsua.h3
-rw-r--r--pjsip/src/pjsua/pjsua_core.c36
-rw-r--r--pjsip/src/pjsua/pjsua_opt.c9
4 files changed, 68 insertions, 11 deletions
diff --git a/pjsip/src/pjsua/main.c b/pjsip/src/pjsua/main.c
index 5508e069..5218c7cd 100644
--- a/pjsip/src/pjsua/main.c
+++ b/pjsip/src/pjsua/main.c
@@ -261,21 +261,34 @@ static void ui_input_url(const char *title, char *buf, int len,
static void conf_list(void)
{
- pjmedia_conf_port_info info;
- struct pjsua_inv_data *inv_data;
+ unsigned i, count;
+ pjmedia_conf_port_info info[16];
printf("Conference ports:\n");
- inv_data = pjsua.inv_list.next;
- while (inv_data != &pjsua.inv_list) {
+ count = PJ_ARRAY_SIZE(info);
+ pjmedia_conf_get_ports_info(pjsua.mconf, &count, info);
+ for (i=0; i<count; ++i) {
+ char txlist[80];
+ unsigned j;
+ pjmedia_conf_port_info *port_info = &info[i];
- pjmedia_conf_get_port_info(pjsua.mconf, inv_data->conf_slot, &info);
-
- printf("Port %2d %.*s\n", inv_data->conf_slot,
- (int)info.name.slen, info.name.ptr);
+ txlist[0] = '\0';
+ for (j=0; j<pjsua.max_ports; ++j) {
+ char s[10];
+ if (port_info->listener[j]) {
+ pj_sprintf(s, "#%d ", j);
+ pj_ansi_strcat(txlist, s);
+ }
+ }
+ printf("Port #%02d %20.*s tx to: %s\n",
+ port_info->slot,
+ (int)port_info->name.slen,
+ port_info->name.ptr,
+ txlist);
- inv_data = inv_data->next;
}
+ puts("");
}
diff --git a/pjsip/src/pjsua/pjsua.h b/pjsip/src/pjsua/pjsua.h
index e731b4e4..81927821 100644
--- a/pjsip/src/pjsua/pjsua.h
+++ b/pjsip/src/pjsua/pjsua.h
@@ -115,8 +115,11 @@ struct pjsua
/* Media: */
pjmedia_endpt *med_endpt; /**< Media endpoint. */
+ unsigned max_ports; /**< Max ports in conf. */
pjmedia_conf *mconf; /**< Media conference. */
pj_bool_t null_audio; /**< Null audio flag. */
+ char *wav_file; /**< WAV file name to play. */
+ unsigned wav_slot; /**< WAV player slot in bridge */
/* Since we support simultaneous calls, we need to have multiple
diff --git a/pjsip/src/pjsua/pjsua_core.c b/pjsip/src/pjsua/pjsua_core.c
index 77b6631a..56a29063 100644
--- a/pjsip/src/pjsua/pjsua_core.c
+++ b/pjsip/src/pjsua/pjsua_core.c
@@ -76,6 +76,10 @@ void pjsua_default(void)
pjsua.reg_timeout = 55;
+ /* Default maximum conference ports: */
+
+ pjsua.max_ports = 8;
+
/* Init route set list: */
pj_list_init(&pjsua.route_set);
@@ -517,7 +521,8 @@ pj_status_t pjsua_init(void)
/* Init conference bridge. */
- status = pjmedia_conf_create(pjsua.pool, 8, 8000, 160, 16, &pjsua.mconf);
+ status = pjmedia_conf_create(pjsua.pool, pjsua.max_ports,
+ 8000, 160, 16, &pjsua.mconf);
if (status != PJ_SUCCESS) {
pj_caching_pool_destroy(&pjsua.cp);
pjsua_perror(THIS_FILE,
@@ -554,6 +559,35 @@ pj_status_t pjsua_start(void)
pjsip_transport *udp_transport;
pj_status_t status = PJ_SUCCESS;
+ /* Create WAV file player if required: */
+
+ if (pjsua.wav_file) {
+ pjmedia_port *port;
+ pj_str_t port_name;
+
+ /* Create the file player port. */
+ status = pjmedia_file_player_port_create( pjsua.pool, pjsua.wav_file,
+ 0, -1, NULL, &port);
+ if (status != PJ_SUCCESS) {
+ pjsua_perror(THIS_FILE,
+ "Error playing media file",
+ status);
+ return status;
+ }
+
+ /* Add port to conference bridge: */
+ status = pjmedia_conf_add_port(pjsua.mconf, pjsua.pool, port,
+ pj_cstr(&port_name, pjsua.wav_file),
+ &pjsua.wav_slot);
+ if (status != PJ_SUCCESS) {
+ pjsua_perror(THIS_FILE,
+ "Unable to add file player to conference bridge",
+ status);
+ return status;
+ }
+ }
+
+
/* Init sockets (STUN etc): */
for (i=0; i<PJ_ARRAY_SIZE(pjsua.med_sock_info); ++i) {
status = init_sockets(i==0, &pjsua.med_sock_info[i]);
diff --git a/pjsip/src/pjsua/pjsua_opt.c b/pjsip/src/pjsua/pjsua_opt.c
index 5ec1a56a..d40f1de1 100644
--- a/pjsip/src/pjsua/pjsua_opt.c
+++ b/pjsip/src/pjsua/pjsua_opt.c
@@ -55,6 +55,8 @@ static void usage(void)
puts("");
puts("Media options:");
puts(" --null-audio Use NULL audio device");
+ puts(" --wav-file=file Play WAV file in conference bridge");
+ puts("");
//puts("");
//puts("User Agent options:");
//puts(" --auto-answer=sec Auto-answer all incoming calls after sec seconds.");
@@ -196,7 +198,7 @@ pj_status_t pjsua_parse_args(int argc, char *argv[])
OPT_REALM, OPT_USERNAME, OPT_PASSWORD,
OPT_USE_STUN1, OPT_USE_STUN2,
OPT_ADD_BUDDY, OPT_OFFER_X_MS_MSG, OPT_NO_PRESENCE,
- OPT_AUTO_ANSWER, OPT_AUTO_HANGUP};
+ OPT_AUTO_ANSWER, OPT_AUTO_HANGUP, OPT_WAV_FILE};
struct option long_options[] = {
{ "config-file",1, 0, OPT_CONFIG_FILE},
{ "log-file", 1, 0, OPT_LOG_FILE},
@@ -222,6 +224,7 @@ pj_status_t pjsua_parse_args(int argc, char *argv[])
{ "no-presence", 0, 0, OPT_NO_PRESENCE},
{ "auto-answer",1, 0, OPT_AUTO_ANSWER},
{ "auto-hangup",1, 0, OPT_AUTO_HANGUP},
+ { "wav-file", 1, 0, OPT_WAV_FILE},
{ NULL, 0, 0, 0}
};
pj_status_t status;
@@ -405,6 +408,10 @@ pj_status_t pjsua_parse_args(int argc, char *argv[])
}
pjsua.buddies[pjsua.buddy_cnt++].uri = pj_str(optarg);
break;
+
+ case OPT_WAV_FILE:
+ pjsua.wav_file = optarg;
+ break;
}
}