summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenny Prijono <bennylp@teluu.com>2009-11-08 03:35:41 +0000
committerBenny Prijono <bennylp@teluu.com>2009-11-08 03:35:41 +0000
commit8bb8512eb7e6e0883964c1f58750d80dd90c6e2d (patch)
treefa0d240e5253f82b3f5ef35eed4b0affc165c97a
parent5ad076e71b93972ac204bfae7749695f04e59ab0 (diff)
Misc (#951): some fixes for pjsystest application:
- added the missing build target on the Makefile build system - added alternative search path for the WAV files git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@2991 74dad513-b988-da41-8d7b-12977e46ad98
-rw-r--r--pjsip-apps/build/Makefile17
-rw-r--r--pjsip-apps/src/pjsystest/systest.c39
-rw-r--r--pjsip-apps/src/pjsystest/systest.h2
3 files changed, 48 insertions, 10 deletions
diff --git a/pjsip-apps/build/Makefile b/pjsip-apps/build/Makefile
index 56e540fb..5c1684fa 100644
--- a/pjsip-apps/build/Makefile
+++ b/pjsip-apps/build/Makefile
@@ -39,12 +39,23 @@ export PJSUA_LDFLAGS += $(APP_LDFLAGS) $(APP_LDLIBS) $(LDFLAGS)
export PJSUA_EXE:=../bin/pjsua-$(TARGET_NAME)$(HOST_EXE)
+###############################################################################
+# Defines for building pjsystest
+#
+export PJSYSTEST_SRCDIR = ../src/pjsystest
+export PJSYSTEST_OBJS += $(OS_OBJS) $(M_OBJS) $(CC_OBJS) $(HOST_OBJS) \
+ systest.o main_console.o
+export PJSYSTEST_CFLAGS += $(_CFLAGS)
+export PJSYSTEST_LDFLAGS += $(APP_LDFLAGS) $(APP_LDLIBS) $(LDFLAGS)
+export PJSYSTEST_EXE:=../bin/pjsystest-$(TARGET_NAME)$(HOST_EXE)
+
+
export CC_OUT CC AR RANLIB HOST_MV HOST_RM HOST_RMDIR HOST_MKDIR OBJEXT LD LDOUT
###############################################################################
# Main entry
#
#
-TARGETS := pjsua samples
+TARGETS := pjsua pjsystest samples
.PHONY: $(TARGETS)
@@ -60,6 +71,9 @@ distclean: realclean
pjsua:
$(MAKE) -f $(RULES_MAK) APP=PJSUA app=pjsua $(PJSUA_EXE)
+pjsystest:
+ $(MAKE) -f $(RULES_MAK) APP=PJSYSTEST app=pjsystest $(PJSYSTEST_EXE)
+
samples:
$(MAKE) -f Samples.mak
@@ -72,6 +86,7 @@ clean depend realclean:
$(MAKE) -f Samples.mak $@
@if test "$@" = "depend"; then \
echo '$(PJSUA_EXE): $(APP_LIB_FILES)' >> .pjsua-$(TARGET_NAME).depend; \
+ echo '$(PJSYSTEST_EXE): $(APP_LIB_FILES)' >> .pjsystest-$(TARGET_NAME).depend; \
fi
diff --git a/pjsip-apps/src/pjsystest/systest.c b/pjsip-apps/src/pjsystest/systest.c
index 81c8d638..678b2c0c 100644
--- a/pjsip-apps/src/pjsystest/systest.c
+++ b/pjsip-apps/src/pjsystest/systest.c
@@ -114,7 +114,7 @@ static void systest_perror(const char *title, pj_status_t status)
errmsg[0] = '\0';
strcpy(themsg, title);
- strncat(themsg, errmsg, sizeof(themsg));
+ strncat(themsg, errmsg, sizeof(themsg)-1);
themsg[sizeof(themsg)-1] = '\0';
gui_msgbox("Error", themsg, WITH_OK);
@@ -245,16 +245,32 @@ on_return:
return;
}
+/* Util: create file player, each time trying different paths until we get
+ * the file.
+ */
+static pj_status_t create_player(unsigned path_cnt, const char *paths[],
+ pjsua_player_id *p_id)
+{
+ pj_str_t name;
+ pj_status_t status = PJ_ENOTFOUND;
+ unsigned i;
+
+ for (i=0; i<path_cnt; ++i) {
+ status = pjsua_player_create(pj_cstr(&name, paths[i]), 0, p_id);
+ if (status == PJ_SUCCESS)
+ return PJ_SUCCESS;
+ }
+ return status;
+}
/*****************************************************************************
* test: play WAV file
*/
-static void systest_play_wav(const char *filename)
+static void systest_play_wav(unsigned path_cnt, const char *paths[])
{
pjsua_player_id play_id = PJSUA_INVALID_ID;
enum gui_key key;
test_item_t *ti;
- pj_str_t name;
const char *title = "WAV File Playback Test";
pj_status_t status;
@@ -268,7 +284,7 @@ static void systest_play_wav(const char *filename)
"impairments such as stutter. Let this test run "
"for a while to make sure that everything is okay."
" Press OK to start, CANCEL to skip",
- filename);
+ paths[0]);
key = gui_msgbox(title, textbuf,
WITH_OKCANCEL);
@@ -280,7 +296,7 @@ static void systest_play_wav(const char *filename)
PJ_LOG(3,(THIS_FILE, "Running %s", title));
/* WAV port */
- status = pjsua_player_create(pj_cstr(&name, filename), 0, &play_id);
+ status = create_player(path_cnt, paths, &play_id);
if (status != PJ_SUCCESS)
goto on_return;
@@ -313,12 +329,16 @@ on_return:
static void systest_play_wav1(void)
{
- systest_play_wav(WAV_PLAYBACK_PATH);
+ const char *paths[] = { WAV_PLAYBACK_PATH,
+ ALT_PATH1 WAV_PLAYBACK_PATH };
+ systest_play_wav(PJ_ARRAY_SIZE(paths), paths);
}
static void systest_play_wav2(void)
{
- systest_play_wav(WAV_TOCK8_PATH);
+ const char *paths[] = { WAV_TOCK8_PATH,
+ ALT_PATH1 WAV_TOCK8_PATH};
+ systest_play_wav(PJ_ARRAY_SIZE(paths), paths);
}
@@ -712,7 +732,7 @@ static int calculate_latency(pj_pool_t *pool, pjmedia_port *wav,
static void systest_latency_test(void)
{
- const pj_str_t ref_wav_file = pj_str(WAV_TOCK8_PATH);
+ const char *ref_wav_paths[] = { WAV_TOCK8_PATH, ALT_PATH1 WAV_TOCK8_PATH };
const pj_str_t rec_wav_file = pj_str(WAV_LATENCY_OUT_PATH);
pjsua_player_id play_id = PJSUA_INVALID_ID;
pjsua_conf_port_id play_slot = PJSUA_INVALID_ID;
@@ -754,7 +774,8 @@ static void systest_latency_test(void)
PJ_LOG(3,(THIS_FILE, "Running %s", title));
- status = pjsua_player_create(&ref_wav_file, 0, &play_id);
+ status = create_player(PJ_ARRAY_SIZE(ref_wav_paths), ref_wav_paths,
+ &play_id);
if (status != PJ_SUCCESS)
goto on_return;
diff --git a/pjsip-apps/src/pjsystest/systest.h b/pjsip-apps/src/pjsystest/systest.h
index f5043be2..d2b7ed1f 100644
--- a/pjsip-apps/src/pjsystest/systest.h
+++ b/pjsip-apps/src/pjsystest/systest.h
@@ -53,6 +53,7 @@
#define WAV_REC_OUT_PATH "\\PJSYSTEST_TESTREC.WAV"
#define WAV_TOCK8_PATH "\\Program Files\\pjsystest\\tock8.WAV"
#define WAV_LATENCY_OUT_PATH "\\PJSYSTEST_LATREC.WAV"
+ #define ALT_PATH1 ""
#else
#define LOG_OUT_PATH "PJSYSTEST.LOG"
#define RESULT_OUT_PATH "PJSYSTEST_RESULT.TXT"
@@ -60,6 +61,7 @@
#define WAV_REC_OUT_PATH "PJSYSTEST_TESTREC.WAV"
#define WAV_TOCK8_PATH "tock8.wav"
#define WAV_LATENCY_OUT_PATH "PJSYSTEST_LATREC.WAV"
+ #define ALT_PATH1 "../../tests/pjsua/wavs/"
#endif
#ifdef __cplusplus