From 16c9aaba16eb52933d21a3e8be876bf0cbaf7dc1 Mon Sep 17 00:00:00 2001 From: Benny Prijono Date: Thu, 16 Jul 2009 11:37:15 +0000 Subject: More ticket #920: fix latency calculation not able to calculate latency higher than 500ms and added copyright info in source files git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@2836 74dad513-b988-da41-8d7b-12977e46ad98 --- pjsip-apps/src/pjsystest/gui.h | 28 ++++++++++++++++++++----- pjsip-apps/src/pjsystest/main_console.c | 28 ++++++++++++++++++++----- pjsip-apps/src/pjsystest/main_wm.c | 31 +++++++++++++++++++++------- pjsip-apps/src/pjsystest/systest.c | 36 +++++++++++++++++++++++++++++---- pjsip-apps/src/pjsystest/systest.h | 20 ++++++++++++++++++ 5 files changed, 122 insertions(+), 21 deletions(-) (limited to 'pjsip-apps/src') diff --git a/pjsip-apps/src/pjsystest/gui.h b/pjsip-apps/src/pjsystest/gui.h index 0ae1ba36..5f056fc0 100644 --- a/pjsip-apps/src/pjsystest/gui.h +++ b/pjsip-apps/src/pjsystest/gui.h @@ -1,3 +1,21 @@ +/* $Id$ */ +/* + * Copyright (C) 2008-2009 Teluu Inc. (http://www.teluu.com) + * + * 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 + */ #ifndef __GUI_H__ #define __GUI_H__ @@ -33,19 +51,19 @@ enum gui_key }; /* Initialize GUI with the menus and stuff */ -PJ_DECL(pj_status_t) gui_init(gui_menu *menu); +pj_status_t gui_init(gui_menu *menu); /* Run GUI main loop */ -PJ_DECL(pj_status_t) gui_start(gui_menu *menu); +pj_status_t gui_start(gui_menu *menu); /* Signal GUI mainloop to stop */ -PJ_DECL(void) gui_destroy(void); +void gui_destroy(void); /* AUX: display messagebox */ -PJ_DECL(enum gui_key) gui_msgbox(const char *title, const char *message, enum gui_flag flag); +enum gui_key gui_msgbox(const char *title, const char *message, enum gui_flag flag); /* AUX: sleep */ -PJ_DECL(void) gui_sleep(unsigned sec); +void gui_sleep(unsigned sec); PJ_END_DECL diff --git a/pjsip-apps/src/pjsystest/main_console.c b/pjsip-apps/src/pjsystest/main_console.c index e39654a8..5778a65d 100644 --- a/pjsip-apps/src/pjsystest/main_console.c +++ b/pjsip-apps/src/pjsystest/main_console.c @@ -1,3 +1,21 @@ +/* $Id$ */ +/* + * Copyright (C) 2008-2009 Teluu Inc. (http://www.teluu.com) + * + * 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 "systest.h" #include "gui.h" #include @@ -5,7 +23,7 @@ static pj_bool_t console_quit; -PJ_DEF(enum gui_key) gui_msgbox(const char *title, const char *message, enum gui_flag flag) +enum gui_key gui_msgbox(const char *title, const char *message, enum gui_flag flag) { puts(title); puts(message); @@ -30,7 +48,7 @@ PJ_DEF(enum gui_key) gui_msgbox(const char *title, const char *message, enum gui } } -PJ_DEF(pj_status_t) gui_init(gui_menu *menu) +pj_status_t gui_init(gui_menu *menu) { PJ_UNUSED_ARG(menu); return PJ_SUCCESS; @@ -57,7 +75,7 @@ static void print_menu(const char *indent, char *menu_id, gui_menu *menu) } } -PJ_DEF(pj_status_t) gui_start(gui_menu *menu) +pj_status_t gui_start(gui_menu *menu) { while (!console_quit) { unsigned i; @@ -103,12 +121,12 @@ PJ_DEF(pj_status_t) gui_start(gui_menu *menu) return PJ_SUCCESS; } -PJ_DEF(void) gui_destroy(void) +void gui_destroy(void) { console_quit = PJ_TRUE; } -PJ_DEF(void) gui_sleep(unsigned sec) +void gui_sleep(unsigned sec) { pj_thread_sleep(sec * 1000); } diff --git a/pjsip-apps/src/pjsystest/main_wm.c b/pjsip-apps/src/pjsystest/main_wm.c index 4956b4af..374e84d6 100644 --- a/pjsip-apps/src/pjsystest/main_wm.c +++ b/pjsip-apps/src/pjsystest/main_wm.c @@ -1,3 +1,21 @@ +/* $Id$ */ +/* + * Copyright (C) 2008-2009 Teluu Inc. (http://www.teluu.com) + * + * 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 "gui.h" #include "systest.h" #include @@ -10,7 +28,7 @@ #include #define MAINWINDOWCLASS TEXT("SysTestDlg") -#define MAINWINDOWTITLE TEXT("SysTest") +#define MAINWINDOWTITLE TEXT("PJSYSTEST") typedef struct menu_handler_t { UINT id; @@ -187,13 +205,12 @@ LRESULT CALLBACK DialogProc(const HWND hWnd, /* === API === */ -PJ_DEF(pj_status_t) gui_init(gui_menu *menu) +pj_status_t gui_init(gui_menu *menu) { WNDCLASS wc; HWND hWnd = NULL; RECT r; DWORD dwStyle; - unsigned log_decor; pj_status_t status = PJ_SUCCESS; @@ -334,7 +351,7 @@ static pj_status_t gui_update_menu(gui_menu *menu) return PJ_SUCCESS; } -PJ_DEF(enum gui_key) gui_msgbox(const char *title, const char *message, enum gui_flag flag) +enum gui_key gui_msgbox(const char *title, const char *message, enum gui_flag flag) { wchar_t buf_title[64]; wchar_t buf_msg[512]; @@ -370,12 +387,12 @@ PJ_DEF(enum gui_key) gui_msgbox(const char *title, const char *message, enum gui } } -PJ_DEF(void) gui_sleep(unsigned sec) +void gui_sleep(unsigned sec) { pj_thread_sleep(sec * 1000); } -PJ_DEF(pj_status_t) gui_start(gui_menu *menu) +pj_status_t gui_start(gui_menu *menu) { MSG msg; @@ -389,7 +406,7 @@ PJ_DEF(pj_status_t) gui_start(gui_menu *menu) return (msg.wParam); } -PJ_DEF(void) gui_destroy(void) +void gui_destroy(void) { if (g_hWndMain) { DestroyWindow(g_hWndMain); diff --git a/pjsip-apps/src/pjsystest/systest.c b/pjsip-apps/src/pjsystest/systest.c index 021403c2..01401848 100644 --- a/pjsip-apps/src/pjsystest/systest.c +++ b/pjsip-apps/src/pjsystest/systest.c @@ -1,3 +1,21 @@ +/* $Id$ */ +/* + * Copyright (C) 2008-2009 Teluu Inc. (http://www.teluu.com) + * + * 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 "systest.h" #include "gui.h" @@ -677,7 +695,11 @@ static int calculate_latency(pj_pool_t *pool, pjmedia_port *wav, *lat_max = lat; /* Advance next loop */ - start_pos += wav->info.clock_rate; + if (start_pos == 0) { + start_pos = max_signal_pos + wav->info.clock_rate * 9 / 10; + } else { + start_pos += wav->info.clock_rate; + } } return 0; @@ -742,8 +764,8 @@ static void systest_latency_test(void) /* Setup the test */ //status = pjsua_conf_connect(0, 0); - status = pjsua_conf_connect(0, rec_slot); status = pjsua_conf_connect(play_slot, 0); + status = pjsua_conf_connect(0, rec_slot); status = pjsua_conf_connect(play_slot, rec_slot); @@ -753,8 +775,8 @@ static void systest_latency_test(void) /* Done with the test */ //status = pjsua_conf_disconnect(0, 0); status = pjsua_conf_disconnect(play_slot, rec_slot); - status = pjsua_conf_disconnect(play_slot, 0); status = pjsua_conf_disconnect(0, rec_slot); + status = pjsua_conf_disconnect(play_slot, 0); pjsua_recorder_destroy(rec_id); rec_id = PJSUA_INVALID_ID; @@ -773,7 +795,9 @@ static void systest_latency_test(void) if (status != PJ_SUCCESS) goto on_return; - status = pjsua_conf_connect(pjsua_player_get_conf_port(play_id), 0); + play_slot = pjsua_player_get_conf_port(play_id); + + status = pjsua_conf_connect(play_slot, 0); if (status != PJ_SUCCESS) goto on_return; @@ -781,6 +805,10 @@ static void systest_latency_test(void) "The captured audio is being played back now. " "Can you hear the 'tock' echo?", WITH_YESNO); + + pjsua_player_destroy(play_id); + play_id = PJSUA_INVALID_ID; + if (key != KEY_YES) goto on_return; diff --git a/pjsip-apps/src/pjsystest/systest.h b/pjsip-apps/src/pjsystest/systest.h index 487944da..1b802fe7 100644 --- a/pjsip-apps/src/pjsystest/systest.h +++ b/pjsip-apps/src/pjsystest/systest.h @@ -1,3 +1,21 @@ +/* $Id$ */ +/* + * Copyright (C) 2008-2009 Teluu Inc. (http://www.teluu.com) + * + * 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 + */ #ifndef __SYSTEST_H__ #define __SYSTEST_H__ @@ -32,11 +50,13 @@ extern "C" { #endif +/* API, to be called by main() */ int systest_init(void); int systest_run(void); void systest_save_result(const char *filename); void systest_deinit(void); +/* Test item is used to record the test result */ typedef struct test_item_t { char title[80]; -- cgit v1.2.3