summaryrefslogtreecommitdiff
path: root/pjsip-apps/src
diff options
context:
space:
mode:
authorBenny Prijono <bennylp@teluu.com>2009-03-12 18:11:37 +0000
committerBenny Prijono <bennylp@teluu.com>2009-03-12 18:11:37 +0000
commit1dacdee696b7591a6dcc0b3c1d0f41573e473168 (patch)
tree302b09dcd989c0c05cf09f6aebaa63d870b421b9 /pjsip-apps/src
parentba9d8ca28eb209571c0bd6a080a8bb03d0fa2d33 (diff)
(Major) Task #737 and #738: integration of APS-Direct and Audiodev from aps-direct branch to trunk.
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@2506 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjsip-apps/src')
-rw-r--r--pjsip-apps/src/pjsua/pjsua_app.c9
-rw-r--r--pjsip-apps/src/samples/auddemo.c544
-rw-r--r--pjsip-apps/src/samples/debug.c2
-rw-r--r--pjsip-apps/src/samples/sndinfo.c295
-rw-r--r--pjsip-apps/src/samples/sndtest.c621
-rw-r--r--pjsip-apps/src/symbian_ua/main_symbian.cpp2
-rw-r--r--pjsip-apps/src/symbian_ua/ua.cpp281
-rw-r--r--pjsip-apps/src/symbian_ua_gui/group/symbian_ua_gui.mmp7
-rw-r--r--pjsip-apps/src/symsndtest/app_main.cpp110
-rw-r--r--pjsip-apps/src/symsndtest/main_symbian.cpp88
10 files changed, 831 insertions, 1128 deletions
diff --git a/pjsip-apps/src/pjsua/pjsua_app.c b/pjsip-apps/src/pjsua/pjsua_app.c
index e7f3390e..5944043f 100644
--- a/pjsip-apps/src/pjsua/pjsua_app.c
+++ b/pjsip-apps/src/pjsua/pjsua_app.c
@@ -4158,6 +4158,12 @@ pj_status_t app_init(int argc, char *argv[])
app_config.cfg.cb.on_call_replaced = &on_call_replaced;
app_config.cfg.cb.on_nat_detect = &on_nat_detect;
+ /* Set sound device latency */
+ if (app_config.capture_lat > 0)
+ app_config.media_cfg.snd_rec_latency = app_config.capture_lat;
+ if (app_config.playback_lat)
+ app_config.media_cfg.snd_play_latency = app_config.playback_lat;
+
/* Initialize pjsua */
status = pjsua_init(&app_config.cfg, &app_config.log_cfg,
&app_config.media_cfg);
@@ -4423,9 +4429,6 @@ pj_status_t app_init(int argc, char *argv[])
if (status != PJ_SUCCESS)
goto on_error;
- /* Set sound device latency */
- pjmedia_snd_set_latency(app_config.capture_lat, app_config.playback_lat);
-
/* Use null sound device? */
#ifndef STEREO_DEMO
if (app_config.null_audio) {
diff --git a/pjsip-apps/src/samples/auddemo.c b/pjsip-apps/src/samples/auddemo.c
new file mode 100644
index 00000000..e805f176
--- /dev/null
+++ b/pjsip-apps/src/samples/auddemo.c
@@ -0,0 +1,544 @@
+/* $Id$ */
+/*
+ * Copyright (C) 2008-2009 Teluu Inc. (http://www.teluu.com)
+ * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+#include <pjmedia-audiodev/audiodev.h>
+#include <pjmedia-audiodev/audiotest.h>
+#include <pjmedia.h>
+#include <pjlib.h>
+#include <pjlib-util.h>
+
+#define THIS_FILE "auddemo.c"
+#define MAX_DEVICES 64
+#define WAV_FILE "auddemo.wav"
+
+
+static unsigned dev_count;
+
+static void app_perror(const char *title, pj_status_t status)
+{
+ char errmsg[PJ_ERR_MSG_SIZE];
+
+ pj_strerror(status, errmsg, sizeof(errmsg));
+ printf( "%s: %s (err=%d)\n",
+ title, errmsg, status);
+}
+
+static void list_devices(void)
+{
+ unsigned i;
+ pj_status_t status;
+
+ dev_count = pjmedia_aud_dev_count();
+ if (dev_count == 0) {
+ PJ_LOG(3,(THIS_FILE, "No devices found"));
+ return;
+ }
+
+ PJ_LOG(3,(THIS_FILE, "Found %d devices:", dev_count));
+
+ for (i=0; i<dev_count; ++i) {
+ pjmedia_aud_dev_info info;
+
+ status = pjmedia_aud_dev_get_info(i, &info);
+ if (status != PJ_SUCCESS)
+ continue;
+
+ PJ_LOG(3,(THIS_FILE," %2d: %s [%s] (%d/%d)",
+ i, info.driver, info.name, info.input_count, info.output_count));
+ }
+}
+
+static const char *decode_caps(unsigned caps)
+{
+ static char text[200];
+ unsigned i;
+
+ text[0] = '\0';
+
+ for (i=0; i<31; ++i) {
+ if ((1 << i) & caps) {
+ const char *capname;
+ capname = pjmedia_aud_dev_cap_name((pjmedia_aud_dev_cap)(1 << i),
+ NULL);
+ strcat(text, capname);
+ strcat(text, " ");
+ }
+ }
+
+ return text;
+}
+
+static void show_dev_info(unsigned index)
+{
+#define H "%-20s"
+ pjmedia_aud_dev_info info;
+ char formats[200];
+ pj_status_t status;
+
+ if (index >= dev_count) {
+ PJ_LOG(1,(THIS_FILE, "Error: invalid index %u", index));
+ return;
+ }
+
+ status = pjmedia_aud_dev_get_info(index, &info);
+ if (status != PJ_SUCCESS) {
+ app_perror("pjmedia_aud_dev_get_info() error", status);
+ return;
+ }
+
+ PJ_LOG(3, (THIS_FILE, "Device at index %u:", index));
+ PJ_LOG(3, (THIS_FILE, "-------------------------"));
+
+ PJ_LOG(3, (THIS_FILE, H": %u (0x%x)", "ID", index, index));
+ PJ_LOG(3, (THIS_FILE, H": %s", "Name", info.name));
+ PJ_LOG(3, (THIS_FILE, H": %s", "Driver", info.driver));
+ PJ_LOG(3, (THIS_FILE, H": %u", "Input channels", info.input_count));
+ PJ_LOG(3, (THIS_FILE, H": %u", "Output channels", info.output_count));
+ PJ_LOG(3, (THIS_FILE, H": %s", "Capabilities", decode_caps(info.caps)));
+
+ formats[0] = '\0';
+ if (info.caps & PJMEDIA_AUD_DEV_CAP_EXT_FORMAT) {
+ unsigned i;
+
+ for (i=0; i<info.ext_fmt_cnt; ++i) {
+ char bitrate[32];
+
+ switch (info.ext_fmt[i].id) {
+ case PJMEDIA_FORMAT_L16:
+ strcat(formats, "L16/");
+ break;
+ case PJMEDIA_FORMAT_PCMA:
+ strcat(formats, "PCMA/");
+ break;
+ case PJMEDIA_FORMAT_PCMU:
+ strcat(formats, "PCMU/");
+ break;
+ case PJMEDIA_FORMAT_AMR:
+ strcat(formats, "AMR/");
+ break;
+ case PJMEDIA_FORMAT_G729:
+ strcat(formats, "G729/");
+ break;
+ case PJMEDIA_FORMAT_ILBC:
+ strcat(formats, "ILBC/");
+ break;
+ default:
+ strcat(formats, "unknown/");
+ break;
+ }
+ sprintf(bitrate, "%u", info.ext_fmt[i].bitrate);
+ strcat(formats, bitrate);
+ strcat(formats, " ");
+ }
+ }
+ PJ_LOG(3, (THIS_FILE, H": %s", "Extended formats", formats));
+
+#undef H
+}
+
+static void test_device(pjmedia_dir dir, unsigned rec_id, unsigned play_id,
+ unsigned clock_rate, unsigned ptime,
+ unsigned chnum)
+{
+ pjmedia_aud_param param;
+ pjmedia_aud_test_results result;
+ pj_status_t status;
+
+ if (dir & PJMEDIA_DIR_CAPTURE) {
+ status = pjmedia_aud_dev_default_param(rec_id, &param);
+ } else {
+ status = pjmedia_aud_dev_default_param(play_id, &param);
+ }
+
+ if (status != PJ_SUCCESS) {
+ app_perror("pjmedia_aud_dev_default_param()", status);
+ return;
+ }
+
+ param.dir = dir;
+ param.rec_id = rec_id;
+ param.play_id = play_id;
+ param.clock_rate = clock_rate;
+ param.channel_count = chnum;
+ param.samples_per_frame = clock_rate * chnum * ptime / 1000;
+
+ PJ_LOG(3,(THIS_FILE, "Performing test.."));
+
+ status = pjmedia_aud_test(&param, &result);
+ if (status != PJ_SUCCESS) {
+ app_perror("Test has completed with error", status);
+ return;
+ }
+
+ PJ_LOG(3,(THIS_FILE, "Done. Result:"));
+
+ if (dir & PJMEDIA_DIR_CAPTURE) {
+ if (result.rec.frame_cnt==0) {
+ PJ_LOG(1,(THIS_FILE, "Error: no frames captured!"));
+ } else {
+ PJ_LOG(3,(THIS_FILE, " %-20s: interval (min/max/avg/dev)=%u/%u/%u/%u, burst=%u",
+ "Recording result",
+ result.rec.min_interval,
+ result.rec.max_interval,
+ result.rec.avg_interval,
+ result.rec.dev_interval,
+ result.rec.max_burst));
+ }
+ }
+
+ if (dir & PJMEDIA_DIR_PLAYBACK) {
+ if (result.play.frame_cnt==0) {
+ PJ_LOG(1,(THIS_FILE, "Error: no playback!"));
+ } else {
+ PJ_LOG(3,(THIS_FILE, " %-20s: interval (min/max/avg/dev)=%u/%u/%u/%u, burst=%u",
+ "Playback result",
+ result.play.min_interval,
+ result.play.max_interval,
+ result.play.avg_interval,
+ result.play.dev_interval,
+ result.play.max_burst));
+ }
+ }
+
+ if (dir==PJMEDIA_DIR_CAPTURE_PLAYBACK) {
+ if (result.rec_drift_per_sec == 0) {
+ PJ_LOG(3,(THIS_FILE, " No clock drift detected"));
+ } else {
+ const char *which = result.rec_drift_per_sec>=0 ? "faster" : "slower";
+ unsigned drift = result.rec_drift_per_sec>=0 ?
+ result.rec_drift_per_sec :
+ -result.rec_drift_per_sec;
+
+ PJ_LOG(3,(THIS_FILE, " Clock drifts detected. Capture device "
+ "is running %d samples per second %s "
+ "than the playback device",
+ drift, which));
+ }
+ }
+}
+
+
+static pj_status_t wav_rec_cb(void *user_data, pjmedia_frame *frame)
+{
+ return pjmedia_port_put_frame((pjmedia_port*)user_data, frame);
+}
+
+static void record(unsigned rec_index, const char *filename)
+{
+ pj_pool_t *pool = NULL;
+ pjmedia_port *wav = NULL;
+ pjmedia_aud_param param;
+ pjmedia_aud_stream *strm = NULL;
+ char line[10];
+ pj_status_t status;
+
+ if (filename == NULL)
+ filename = WAV_FILE;
+
+ pool = pj_pool_create(pjmedia_aud_subsys_get_pool_factory(), "wav",
+ 1000, 1000, NULL);
+
+ status = pjmedia_wav_writer_port_create(pool, filename, 16000,
+ 1, 320, 16, 0, 0, &wav);
+ if (status != PJ_SUCCESS) {
+ app_perror("Error creating WAV file", status);
+ goto on_return;
+ }
+
+ status = pjmedia_aud_dev_default_param(rec_index, &param);
+ if (status != PJ_SUCCESS) {
+ app_perror("pjmedia_aud_dev_default_param()", status);
+ goto on_return;
+ }
+
+ param.dir = PJMEDIA_DIR_CAPTURE;
+ param.clock_rate = wav->info.clock_rate;
+ param.samples_per_frame = wav->info.samples_per_frame;
+ param.channel_count = wav->info.channel_count;
+ param.bits_per_sample = wav->info.bits_per_sample;
+
+ status = pjmedia_aud_stream_create(&param, &wav_rec_cb, NULL, wav,
+ &strm);
+ if (status != PJ_SUCCESS) {
+ app_perror("Error opening the sound device", status);
+ goto on_return;
+ }
+
+ status = pjmedia_aud_stream_start(strm);
+ if (status != PJ_SUCCESS) {
+ app_perror("Error starting the sound device", status);
+ goto on_return;
+ }
+
+ PJ_LOG(3,(THIS_FILE, "Recording started, press ENTER to stop"));
+ fgets(line, sizeof(line), stdin);
+
+on_return:
+ if (strm) {
+ pjmedia_aud_stream_stop(strm);
+ pjmedia_aud_stream_destroy(strm);
+ }
+ if (wav)
+ pjmedia_port_destroy(wav);
+ if (pool)
+ pj_pool_release(pool);
+}
+
+
+static pj_status_t wav_play_cb(void *user_data, pjmedia_frame *frame)
+{
+ return pjmedia_port_get_frame((pjmedia_port*)user_data, frame);
+}
+
+
+static void play_file(unsigned play_index, const char *filename)
+{
+ pj_pool_t *pool = NULL;
+ pjmedia_port *wav = NULL;
+ pjmedia_aud_param param;
+ pjmedia_aud_stream *strm = NULL;
+ char line[10];
+ pj_status_t status;
+
+ if (filename == NULL)
+ filename = WAV_FILE;
+
+ pool = pj_pool_create(pjmedia_aud_subsys_get_pool_factory(), "wav",
+ 1000, 1000, NULL);
+
+ status = pjmedia_wav_player_port_create(pool, filename, 20, 0, 0, &wav);
+ if (status != PJ_SUCCESS) {
+ app_perror("Error opening WAV file", status);
+ goto on_return;
+ }
+
+ status = pjmedia_aud_dev_default_param(play_index, &param);
+ if (status != PJ_SUCCESS) {
+ app_perror("pjmedia_aud_dev_default_param()", status);
+ goto on_return;
+ }
+
+ param.dir = PJMEDIA_DIR_PLAYBACK;
+ param.clock_rate = wav->info.clock_rate;
+ param.samples_per_frame = wav->info.samples_per_frame;
+ param.channel_count = wav->info.channel_count;
+ param.bits_per_sample = wav->info.bits_per_sample;
+
+ status = pjmedia_aud_stream_create(&param, NULL, &wav_play_cb, wav,
+ &strm);
+ if (status != PJ_SUCCESS) {
+ app_perror("Error opening the sound device", status);
+ goto on_return;
+ }
+
+ status = pjmedia_aud_stream_start(strm);
+ if (status != PJ_SUCCESS) {
+ app_perror("Error starting the sound device", status);
+ goto on_return;
+ }
+
+ PJ_LOG(3,(THIS_FILE, "Playback started, press ENTER to stop"));
+ fgets(line, sizeof(line), stdin);
+
+on_return:
+ if (strm) {
+ pjmedia_aud_stream_stop(strm);
+ pjmedia_aud_stream_destroy(strm);
+ }
+ if (wav)
+ pjmedia_port_destroy(wav);
+ if (pool)
+ pj_pool_release(pool);
+}
+
+
+static void print_menu(void)
+{
+ puts("");
+ puts("Audio demo menu:");
+ puts("-------------------------------");
+ puts(" l List devices");
+ puts(" i ID Show device info for device ID");
+ puts(" t RID PID CR PTIM [CH] Perform test on the device:");
+ puts(" RID: record device ID (-1 for no)");
+ puts(" PID: playback device ID (-1 for no)");
+ puts(" CR: clock rate");
+ puts(" PTIM: ptime in ms");
+ puts(" CH: # of channels");
+ puts(" r RID [FILE] Record capture device RID to WAV file");
+ puts(" p PID [FILE] Playback WAV file to device ID PID");
+ puts(" v Toggle log verbosity");
+ puts(" q Quit");
+ puts("");
+ printf("Enter selection: ");
+ fflush(stdout);
+}
+
+int main()
+{
+ pj_caching_pool cp;
+ pj_bool_t done = PJ_FALSE;
+ pj_status_t status;
+
+ /* Init pjlib */
+ status = pj_init();
+ PJ_ASSERT_RETURN(status==PJ_SUCCESS, 1);
+
+ pj_log_set_decor(PJ_LOG_HAS_NEWLINE | PJ_LOG_HAS_COLOR);
+
+ /* Must create a pool factory before we can allocate any memory. */
+ pj_caching_pool_init(&cp, &pj_pool_factory_default_policy, 0);
+
+ status = pjmedia_aud_subsys_init(&cp.factory);
+ if (status != PJ_SUCCESS) {
+ app_perror("pjmedia_aud_subsys_init()", status);
+ pj_caching_pool_destroy(&cp);
+ pj_shutdown();
+ return 1;
+ }
+
+ list_devices();
+
+ while (!done) {
+ char line[80];
+
+ print_menu();
+
+ if (fgets(line, sizeof(line), stdin)==NULL)
+ break;
+
+ switch (line[0]) {
+ case 'l':
+ list_devices();
+ break;
+
+ case 'i':
+ {
+ unsigned dev_index;
+ if (sscanf(line+2, "%u", &dev_index) != 1) {
+ puts("error: device ID required");
+ break;
+ }
+ show_dev_info(dev_index);
+ }
+ break;
+
+ case 't':
+ {
+ pjmedia_dir dir;
+ int rec_id, play_id;
+ unsigned clock_rate, ptime, chnum;
+ int cnt;
+
+ cnt = sscanf(line+2, "%d %d %u %u %u", &rec_id, &play_id,
+ &clock_rate, &ptime, &chnum);
+ if (cnt < 4) {
+ puts("error: not enough parameters");
+ break;
+ }
+ if (clock_rate < 8000 || clock_rate > 128000) {
+ puts("error: invalid clock rate");
+ break;
+ }
+ if (ptime < 10 || ptime > 500) {
+ puts("error: invalid ptime");
+ break;
+ }
+ if (cnt==5) {
+ if (chnum < 1 || chnum > 4) {
+ puts("error: invalid number of channels");
+ break;
+ }
+ } else {
+ chnum = 1;
+ }
+
+ if (rec_id >= 0 && rec_id < (int)dev_count) {
+ if (play_id >= 0 && play_id < (int)dev_count)
+ dir = PJMEDIA_DIR_CAPTURE_PLAYBACK;
+ else
+ dir = PJMEDIA_DIR_CAPTURE;
+ } else if (play_id >= 0 && play_id < (int)dev_count) {
+ dir = PJMEDIA_DIR_PLAYBACK;
+ } else {
+ puts("error: at least one valid device index required");
+ break;
+ }
+
+ test_device(dir, rec_id, play_id, clock_rate, ptime, chnum);
+
+ }
+ break;
+
+ case 'r':
+ /* record */
+ {
+ int index;
+ char filename[80];
+ int count;
+
+ count = sscanf(line+2, "%d %s", &index, filename);
+ if (count==1)
+ record(index, NULL);
+ else if (count==2)
+ record(index, filename);
+ else
+ puts("error: invalid command syntax");
+ }
+ break;
+
+ case 'p':
+ /* playback */
+ {
+ int index;
+ char filename[80];
+ int count;
+
+ count = sscanf(line+2, "%d %s", &index, filename);
+ if (count==1)
+ play_file(index, NULL);
+ else if (count==2)
+ play_file(index, filename);
+ else
+ puts("error: invalid command syntax");
+ }
+ break;
+
+ case 'v':
+ if (pj_log_get_level() <= 3) {
+ pj_log_set_level(5);
+ puts("Logging set to detail");
+ } else {
+ pj_log_set_level(3);
+ puts("Logging set to quiet");
+ }
+ break;
+
+ case 'q':
+ done = PJ_TRUE;
+ break;
+ }
+ }
+
+ pj_caching_pool_destroy(&cp);
+ pj_shutdown();
+ return 0;
+}
+
+
diff --git a/pjsip-apps/src/samples/debug.c b/pjsip-apps/src/samples/debug.c
index c7453d93..1a145b9a 100644
--- a/pjsip-apps/src/samples/debug.c
+++ b/pjsip-apps/src/samples/debug.c
@@ -28,5 +28,5 @@
* E.g.:
* #include "playfile.c"
*/
-#include "aectest.c"
+#include "auddemo.c"
diff --git a/pjsip-apps/src/samples/sndinfo.c b/pjsip-apps/src/samples/sndinfo.c
deleted file mode 100644
index 9f282d1a..00000000
--- a/pjsip-apps/src/samples/sndinfo.c
+++ /dev/null
@@ -1,295 +0,0 @@
-/* $Id$ */
-/*
- * Copyright (C) 2008-2009 Teluu Inc. (http://www.teluu.com)
- * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-static const char *desc =
- " sndinfo.c \n"
- " \n"
- " PURPOSE: \n"
- " Print sound device info and test open device. \n"
- " \n"
- " USAGE: \n"
- " sndinfo [id rec/play/both clockrate nchan bits] \n"
- " \n"
- " DESCRIPTION: \n"
- " When invoked without any arguments, it displays information about all \n"
- " sound devices in the system. \n"
- " \n"
- " When invoked with arguments, the program tests if device can be opened \n"
- " with the specified arguments. All these arguments must be specified: \n"
- " - id The device ID (-1 for the first capable device) \n"
- " - rec/play/both Specify which streams to open. \n"
- " - clockrate Specify clock rate (e.g. 8000, 11025, etc.) \n"
- " - nchan Number of channels (1=mono, 2=stereo). \n"
- " - bits Number of bits per sample (normally 16). \n";
-
-#include <pjmedia.h>
-#include <pjlib.h>
-
-#include <stdlib.h> /* atoi() */
-#include <stdio.h>
-
-
-static void enum_devices(void)
-{
- int i, count;
-
- count = pjmedia_snd_get_dev_count();
- if (count == 0) {
- puts("No devices found");
- return;
- }
-
- for (i=0; i<count; ++i) {
- const pjmedia_snd_dev_info *info;
-
- info = pjmedia_snd_get_dev_info(i);
- pj_assert(info != NULL);
-
- printf( "Device #%02d: \n"
- " Name : %s\n"
- " # of input channels : %d\n"
- " # of output channels: %d\n"
- " Default clock rate : %d Hz\n\n",
- i, info->name, info->input_count, info->output_count,
- info->default_samples_per_sec);
- }
- puts("");
- puts("Run with -h to get more options");
-}
-
-static unsigned clock_rate;
-static unsigned play_counter;
-static unsigned rec_counter;
-static unsigned min_delay = 0xFFFF, max_delay;
-static char play_delays[1000];
-static pj_uint32_t last_play_timestamp, last_rec_timestamp;
-
-static pj_status_t play_cb(void *user_data, pj_uint32_t timestamp,
- void *output, unsigned size)
-{
- static pj_timestamp last_cb;
-
-
- PJ_UNUSED_ARG(user_data);
- PJ_UNUSED_ARG(output);
- PJ_UNUSED_ARG(size);
-
-
- ++play_counter;
- last_play_timestamp = timestamp;
-
- if (last_cb.u64 == 0) {
- pj_get_timestamp(&last_cb);
- } else if (play_counter <= PJ_ARRAY_SIZE(play_delays)) {
- pj_timestamp now;
- unsigned delay;
-
- pj_get_timestamp(&now);
-
- delay = pj_elapsed_msec(&last_cb, &now);
- if (delay < min_delay)
- min_delay = delay;
- if (delay > max_delay)
- max_delay = delay;
-
- last_cb = now;
-
- play_delays[play_counter-1] = (char)delay;
- }
-
- return PJ_SUCCESS;
-}
-
-static pj_status_t rec_cb(void *user_data, pj_uint32_t timestamp,
- void *input, unsigned size)
-{
-
- PJ_UNUSED_ARG(size);
- PJ_UNUSED_ARG(input);
- PJ_UNUSED_ARG(user_data);
-
-
- ++rec_counter;
-
- if (timestamp - last_rec_timestamp >= clock_rate && last_play_timestamp) {
- int diff;
- diff = last_play_timestamp - timestamp;
- printf("Play timestamp=%u, capture timestamp=%u, diff=%d\n",
- last_play_timestamp, timestamp, diff);
- last_rec_timestamp = timestamp;
- }
- return PJ_SUCCESS;
-}
-
-static void app_perror(const char *title, pj_status_t status)
-{
- char errmsg[PJ_ERR_MSG_SIZE];
-
- pj_strerror(status, errmsg, sizeof(errmsg));
- printf( "%s: %s (err=%d)\n",
- title, errmsg, status);
-}
-
-static int open_device(int dev_id, pjmedia_dir dir,
- int nchannel, int bits)
-{
- pj_status_t status = PJ_SUCCESS;
- unsigned nsamples;
- pjmedia_snd_stream *strm;
- const char *dirtype;
- char tmp[10];
- unsigned i;
-
- switch (dir) {
- case PJMEDIA_DIR_CAPTURE:
- dirtype = "capture"; break;
- case PJMEDIA_DIR_PLAYBACK:
- dirtype = "playback"; break;
- case PJMEDIA_DIR_CAPTURE_PLAYBACK:
- dirtype = "capture/playback"; break;
- default:
- return 1;
- }
-
- nsamples = clock_rate * 20 / 1000;
-
- printf( "Opening device %d for %s: clockrate=%d, nchannel=%d, "
- "bits=%d, nsamples=%d..\n",
- dev_id, dirtype, clock_rate, nchannel, bits, nsamples);
-
- if (dir == PJMEDIA_DIR_CAPTURE) {
- status = pjmedia_snd_open_rec( dev_id, clock_rate, nchannel,
- nsamples, bits, &rec_cb, NULL,
- &strm);
- } else if (dir == PJMEDIA_DIR_PLAYBACK) {
- status = pjmedia_snd_open_player( dev_id, clock_rate, nchannel,
- nsamples, bits, &play_cb, NULL,
- &strm);
- } else {
- status = pjmedia_snd_open( dev_id, dev_id, clock_rate, nchannel,
- nsamples, bits, &rec_cb, &play_cb, NULL,
- &strm);
- }
-
- if (status != PJ_SUCCESS) {
- app_perror("Unable to open device for capture", status);
- return 1;
- }
-
- status = pjmedia_snd_stream_start(strm);
- if (status != PJ_SUCCESS) {
- app_perror("Unable to start capture stream", status);
- return 1;
- }
-
- /* Let playback/capture runs for a while */
- //pj_thread_sleep(1000);
- puts("Press <ENTER> to stop");
- if (fgets(tmp, sizeof(tmp), stdin) == NULL) {
- puts("EOF while reading stdin, will quit now..");
- }
-
- pjmedia_snd_stream_close(strm);
-
- if ((dir & PJMEDIA_DIR_CAPTURE) && rec_counter==0) {
- printf("Error: capture stream was not running\n");
- return 1;
- }
-
- if ((dir & PJMEDIA_DIR_PLAYBACK) && play_counter==0) {
- printf("Error: playback stream was not running\n");
- return 1;
- }
-
- puts("Success.");
-
- printf("Delay: ");
- for (i=0; i<play_counter; ++i)
- printf("%d ", play_delays[i]);
-
- puts("");
- if (dir & PJMEDIA_DIR_PLAYBACK) {
- printf("Callback interval: min interval=%d ms, max interval=%d ms\n",
- min_delay, max_delay);
- }
-
-
- return 0;
-}
-
-
-int main(int argc, char *argv[])
-{
- pj_caching_pool cp;
- pjmedia_endpt *med_endpt;
- pj_status_t status;
-
- /* Init pjlib */
- status = pj_init();
- PJ_ASSERT_RETURN(status==PJ_SUCCESS, 1);
-
- /* Must create a pool factory before we can allocate any memory. */
- pj_caching_pool_init(&cp, &pj_pool_factory_default_policy, 0);
-
- /*
- * Initialize media endpoint.
- * This will implicitly initialize PJMEDIA too.
- */
- status = pjmedia_endpt_create(&cp.factory, NULL, 1, &med_endpt);
- PJ_ASSERT_RETURN(status == PJ_SUCCESS, 1);
-
-
- if (argc == 1) {
- enum_devices();
- } else if (argc == 6) {
-
- int dev_id;
- pjmedia_dir dir = PJMEDIA_DIR_NONE;
- int nchannel;
- int bits;
-
- dev_id = atoi(argv[1]);
-
- if (strcmp(argv[2], "rec")==0)
- dir = PJMEDIA_DIR_CAPTURE;
- else if (strcmp(argv[2], "play")==0)
- dir = PJMEDIA_DIR_PLAYBACK;
- else if (strcmp(argv[2], "both")==0)
- dir = PJMEDIA_DIR_CAPTURE_PLAYBACK;
-
- clock_rate = atoi(argv[3]);
- nchannel = atoi(argv[4]);
- bits = atoi(argv[5]);
-
- return open_device(dev_id, dir, nchannel, bits);
-
- } else {
- puts("Error: invalid arguments");
- puts(desc);
- return 1;
- }
-
- /* Shutdown PJLIB */
- pj_shutdown();
-
- return 0;
-}
-
-
diff --git a/pjsip-apps/src/samples/sndtest.c b/pjsip-apps/src/samples/sndtest.c
deleted file mode 100644
index 007ed57d..00000000
--- a/pjsip-apps/src/samples/sndtest.c
+++ /dev/null
@@ -1,621 +0,0 @@
-/* $Id$ */
-/*
- * Copyright (C) 2008-2009 Teluu Inc. (http://www.teluu.com)
- * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-/**
- * \page page_pjmedia_samples_sndtest_c Samples: Sound Card Benchmark
- *
- * This example can be used to benchmark the quality of the sound card
- * installed in the system. At the end of the test, it will report
- * the jitter and clock drifts of the device.
- *
- * This file is pjsip-apps/src/samples/sndtest.c
- *
- * Screenshots on WinXP: \image html sndtest.jpg
- *
- * \includelineno sndtest.c
- */
-
-
-#include <pjmedia.h>
-#include <pjlib.h>
-#include <pjlib-util.h>
-
-#include <stdlib.h> /* atoi() */
-#include <stdio.h>
-
-
-
-#define THIS_FILE "sndtest.c"
-
-/* Warn (print log with yellow color) if frame jitter is larger than
- * this value (in usec).
- */
-#define WARN_JITTER_USEC 1000
-
-/* Test duration in msec */
-#define DURATION 10000
-
-/* Skip the first msec from the calculation */
-#define SKIP_DURATION 1000
-
-/* Max frames per sec (to calculate number of delays to keep). */
-#define MAX_FRAMES_PER_SEC 100
-
-/* Number of frame durations to keep */
-#define MAX_DELAY_COUNTER (((DURATION/1000)+1)*MAX_FRAMES_PER_SEC)
-
-
-struct stream_data
-{
- pj_uint32_t first_timestamp;
- pj_uint32_t last_timestamp;
- pj_timestamp last_called;
- unsigned counter;
- unsigned min_delay;
- unsigned max_delay;
- unsigned delay[MAX_DELAY_COUNTER];
-};
-
-struct test_data {
- pjmedia_dir dir;
- unsigned clock_rate;
- unsigned samples_per_frame;
- unsigned channel_count;
- pj_bool_t running;
- pj_bool_t has_error;
- pj_mutex_t *mutex;
-
- struct stream_data capture_data;
- struct stream_data playback_data;
-};
-
-
-
-static const char *desc =
- " sndtest.c \n"
- " \n"
- " PURPOSE: \n"
- " Test the performance of sound device. \n"
- " \n"
- " USAGE: \n"
- " sndtest --help \n"
- " sndtest [options] \n"
- " \n"
- " where options: \n"
- " --id=ID -i Use device ID (default is -1) \n"
- " --rate=HZ -r Set test clock rate (default=8000)\n"
- " --frame=SAMPLES -f Set number of samples per frame\n"
- " --channel=CH -n Set number of channels (default=1)\n"
- " --verbose -v Show verbose result \n"
- " --help -h Show this screen \n"
-;
-
-
-
-static void enum_devices(void)
-{
- int i, count;
-
- count = pjmedia_snd_get_dev_count();
- if (count == 0) {
- PJ_LOG(3,(THIS_FILE, "No devices found"));
- return;
- }
-
- PJ_LOG(3,(THIS_FILE, "Found %d devices:", count));
- for (i=0; i<count; ++i) {
- const pjmedia_snd_dev_info *info;
-
- info = pjmedia_snd_get_dev_info(i);
- pj_assert(info != NULL);
-
- PJ_LOG(3,(THIS_FILE," %d: %s (capture=%d, playback=%d)",
- i, info->name, info->input_count, info->output_count));
- }
-}
-
-
-static pj_status_t play_cb(void *user_data, pj_uint32_t timestamp,
- void *output, unsigned size)
-{
- struct test_data *test_data = user_data;
- struct stream_data *strm_data = &test_data->playback_data;
-
- pj_mutex_lock(test_data->mutex);
-
- /* Skip frames when test is not started or test has finished */
- if (!test_data->running) {
- pj_bzero(output, size);
-
- pj_mutex_unlock(test_data->mutex);
- return PJ_SUCCESS;
- }
-
- /* Save last timestamp seen (to calculate drift) */
- strm_data->last_timestamp = timestamp;
-
- if (strm_data->last_called.u64 == 0) {
- pj_get_timestamp(&strm_data->last_called);
- /* Init min_delay to one frame */
- strm_data->min_delay = test_data->samples_per_frame * 1000000 /
- test_data->clock_rate;
- strm_data->first_timestamp = timestamp;
-
- } else if (strm_data->counter <= MAX_DELAY_COUNTER) {
- pj_timestamp now;
- unsigned delay;
-
- pj_get_timestamp(&now);
-
- /* Calculate frame interval */
- delay = pj_elapsed_usec(&strm_data->last_called, &now);
- if (delay < strm_data->min_delay)
- strm_data->min_delay = delay;
- if (delay > strm_data->max_delay)
- strm_data->max_delay = delay;
-
- strm_data->last_called = now;
-
- /* Save the frame interval for later calculation */
- strm_data->delay[strm_data->counter] = delay;
- ++strm_data->counter;
-
- } else {
-
- /* No space, can't take anymore frames */
- test_data->running = 0;
-
- }
-
- pj_bzero(output, size);
-
- pj_mutex_unlock(test_data->mutex);
-
- return PJ_SUCCESS;
-}
-
-static pj_status_t rec_cb(void *user_data, pj_uint32_t timestamp,
- void *input, unsigned size)
-{
-
- struct test_data *test_data = user_data;
- struct stream_data *strm_data = &test_data->capture_data;
-
- pj_mutex_lock(test_data->mutex);
-
- PJ_UNUSED_ARG(input);
- PJ_UNUSED_ARG(size);
-
- /* Skip frames when test is not started or test has finished */
- if (!test_data->running) {
- pj_mutex_unlock(test_data->mutex);
- return PJ_SUCCESS;
- }
-
- /* Save last timestamp seen (to calculate drift) */
- strm_data->last_timestamp = timestamp;
-
- if (strm_data->last_called.u64 == 0) {
- pj_get_timestamp(&strm_data->last_called);
- /* Init min_delay to one frame */
- strm_data->min_delay = test_data->samples_per_frame * 1000000 /
- test_data->clock_rate;
- strm_data->first_timestamp = timestamp;
-
- } else if (strm_data->counter <= MAX_DELAY_COUNTER) {
- pj_timestamp now;
- unsigned delay;
-
- pj_get_timestamp(&now);
-
- /* Calculate frame interval */
- delay = pj_elapsed_usec(&strm_data->last_called, &now);
- if (delay < strm_data->min_delay)
- strm_data->min_delay = delay;
- if (delay > strm_data->max_delay)
- strm_data->max_delay = delay;
-
- strm_data->last_called = now;
-
- /* Save the frame interval for later calculation */
- strm_data->delay[strm_data->counter] = delay;
- ++strm_data->counter;
-
- } else {
-
- /* No space, can't take anymore frames */
- test_data->running = 0;
-
- }
-
- pj_mutex_unlock(test_data->mutex);
- return PJ_SUCCESS;
-}
-
-static void app_perror(const char *title, pj_status_t status)
-{
- char errmsg[PJ_ERR_MSG_SIZE];
-
- pj_strerror(status, errmsg, sizeof(errmsg));
- printf( "%s: %s (err=%d)\n",
- title, errmsg, status);
-}
-
-
-static void print_stream_data(const char *title,
- struct test_data *test_data,
- struct stream_data *strm_data,
- int verbose)
-{
- unsigned i, dur;
- int ptime;
- unsigned min_jitter, max_jitter, sum_jitter, avg_jitter=0;
-
- PJ_LOG(3,(THIS_FILE, " %s stream report:", title));
-
- /* Check that frames are captured/played */
- if (strm_data->counter == 0) {
- PJ_LOG(1,(THIS_FILE, " Error: no frames are captured/played!"));
- test_data->has_error = 1;
- return;
- }
-
- /* Duration */
- dur = (strm_data->counter+1) * test_data->samples_per_frame * 1000 /
- test_data->clock_rate;
- PJ_LOG(3,(THIS_FILE, " Duration: %ds.%03d",
- dur/1000, dur%1000));
-
- /* Frame interval */
- if (strm_data->max_delay - strm_data->min_delay < WARN_JITTER_USEC) {
- PJ_LOG(3,(THIS_FILE,
- " Frame interval: min=%d.%03dms, max=%d.%03dms",
- strm_data->min_delay/1000, strm_data->min_delay%1000,
- strm_data->max_delay/1000, strm_data->max_delay%1000));
- } else {
- test_data->has_error = 1;
- PJ_LOG(2,(THIS_FILE,
- " Frame interval: min=%d.%03dms, max=%d.%03dms",
- strm_data->min_delay/1000, strm_data->min_delay%1000,
- strm_data->max_delay/1000, strm_data->max_delay%1000));
- }
-
- if (verbose) {
- unsigned i;
- unsigned decor = pj_log_get_decor();
-
- PJ_LOG(3,(THIS_FILE, " Dumping frame delays:"));
-
- pj_log_set_decor(0);
- for (i=0; i<strm_data->counter; ++i)
- PJ_LOG(3,(THIS_FILE, " %d.%03d", strm_data->delay[i]/1000,
- strm_data->delay[i]%1000));
- PJ_LOG(3,(THIS_FILE, "\r\n"));
- pj_log_set_decor(decor);
- }
-
- /* Calculate frame ptime in usec */
- ptime = test_data->samples_per_frame * 1000000 /
- test_data->clock_rate;
-
- /* Calculate jitter */
- min_jitter = 0xFFFFF;
- max_jitter = 0;
- sum_jitter = 0;
-
- for (i=1; i<strm_data->counter; ++i) {
- int jitter1, jitter2, jitter;
-
- /* jitter1 is interarrival difference */
- jitter1 = strm_data->delay[i] - strm_data->delay[i-1];
- if (jitter1 < 0) jitter1 = -jitter1;
-
- /* jitter2 is difference between actual and scheduled arrival.
- * This is intended to capture situation when frames are coming
- * instantaneously, which will calculate as zero jitter with
- * jitter1 calculation.
- */
- jitter2 = ptime - strm_data->delay[i];
- if (jitter2 < 0) jitter2 = -jitter2;
-
- /* Set jitter as the maximum of the two jitter calculations.
- * This is intended to show the worst result.
- */
- jitter = (jitter1>jitter2) ? jitter1 : jitter2;
-
- /* Calculate min, max, avg jitter */
- if (jitter < (int)min_jitter) min_jitter = jitter;
- if (jitter > (int)max_jitter) max_jitter = jitter;
-
- sum_jitter += jitter;
- }
-
- avg_jitter = (sum_jitter) / (strm_data->counter - 1);
-
- if (max_jitter < WARN_JITTER_USEC) {
- PJ_LOG(3,(THIS_FILE,
- " Jitter: min=%d.%03dms, avg=%d.%03dms, max=%d.%03dms",
- min_jitter/1000, min_jitter%1000,
- avg_jitter/1000, avg_jitter%1000,
- max_jitter/1000, max_jitter%1000));
- } else {
- test_data->has_error = 1;
- PJ_LOG(2,(THIS_FILE,
- " Jitter: min=%d.%03dms, avg=%d.%03dms, max=%d.%03dms",
- min_jitter/1000, min_jitter%1000,
- avg_jitter/1000, avg_jitter%1000,
- max_jitter/1000, max_jitter%1000));
- }
-}
-
-
-static int perform_test(pj_pool_t *pool, int dev_id, pjmedia_dir dir,
- unsigned clock_rate, unsigned samples_per_frame,
- unsigned nchannel, int verbose)
-{
- pj_status_t status = PJ_SUCCESS;
- pjmedia_snd_stream *strm;
- struct test_data test_data;
- pjmedia_snd_stream_info si;
-
- /*
- * Init test parameters
- */
- pj_bzero(&test_data, sizeof(test_data));
- test_data.dir = dir;
- test_data.clock_rate = clock_rate;
- test_data.samples_per_frame = samples_per_frame;
- test_data.channel_count = nchannel;
-
- pj_mutex_create_simple(pool, "sndtest", &test_data.mutex);
-
- /*
- * Open device.
- */
- if (dir == PJMEDIA_DIR_CAPTURE) {
- status = pjmedia_snd_open_rec( dev_id, clock_rate, nchannel,
- samples_per_frame, 16, &rec_cb,
- &test_data, &strm);
- } else if (dir == PJMEDIA_DIR_PLAYBACK) {
- status = pjmedia_snd_open_player( dev_id, clock_rate, nchannel,
- samples_per_frame, 16, &play_cb,
- &test_data, &strm);
- } else {
- status = pjmedia_snd_open( dev_id, dev_id, clock_rate, nchannel,
- samples_per_frame, 16, &rec_cb, &play_cb,
- &test_data, &strm);
- }
-
- if (status != PJ_SUCCESS) {
- app_perror("Unable to open device for capture", status);
- return status;
- }
-
- pjmedia_snd_stream_get_info(strm, &si);
- if (si.play_id >= 0) {
- PJ_LOG(3,(THIS_FILE, "Testing playback device %s",
- pjmedia_snd_get_dev_info(si.play_id)->name));
- }
- if (si.rec_id >= 0) {
- PJ_LOG(3,(THIS_FILE, "Testing capture device %s",
- pjmedia_snd_get_dev_info(si.rec_id)->name));
- }
-
- /* Sleep for a while to let sound device "settles" */
- pj_thread_sleep(200);
-
-
- /*
- * Start the stream.
- */
- status = pjmedia_snd_stream_start(strm);
- if (status != PJ_SUCCESS) {
- app_perror("Unable to start capture stream", status);
- return status;
- }
-
- PJ_LOG(3,(THIS_FILE,
- " Please wait while test is in progress (~%d secs)..",
- (DURATION+SKIP_DURATION)/1000));
-
- /* Let the stream runs for few msec/sec to get stable result.
- * (capture normally begins with frames available simultaneously).
- */
- pj_thread_sleep(SKIP_DURATION);
-
-
- /* Begin gather data */
- test_data.running = 1;
-
- /*
- * Let the test runs for a while.
- */
- pj_thread_sleep(DURATION);
-
-
- /*
- * Close stream.
- */
- test_data.running = 0;
- pjmedia_snd_stream_close(strm);
-
-
- /*
- * Print results.
- */
- PJ_LOG(3,(THIS_FILE, " Dumping results:"));
-
- PJ_LOG(3,(THIS_FILE, " Parameters: clock rate=%dHz, %d samples/frame",
- clock_rate, samples_per_frame));
-
- if (dir & PJMEDIA_DIR_PLAYBACK)
- print_stream_data("Playback", &test_data, &test_data.playback_data,
- verbose);
- if (dir & PJMEDIA_DIR_CAPTURE)
- print_stream_data("Capture", &test_data, &test_data.capture_data,
- verbose);
-
- /* Check drifting */
- if (dir == PJMEDIA_DIR_CAPTURE_PLAYBACK) {
- int end_diff, start_diff, drift;
-
- end_diff = test_data.capture_data.last_timestamp -
- test_data.playback_data.last_timestamp;
- start_diff = test_data.capture_data.first_timestamp-
- test_data.playback_data.first_timestamp;
- drift = end_diff > start_diff? end_diff - start_diff :
- start_diff - end_diff;
-
- PJ_LOG(3,(THIS_FILE, " Checking for clock drifts:"));
-
- /* Allow one frame tolerance for clock drift detection */
- if (drift < (int)samples_per_frame) {
- PJ_LOG(3,(THIS_FILE, " No clock drifts is detected"));
- } else {
- const char *which = (drift<0 ? "slower" : "faster");
- unsigned msec_dur;
-
- if (drift < 0) drift = -drift;
-
-
- msec_dur = (test_data.capture_data.last_timestamp -
- test_data.capture_data.first_timestamp) * 1000 /
- test_data.clock_rate;
-
- PJ_LOG(2,(THIS_FILE,
- " Sound capture is %d samples %s than playback "
- "at the end of the test (average is %d samples"
- " per second)",
- drift, which,
- drift * 1000 / msec_dur));
-
- }
- }
-
- if (test_data.has_error == 0) {
- PJ_LOG(3,(THIS_FILE, " Test completed, sound device looks okay."));
- return 0;
- } else {
- PJ_LOG(2,(THIS_FILE, " Test completed with some warnings"));
- return 1;
- }
-}
-
-
-int main(int argc, char *argv[])
-{
- pj_caching_pool cp;
- pj_pool_t *pool;
- pjmedia_endpt *med_endpt;
- int id = -1, verbose = 0;
- int clock_rate = 8000;
- int frame = -1;
- int channel = 1;
- struct pj_getopt_option long_options[] = {
- { "id", 1, 0, 'i' },
- { "rate", 1, 0, 'r' },
- { "frame", 1, 0, 'f' },
- { "channel", 1, 0, 'n' },
- { "verbose", 0, 0, 'v' },
- { "help", 0, 0, 'h' },
- { NULL, 0, 0, 0 }
- };
- int c, option_index;
-
-
- pj_status_t status;
-
- /* Init pjlib */
- status = pj_init();
- PJ_ASSERT_RETURN(status==PJ_SUCCESS, 1);
-
- /* Must create a pool factory before we can allocate any memory. */
- pj_caching_pool_init(&cp, &pj_pool_factory_default_policy, 0);
-
- /* Also create pool for misc purposes */
- pool = pj_pool_create(&cp.factory, "sndtest", 1000, 1000, NULL);
-
- /*
- * Initialize media endpoint.
- * This will implicitly initialize PJMEDIA too.
- */
- status = pjmedia_endpt_create(&cp.factory, NULL, 1, &med_endpt);
- PJ_ASSERT_RETURN(status == PJ_SUCCESS, 1);
-
- /* Print devices */
- enum_devices();
-
- /* Parse options */
- pj_optind = 0;
- while((c=pj_getopt_long(argc,argv, "i:r:f:n:vh",
- long_options, &option_index))!=-1)
- {
- switch (c) {
- case 'i':
- id = atoi(pj_optarg);
- break;
- case 'r':
- clock_rate = atoi(pj_optarg);
- break;
- case 'f':
- frame = atoi(pj_optarg);
- break;
- case 'n':
- channel = atoi(pj_optarg);
- break;
- case 'v':
- verbose = 1;
- break;
- case 'h':
- puts(desc);
- return 0;
- break;
- default:
- printf("Error: invalid options %s\n", argv[pj_optind-1]);
- puts(desc);
- return 1;
- }
- }
-
- if (pj_optind != argc) {
- printf("Error: invalid options\n");
- puts(desc);
- return 1;
- }
-
- if (!verbose)
- pj_log_set_level(3);
-
- if (frame == -1)
- frame = 10 * clock_rate / 1000;
-
-
- status = perform_test(pool, id, PJMEDIA_DIR_CAPTURE_PLAYBACK,
- clock_rate, frame, channel, verbose);
-
- pjmedia_endpt_destroy(med_endpt);
- pj_pool_release(pool);
- pj_caching_pool_destroy(&cp);
- pj_shutdown();
-
- return status == PJ_SUCCESS ? 0 : 1;
-}
-
-
diff --git a/pjsip-apps/src/symbian_ua/main_symbian.cpp b/pjsip-apps/src/symbian_ua/main_symbian.cpp
index b26b10bd..a0082a02 100644
--- a/pjsip-apps/src/symbian_ua/main_symbian.cpp
+++ b/pjsip-apps/src/symbian_ua/main_symbian.cpp
@@ -29,7 +29,7 @@
CConsoleBase* console;
// Needed by APS
-TPtrC APP_UID = _L("A000000D");
+TPtrC APP_UID = _L("200235D3");
////////////////////////////////////////////////////////////////////////////
diff --git a/pjsip-apps/src/symbian_ua/ua.cpp b/pjsip-apps/src/symbian_ua/ua.cpp
index 11adb154..033a2f2a 100644
--- a/pjsip-apps/src/symbian_ua/ua.cpp
+++ b/pjsip-apps/src/symbian_ua/ua.cpp
@@ -19,10 +19,12 @@
*/
#include <pjsua-lib/pjsua.h>
#include <pjsua-lib/pjsua_internal.h>
+//#include <pjmedia/symbian_sound_aps.h>
#include "ua.h"
#define THIS_FILE "symbian_ua.cpp"
-#define LOG_LEVEL 3
+#define CON_LOG_LEVEL 3 // console log level
+#define FILE_LOG_LEVEL 4 // logfile log level
//
// Basic config.
@@ -280,7 +282,7 @@ static pj_status_t app_startup()
pj_log_set_log_func(&log_writer);
/* Set log level */
- pj_log_set_level(LOG_LEVEL);
+ pj_log_set_level(CON_LOG_LEVEL);
/* Create pjsua first! */
status = pjsua_create();
@@ -328,23 +330,20 @@ static pj_status_t app_startup()
pjsua_logging_config_default(&log_cfg);
- log_cfg.level = LOG_LEVEL;
- log_cfg.console_level = LOG_LEVEL;
+ log_cfg.level = FILE_LOG_LEVEL;
+ log_cfg.console_level = CON_LOG_LEVEL;
log_cfg.cb = &log_writer;
- //log_cfg.log_filename = pj_str("C:\\data\\symbian_ua.log");
+ log_cfg.log_filename = pj_str("C:\\data\\symbian_ua.log");
pjsua_media_config_default(&med_cfg);
med_cfg.thread_cnt = 0; // Disable threading on Symbian
med_cfg.has_ioqueue = PJ_FALSE;
med_cfg.clock_rate = 8000;
-#if defined(PJMEDIA_SYM_SND_USE_APS) && (PJMEDIA_SYM_SND_USE_APS==1)
- med_cfg.audio_frame_ptime = 20;
-#else
med_cfg.audio_frame_ptime = 40;
-#endif
med_cfg.ec_tail_len = 0;
med_cfg.enable_ice = USE_ICE;
- med_cfg.snd_auto_close_time = 5; // wait for 5 seconds idle before sound dev get auto-closed
+ med_cfg.snd_auto_close_time = 0; // wait for 0 seconds idle before sound dev get auto-closed
+ //med_cfg.no_vad = PJ_TRUE;
status = pjsua_init(&cfg, &log_cfg, &med_cfg);
if (status != PJ_SUCCESS) {
@@ -491,87 +490,233 @@ void ConsoleUI::DoCancel()
con_->ReadCancel();
}
-static void PrintMenu()
+static void PrintMainMenu()
{
- PJ_LOG(3, (THIS_FILE, "\n\n"
- "Menu:\n"
- " d Dump states\n"
- " D Dump states detail\n"
- " P Dump pool factory\n"
- " l Start loopback audio device\n"
- " L Stop loopback audio device\n"
+ const char *menu =
+ "\n\n"
+ "Main Menu:\n"
+ " d Enable/disable codecs\n"
" m Call " SIP_DST_URI "\n"
" a Answer call\n"
" g Hangup all calls\n"
+ " t Toggle audio route\n"
+#if !defined(PJMEDIA_CONF_USE_SWITCH_BOARD) || PJMEDIA_CONF_USE_SWITCH_BOARD==0
+ " j Toggle loopback audio\n"
+#endif
+ "up/dn Increase/decrease output volume\n"
" s Subscribe " SIP_DST_URI "\n"
" S Unsubscribe presence\n"
" o Set account online\n"
" O Set account offline\n"
- " w Quit\n"));
+ " w Quit\n";
+
+ PJ_LOG(3, (THIS_FILE, menu));
}
-// Implementation: called when read has completed.
-void ConsoleUI::RunL()
+static void PrintCodecMenu()
{
- TKeyCode kc = con_->KeyCode();
- pj_bool_t reschedule = PJ_TRUE;
+ const char *menu =
+ "\n\n"
+ "Codec Menu:\n"
+ " a Enable all codecs\n"
+#if PJMEDIA_HAS_PASSTHROUGH_CODEC_AMR
+ " d Enable only AMR\n"
+#endif
+#if PJMEDIA_HAS_PASSTHROUGH_CODEC_G729
+ " g Enable only G.729\n"
+#endif
+#if PJMEDIA_HAS_PASSTHROUGH_CODEC_ILBC
+ " j Enable only iLBC\n"
+#endif
+ " m Enable only Speex\n"
+ " p Enable only GSM\n"
+ " t Enable only PCMU\n"
+ " w Enable only PCMA\n";
+ PJ_LOG(3, (THIS_FILE, menu));
+}
+
+static void HandleMainMenu(TKeyCode kc) {
switch (kc) {
- case 'w':
- CActiveScheduler::Stop();
- reschedule = PJ_FALSE;
- break;
- case 'D':
- case 'd':
- pjsua_dump(kc == 'D');
- break;
- case 'p':
- case 'P':
- pj_pool_factory_dump(pjsua_get_pool_factory(), PJ_TRUE);
- break;
- case 'l':
- pjsua_conf_connect(0, 0);
- break;
- case 'L':
- pjsua_conf_disconnect(0, 0);
- break;
- case 'm':
- if (g_call_id != PJSUA_INVALID_ID) {
- PJ_LOG(3,(THIS_FILE, "Another call is active"));
- break;
- }
- if (pjsua_verify_sip_url(SIP_DST_URI) == PJ_SUCCESS) {
- pj_str_t dst = pj_str(SIP_DST_URI);
- pjsua_call_make_call(g_acc_id, &dst, 0, NULL,
- NULL, &g_call_id);
+ case EKeyUpArrow:
+ case EKeyDownArrow:
+ {
+ unsigned vol;
+ pj_status_t status;
+
+ status = pjsua_snd_get_setting(
+ PJMEDIA_AUD_DEV_CAP_OUTPUT_VOLUME_SETTING, &vol);
+ if (status == PJ_SUCCESS) {
+ if (kc == EKeyUpArrow)
+ vol = PJ_MIN(100, vol+10);
+ else
+ vol = (vol>=10 ? vol-10 : 0);
+ status = pjsua_snd_set_setting(
+ PJMEDIA_AUD_DEV_CAP_OUTPUT_VOLUME_SETTING,
+ &vol, PJ_TRUE);
+ }
+
+ if (status == PJ_SUCCESS) {
+ PJ_LOG(3,(THIS_FILE, "Output volume set to %d", vol));
} else {
- PJ_LOG(3,(THIS_FILE, "Invalid SIP URI"));
+ pjsua_perror(THIS_FILE, "Error setting volume", status);
}
- break;
+ }
+ break;
+
+ case 't':
+ {
+ pjmedia_aud_dev_route route;
+ pj_status_t status;
+
+ status = pjsua_snd_get_setting(PJMEDIA_AUD_DEV_CAP_OUTPUT_ROUTE,
+ &route);
+
+ if (status == PJ_SUCCESS) {
+ if (route == PJMEDIA_AUD_DEV_ROUTE_LOUDSPEAKER)
+ route = PJMEDIA_AUD_DEV_ROUTE_EARPIECE;
+ else
+ route = PJMEDIA_AUD_DEV_ROUTE_LOUDSPEAKER;
+
+ status = pjsua_snd_set_setting(
+ PJMEDIA_AUD_DEV_CAP_OUTPUT_ROUTE,
+ &route, PJ_TRUE);
+ }
+
+ if (status != PJ_SUCCESS)
+ pjsua_perror(THIS_FILE, "Error switch audio route", status);
+ }
+ break;
+
+ case 'j':
+ {
+ static pj_bool_t loopback_active = PJ_FALSE;
+ if (!loopback_active)
+ pjsua_conf_connect(0, 0);
+ else
+ pjsua_conf_disconnect(0, 0);
+ loopback_active = !loopback_active;
+ }
+ break;
+
+ case 'm':
+ if (g_call_id != PJSUA_INVALID_ID) {
+ PJ_LOG(3,(THIS_FILE, "Another call is active"));
+ break;
+ }
+
+ if (pjsua_verify_sip_url(SIP_DST_URI) == PJ_SUCCESS) {
+ pj_str_t dst = pj_str(SIP_DST_URI);
+ pjsua_call_make_call(g_acc_id, &dst, 0, NULL,
+ NULL, &g_call_id);
+ } else {
+ PJ_LOG(3,(THIS_FILE, "Invalid SIP URI"));
+ }
+ break;
case 'a':
- if (g_call_id != PJSUA_INVALID_ID)
- pjsua_call_answer(g_call_id, 200, NULL, NULL);
- break;
+ if (g_call_id != PJSUA_INVALID_ID)
+ pjsua_call_answer(g_call_id, 200, NULL, NULL);
+ break;
case 'g':
- pjsua_call_hangup_all();
- break;
+ pjsua_call_hangup_all();
+ break;
case 's':
case 'S':
- if (g_buddy_id != PJSUA_INVALID_ID)
- pjsua_buddy_subscribe_pres(g_buddy_id, kc=='s');
- break;
+ if (g_buddy_id != PJSUA_INVALID_ID)
+ pjsua_buddy_subscribe_pres(g_buddy_id, kc=='s');
+ break;
case 'o':
case 'O':
- pjsua_acc_set_online_status(g_acc_id, kc=='o');
- break;
+ pjsua_acc_set_online_status(g_acc_id, kc=='o');
+ break;
+
default:
- PJ_LOG(3,(THIS_FILE, "Keycode '%c' (%d) is pressed",
- kc, kc));
+ PJ_LOG(3,(THIS_FILE, "Keycode '%c' (%d) is pressed", kc, kc));
+ break;
+ }
+
+ PrintMainMenu();
+}
+
+static void HandleCodecMenu(TKeyCode kc) {
+ const pj_str_t ID_ALL = {"*", 1};
+ pj_str_t codec = {NULL, 0};
+
+ if (kc == 'a') {
+ pjsua_codec_set_priority(&ID_ALL, PJMEDIA_CODEC_PRIO_NORMAL);
+ PJ_LOG(3,(THIS_FILE, "All codecs activated"));
+ } else {
+ switch (kc) {
+ case 'd':
+ codec = pj_str("AMR");
+ break;
+ case 'g':
+ codec = pj_str("G729");
+ break;
+ case 'j':
+ codec = pj_str("ILBC");
+ break;
+ case 'm':
+ codec = pj_str("SPEEX/8000");
+ break;
+ case 'p':
+ codec = pj_str("GSM");
+ break;
+ case 't':
+ codec = pj_str("PCMU");
+ break;
+ case 'w':
+ codec = pj_str("PCMA");
+ break;
+ default:
+ PJ_LOG(3,(THIS_FILE, "Keycode '%c' (%d) is pressed", kc, kc));
break;
+ }
+
+ if (codec.slen) {
+ pj_status_t status;
+
+ pjsua_codec_set_priority(&ID_ALL, PJMEDIA_CODEC_PRIO_DISABLED);
+
+ status = pjsua_codec_set_priority(&codec,
+ PJMEDIA_CODEC_PRIO_NORMAL);
+ if (status == PJ_SUCCESS)
+ PJ_LOG(3,(THIS_FILE, "%s activated", codec.ptr));
+ else
+ PJ_LOG(3,(THIS_FILE, "Failed activating %s, err=%d",
+ codec.ptr, status));
+ }
}
+}
- PrintMenu();
+// Implementation: called when read has completed.
+void ConsoleUI::RunL()
+{
+ enum {
+ MENU_TYPE_MAIN = 0,
+ MENU_TYPE_CODEC = 1
+ };
+ static int menu_type = MENU_TYPE_MAIN;
+ TKeyCode kc = con_->KeyCode();
+ pj_bool_t reschedule = PJ_TRUE;
+
+ if (menu_type == MENU_TYPE_MAIN) {
+ if (kc == 'w') {
+ CActiveScheduler::Stop();
+ reschedule = PJ_FALSE;
+ } else if (kc == 'd') {
+ menu_type = MENU_TYPE_CODEC;
+ PrintCodecMenu();
+ } else {
+ HandleMainMenu(kc);
+ }
+ } else {
+ HandleCodecMenu(kc);
+
+ menu_type = MENU_TYPE_MAIN;
+ PrintMainMenu();
+ }
if (reschedule)
Run();
@@ -815,7 +960,7 @@ private:
}
PJ_LOG(3, (THIS_FILE, "PJSUA restarted."));
- PrintMenu();
+ PrintMainMenu();
}
Start();
@@ -873,7 +1018,7 @@ int ua_main()
ConsoleUI *con = new ConsoleUI(console);
con->Run();
- PrintMenu();
+ PrintMainMenu();
// Init & start connection monitor
CConnMon *connmon = CConnMon::NewL(aConn, aSocketServer);
@@ -910,7 +1055,7 @@ int ua_main()
// Close connection and socket server
aConn.Close();
aSocketServer.Close();
-
+
return status;
}
diff --git a/pjsip-apps/src/symbian_ua_gui/group/symbian_ua_gui.mmp b/pjsip-apps/src/symbian_ua_gui/group/symbian_ua_gui.mmp
index 0a09fcb3..5128ca69 100644
--- a/pjsip-apps/src/symbian_ua_gui/group/symbian_ua_gui.mmp
+++ b/pjsip-apps/src/symbian_ua_gui/group/symbian_ua_gui.mmp
@@ -39,6 +39,7 @@ LIBRARY charconv.lib estlib.lib
STATICLIBRARY pjsua_lib.lib pjsip_ua.lib
STATICLIBRARY pjsip_simple.lib pjsip.lib pjsdp.lib pjmedia.lib
+STATICLIBRARY pjmedia_audiodev.lib
STATICLIBRARY pjnath.lib pjlib_util.lib pjlib.lib
STATICLIBRARY libsrtp.lib
STATICLIBRARY libgsmcodec.lib
@@ -49,12 +50,10 @@ STATICLIBRARY libspeexcodec.lib
STATICLIBRARY null_audio.lib
CAPABILITY NetworkServices LocalServices ReadUserData WriteUserData UserEnvironment
#elif SND_USE_APS
- STATICLIBRARY symbian_audio_aps.lib
- LIBRARY APSSession2.lib
+ LIBRARY APSSession2.lib
CAPABILITY NetworkServices LocalServices ReadUserData WriteUserData UserEnvironment MultimediaDD
- MACRO PJMEDIA_SYM_SND_USE_APS=1
+ MACRO PJMEDIA_SYM_SND_USE_APS=1
#else
- STATICLIBRARY symbian_audio.lib
LIBRARY mediaclientaudiostream.lib
LIBRARY mediaclientaudioinputstream.lib
CAPABILITY NetworkServices LocalServices ReadUserData WriteUserData UserEnvironment
diff --git a/pjsip-apps/src/symsndtest/app_main.cpp b/pjsip-apps/src/symsndtest/app_main.cpp
index 597e7117..056cde10 100644
--- a/pjsip-apps/src/symsndtest/app_main.cpp
+++ b/pjsip-apps/src/symsndtest/app_main.cpp
@@ -49,7 +49,7 @@ static void log_writer(int level, const char *buf, unsigned len)
static wchar_t buf16[PJ_LOG_MAX_SIZE];
PJ_UNUSED_ARG(level);
-
+
pj_ansi_to_unicode(buf, len, buf16, PJ_ARRAY_SIZE(buf16));
TPtrC16 aBuf((const TUint16*)buf16, (TInt)len);
@@ -57,24 +57,24 @@ static void log_writer(int level, const char *buf, unsigned len)
}
/* perror util */
-static void app_perror(const char *title, pj_status_t status)
+static void app_perror(const char *title, pj_status_t status)
{
- char errmsg[PJ_ERR_MSG_SIZE];
+ char errmsg[PJ_ERR_MSG_SIZE];
pj_strerror(status, errmsg, sizeof(errmsg));
PJ_LOG(1,(THIS_FILE, "Error: %s: %s", title, errmsg));
}
/* Application init */
-static pj_status_t app_init()
+static pj_status_t app_init()
{
unsigned i, count;
pj_status_t status;
-
+
/* Redirect log */
pj_log_set_log_func((void (*)(int,const char*,int)) &log_writer);
pj_log_set_decor(PJ_LOG_HAS_NEWLINE);
pj_log_set_level(3);
-
+
/* Init pjlib */
status = pj_init();
if (status != PJ_SUCCESS) {
@@ -83,7 +83,7 @@ static pj_status_t app_init()
}
pj_caching_pool_init(&cp, NULL, 0);
-
+
/* Init sound subsystem */
status = pjmedia_snd_init(&cp.factory);
if (status != PJ_SUCCESS) {
@@ -92,16 +92,16 @@ static pj_status_t app_init()
pj_shutdown();
return status;
}
-
+
count = pjmedia_snd_get_dev_count();
PJ_LOG(3,(THIS_FILE, "Device count: %d", count));
for (i=0; i<count; ++i) {
const pjmedia_snd_dev_info *info;
-
+
info = pjmedia_snd_get_dev_info(i);
PJ_LOG(3, (THIS_FILE, "%d: %s %d/%d %dHz",
i, info->name, info->input_count, info->output_count,
- info->default_samples_per_sec));
+ info->default_samples_per_sec));
}
/* Create pool */
@@ -114,8 +114,8 @@ static pj_status_t app_init()
}
/* Init delay buffer */
- status = pjmedia_delay_buf_create(pool, THIS_FILE, CLOCK_RATE,
- SAMPLES_PER_FRAME, CHANNEL_COUNT,
+ status = pjmedia_delay_buf_create(pool, THIS_FILE, CLOCK_RATE,
+ SAMPLES_PER_FRAME, CHANNEL_COUNT,
0, 0, &delaybuf);
if (status != PJ_SUCCESS) {
app_perror("pjmedia_delay_buf_create()", status);
@@ -123,16 +123,16 @@ static pj_status_t app_init()
//pj_shutdown();
//return status;
}
-
+
return PJ_SUCCESS;
}
/* Sound capture callback */
-static pj_status_t rec_cb(void *user_data,
+static pj_status_t rec_cb(void *user_data,
pj_uint32_t timestamp,
void *input,
- unsigned size)
+ unsigned size)
{
PJ_UNUSED_ARG(user_data);
PJ_UNUSED_ARG(timestamp);
@@ -153,28 +153,28 @@ static pj_status_t rec_cb(void *user_data,
static pj_status_t play_cb(void *user_data,
pj_uint32_t timestamp,
void *output,
- unsigned size)
+ unsigned size)
{
PJ_UNUSED_ARG(user_data);
PJ_UNUSED_ARG(timestamp);
PJ_UNUSED_ARG(size);
-
+
pjmedia_delay_buf_get(delaybuf, (pj_int16_t*)output);
-
+
++play_cnt;
- return PJ_SUCCESS;
+ return PJ_SUCCESS;
}
/* Start sound */
-static pj_status_t snd_start(unsigned flag)
+static pj_status_t snd_start(unsigned flag)
{
pj_status_t status;
-
+
if (strm != NULL) {
app_perror("snd already open", PJ_EINVALIDOP);
return PJ_EINVALIDOP;
}
-
+
if (flag==PJMEDIA_DIR_CAPTURE_PLAYBACK)
status = pjmedia_snd_open(-1, -1, CLOCK_RATE, CHANNEL_COUNT,
SAMPLES_PER_FRAME, BITS_PER_SAMPLE,
@@ -187,7 +187,7 @@ static pj_status_t snd_start(unsigned flag)
status = pjmedia_snd_open_player(-1, CLOCK_RATE, CHANNEL_COUNT,
SAMPLES_PER_FRAME, BITS_PER_SAMPLE,
&play_cb, NULL, &strm);
-
+
if (status != PJ_SUCCESS) {
app_perror("snd open", status);
return status;
@@ -210,19 +210,23 @@ static pj_status_t snd_start(unsigned flag)
}
/* Stop sound */
-static pj_status_t snd_stop()
+static pj_status_t snd_stop()
{
pj_time_val now;
pj_status_t status;
-
+
if (strm == NULL) {
app_perror("snd not open", PJ_EINVALIDOP);
return PJ_EINVALIDOP;
}
-
+
+ status = pjmedia_snd_stream_stop(strm);
+ if (status != PJ_SUCCESS) {
+ app_perror("snd failed to stop", status);
+ }
status = pjmedia_snd_stream_close(strm);
strm = NULL;
-
+
pj_gettimeofday(&now);
PJ_TIME_VAL_SUB(now, t_start);
@@ -234,11 +238,11 @@ static pj_status_t snd_stop()
}
/* Shutdown application */
-static void app_fini()
+static void app_fini()
{
if (strm)
snd_stop();
-
+
pjmedia_snd_deinit();
pjmedia_delay_buf_destroy(delaybuf);
pj_pool_release(pool);
@@ -253,56 +257,55 @@ static void app_fini()
*/
#include <e32base.h>
-class ConsoleUI : public CActive
+class ConsoleUI : public CActive
{
public:
- ConsoleUI(CActiveSchedulerWait *asw, CConsoleBase *con);
+ ConsoleUI(CConsoleBase *con);
// Run console UI
void Run();
// Stop
void Stop();
-
+
protected:
// Cancel asynchronous read.
void DoCancel();
// Implementation: called when read has completed.
void RunL();
-
+
private:
- CActiveSchedulerWait *asw_;
CConsoleBase *con_;
};
-ConsoleUI::ConsoleUI(CActiveSchedulerWait *asw, CConsoleBase *con)
-: CActive(EPriorityHigh), asw_(asw), con_(con)
+ConsoleUI::ConsoleUI(CConsoleBase *con)
+: CActive(EPriorityUserInput), con_(con)
{
CActiveScheduler::Add(this);
}
// Run console UI
-void ConsoleUI::Run()
+void ConsoleUI::Run()
{
con_->Read(iStatus);
SetActive();
}
// Stop console UI
-void ConsoleUI::Stop()
+void ConsoleUI::Stop()
{
DoCancel();
}
// Cancel asynchronous read.
-void ConsoleUI::DoCancel()
+void ConsoleUI::DoCancel()
{
con_->ReadCancel();
}
-static void PrintMenu()
+static void PrintMenu()
{
PJ_LOG(3, (THIS_FILE, "\n\n"
"Menu:\n"
@@ -314,14 +317,15 @@ static void PrintMenu()
}
// Implementation: called when read has completed.
-void ConsoleUI::RunL()
+void ConsoleUI::RunL()
{
TKeyCode kc = con_->KeyCode();
pj_bool_t reschedule = PJ_TRUE;
-
+
switch (kc) {
case 'w':
- asw_->AsyncStop();
+ snd_stop();
+ CActiveScheduler::Stop();
reschedule = PJ_FALSE;
break;
case 'a':
@@ -343,30 +347,28 @@ void ConsoleUI::RunL()
}
PrintMenu();
-
+
if (reschedule)
Run();
}
////////////////////////////////////////////////////////////////////////////
-int app_main()
+int app_main()
{
if (app_init() != PJ_SUCCESS)
return -1;
-
+
// Run the UI
- CActiveSchedulerWait *asw = new CActiveSchedulerWait;
- ConsoleUI *con = new ConsoleUI(asw, console);
-
+ ConsoleUI *con = new ConsoleUI(console);
+
con->Run();
-
+
PrintMenu();
- asw->Start();
-
+ CActiveScheduler::Start();
+
delete con;
- delete asw;
-
+
app_fini();
return 0;
}
diff --git a/pjsip-apps/src/symsndtest/main_symbian.cpp b/pjsip-apps/src/symsndtest/main_symbian.cpp
index bc160bd6..a711f092 100644
--- a/pjsip-apps/src/symsndtest/main_symbian.cpp
+++ b/pjsip-apps/src/symsndtest/main_symbian.cpp
@@ -29,75 +29,12 @@
CConsoleBase* console;
// Needed by APS
-TPtrC APP_UID = _L("A000000D");
+TPtrC APP_UID = _L("A000000E");
int app_main();
////////////////////////////////////////////////////////////////////////////
-class MyTask : public CActive
-{
-public:
- static MyTask *NewL(CActiveSchedulerWait *asw);
- ~MyTask();
- void Start();
-
-protected:
- MyTask(CActiveSchedulerWait *asw);
- void ConstructL();
- virtual void RunL();
- virtual void DoCancel();
-
-private:
- RTimer timer_;
- CActiveSchedulerWait *asw_;
-};
-
-MyTask::MyTask(CActiveSchedulerWait *asw)
-: CActive(EPriorityNormal), asw_(asw)
-{
-}
-
-MyTask::~MyTask()
-{
- timer_.Close();
-}
-
-void MyTask::ConstructL()
-{
- timer_.CreateLocal();
- CActiveScheduler::Add(this);
-}
-
-MyTask *MyTask::NewL(CActiveSchedulerWait *asw)
-{
- MyTask *self = new (ELeave) MyTask(asw);
- CleanupStack::PushL(self);
-
- self->ConstructL();
-
- CleanupStack::Pop(self);
- return self;
-}
-
-void MyTask::Start()
-{
- timer_.After(iStatus, 0);
- SetActive();
-}
-
-void MyTask::RunL()
-{
- int rc = app_main();
- asw_->AsyncStop();
-}
-
-void MyTask::DoCancel()
-{
-
-}
-
-////////////////////////////////////////////////////////////////////////////
LOCAL_C void DoStartL()
{
@@ -105,19 +42,8 @@ LOCAL_C void DoStartL()
CleanupStack::PushL(scheduler);
CActiveScheduler::Install(scheduler);
- CActiveSchedulerWait *asw = new CActiveSchedulerWait;
- CleanupStack::PushL(asw);
-
- MyTask *task = MyTask::NewL(asw);
- task->Start();
-
- asw->Start();
-
- delete task;
-
- CleanupStack::Pop(asw);
- delete asw;
-
+ app_main();
+
CActiveScheduler::Install(NULL);
CleanupStack::Pop(scheduler);
delete scheduler;
@@ -142,13 +68,13 @@ GLDEF_C TInt E32Main()
TRAPD(startError, DoStartL());
- console->Printf(_L("[press any key to close]\n"));
- console->Getch();
-
+ //console->Printf(_L("[press any key to close]\n"));
+ //console->Getch();
+
delete console;
delete cleanup;
- CloseSTDLIB();
+ CloseSTDLIB();
// Mark end of heap usage, detect memory leaks
__UHEAP_MARKEND;