Commit b2dc80f2 authored by jehan's avatar jehan

add ref count to ms_init/uninit functions

parent 25d5fc4a
......@@ -39,10 +39,14 @@
</toolChain>
</folderInfo>
<sourceEntries>
<entry excluding="src/audiofilters|src/videofilters|src/base" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/>
<entry excluding="src/otherfilters|tester|src/utils|src/voip|src/audiofilters|src/videofilters|src/base" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/>
<entry flags="VALUE_WORKSPACE_PATH" kind="sourcePath" name="src/audiofilters"/>
<entry flags="VALUE_WORKSPACE_PATH" kind="sourcePath" name="src/base"/>
<entry flags="VALUE_WORKSPACE_PATH" kind="sourcePath" name="src/otherfilters"/>
<entry flags="VALUE_WORKSPACE_PATH" kind="sourcePath" name="src/utils"/>
<entry flags="VALUE_WORKSPACE_PATH" kind="sourcePath" name="src/videofilters"/>
<entry flags="VALUE_WORKSPACE_PATH" kind="sourcePath" name="src/voip"/>
<entry flags="VALUE_WORKSPACE_PATH" kind="sourcePath" name="tester"/>
</sourceEntries>
</configuration>
</storageModule>
......@@ -77,7 +81,7 @@
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
</scannerConfigBuildInfo>
<scannerConfigBuildInfo instanceId="0.176448098;0.176448098.;cdt.managedbuild.tool.gnu.c.compiler.macosx.base.1973640523;cdt.managedbuild.tool.gnu.c.compiler.input.1596178168">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
<autodiscovery enabled="false" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.make.core.GCCStandardMakePerFileProfile"/>
</scannerConfigBuildInfo>
</storageModule>
</cproject>
......@@ -300,7 +300,7 @@ AM_CPPFLAGS=\
-I$(top_srcdir)/src/voip \
-I$(top_srcdir)/src/audiofilters \
-I$(top_srcdir)/src/otherfilters \
-I$(top_srcdir)/src/videofilters
-I$(top_srcdir)/src/videofilters
AM_CFLAGS=\
$(STRICT_OPTIONS) \
......
......@@ -428,10 +428,18 @@ int ms_load_plugins(const char *dir){
#endif
return num;
}
static int ms_plugins_ref=0;
void ms_unload_plugins(){
#if defined(WIN32) && !defined(_WIN32_WCE)
MSList *elem;
MSList *elem;
#endif
if (--ms_plugins_ref >0 ) {
ms_message ("Skiping ms_unload_plugins, still [%i] ref",ms_plugins_ref);
return;
}
#if defined(WIN32) && !defined(_WIN32_WCE)
for(elem=ms_plugins_loaded_list;elem!=NULL;elem=elem->next)
{
......@@ -459,10 +467,17 @@ static void ms_android_log_handler(OrtpLogLevel lev, const char *fmt, va_list ar
}
#endif
static int ms_base_ref=0;
void ms_base_init(){
int i;
long num_cpu=1;
if (ms_base_ref++ >0 ) {
ms_message ("Skiping ms_base_init, because [%i] ref",ms_base_ref);
return;
}
#if defined(ENABLE_NLS)
bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
#endif
......@@ -495,11 +510,21 @@ void ms_base_init(){
}
void ms_base_exit(){
if (--ms_base_ref >0 ) {
ms_message ("Skiping ms_base_exit, still [%i] ref",ms_base_ref);
return;
}
ms_filter_unregister_all();
ms_unload_plugins();
}
void ms_plugins_init(void) {
if (ms_plugins_ref++ >0 ) {
ms_message ("Skiping ms_plugins_init, because [%i] ref",ms_plugins_ref);
return;
}
if (plugins_dir == NULL) {
#ifdef PACKAGE_PLUGINS_DIR
plugins_dir = ms_strdup(PACKAGE_PLUGINS_DIR);
......
......@@ -309,6 +309,8 @@ static int send_dtmf(MSFilter * f, uint32_t timestamp_start)
default:
ms_warning("Bad dtmf: %c.",d->dtmf);
d->skip = FALSE; /*reset dtmf*/
d->dtmf = 0;
return -1;
}
......
......@@ -217,11 +217,15 @@ static MSWebCamDesc * ms_web_cam_descs[]={
};
#endif
static int ms_voip_ref=0;
void ms_voip_init(){
MSSndCardManager *cm;
int i;
if (ms_voip_ref++ >0 ) {
ms_message ("Skiping ms_voip_init, because [%i] ref",ms_voip_ref);
return;
}
/* register builtin VoIP MSFilter's */
for (i=0;ms_voip_filter_descs[i]!=NULL;i++){
ms_filter_register(ms_voip_filter_descs[i]);
......@@ -261,6 +265,11 @@ void ms_voip_init(){
}
void ms_voip_exit(){
if (--ms_voip_ref >0 ) {
ms_message ("Skiping ms_voip_exit, still [%i] ref",ms_voip_ref);
return;
}
ms_snd_card_manager_destroy();
#ifdef VIDEO_ENABLED
ms_web_cam_manager_destroy();
......
......@@ -9,8 +9,12 @@ if BUILD_TESTS
noinst_PROGRAMS=mediastreamer2_tester
mediastreamer2_tester_SOURCES= \
mediastreamer2_tester.c mediastreamer2_tester.h mediastreamer2_tester_private.c mediastreamer2_tester_private.h \
mediastreamer2_basic_audio_tester.c mediastreamer2_sound_card_tester.c mediastreamer2_audio_stream_tester.c
mediastreamer2_tester.c mediastreamer2_tester.h \
mediastreamer2_tester_private.c mediastreamer2_tester_private.h \
mediastreamer2_basic_audio_tester.c \
mediastreamer2_sound_card_tester.c \
mediastreamer2_audio_stream_tester.c \
mediastreamer2_framework_tester.c
AM_CPPFLAGS=\
......@@ -21,6 +25,7 @@ AM_CPPFLAGS=\
-I$(top_srcdir)/src/audiofilters \
-I$(top_srcdir)/src/otherfilters \
-I$(top_srcdir)/src/videofilters \
-I$(top_srcdir)/src \
-I$(top_srcdir)/tester
LDADD=$(top_builddir)/src/libmediastreamer_base.la \
......
......@@ -288,6 +288,43 @@ static void adaptative_isac16_audio_stream() {
}
}
static void audio_stream_dtmf(int codec_payload, int initial_bitrate,int target_bw, int max_recv_rtcp_packet) {
// stream_manager_t * marielle = stream_manager_new();
// stream_manager_t * margaux = stream_manager_new();
// int pause_time=0;
//
// OrtpNetworkSimulatorParams params={0};
// params.enabled=TRUE;
// params.loss_rate=0;
// params.max_bandwidth=target_bw;
// params.max_buffer_size=initial_bitrate;
// float recv_send_bw_ratio;
// int rtcp_interval = 1000;
// float marielle_send_bw;
//
// media_stream_enable_adaptive_bitrate_control(&marielle->stream->ms,TRUE);
//
//
// stream_manager_start(marielle,codec_payload, margaux->local_rtp,initial_bitrate,HELLO_16K_1S_FILE,NULL);
// ms_filter_call_method(marielle->stream->soundread,MS_FILE_PLAYER_LOOP,&pause_time);
//
// unlink("blibi.wav");
// stream_manager_start(margaux,codec_payload, marielle->local_rtp,-1,NULL,"blibi.wav");
// rtp_session_enable_network_simulation(margaux->stream->ms.session,&params);
// rtp_session_set_rtcp_report_interval(margaux->stream->ms.session, rtcp_interval);
//
// wait_for_until(&marielle->stream->ms,&margaux->stream->ms,&marielle->stats.number_of_EndOfFile,10,rtcp_interval*max_recv_rtcp_packet);
//
// marielle_send_bw=media_stream_get_up_bw(&marielle->stream->ms);
// recv_send_bw_ratio=params.max_bandwidth/marielle_send_bw;
// ms_message("marielle sent bw= [%f] , target was [%f] recv/send [%f]",marielle_send_bw,params.max_bandwidth,recv_send_bw_ratio);
// CU_ASSERT_TRUE(recv_send_bw_ratio>0.9);
//
// stream_manager_delete(marielle);
// stream_manager_delete(margaux);
}
static test_t tests[] = {
{ "Basic audio stream", basic_audio_stream },
......
......@@ -72,6 +72,9 @@ static void dtmfgen_tonedet(void) {
ms_tester_tone_generation_and_detection_loop();
/*try unreconized DTMF*/
CU_ASSERT_NOT_EQUAL(ms_filter_call_method(ms_tester_dtmfgen, MS_DTMF_GEN_PLAY, "F"),0);
ms_ticker_detach(ms_tester_ticker, ms_tester_voidsource);
ms_connection_helper_start(&h);
ms_connection_helper_unlink(&h, ms_tester_voidsource, -1, 0);
......
/*
mediastreamer2 library - modular sound and video processing and streaming
Copyright (C) 2006-2013 Belledonne Communications, Grenoble
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 "mediastreamer-config.h"
#include "mediastreamer2/mediastream.h"
#include "mediastreamer2/dtmfgen.h"
#include "mediastreamer2/msfileplayer.h"
#include "mediastreamer2/msfilerec.h"
#include "mediastreamer2/msrtp.h"
#include "mediastreamer2/mstonedetector.h"
#include "private.h"
#include "mediastreamer2_tester.h"
#include "mediastreamer2_tester_private.h"
#include "basedescs.h"
#include "voipdescs.h"
#include <stdio.h>
#include "CUnit/Basic.h"
#ifdef _MSC_VER
#define unlink _unlink
#endif
static int tester_init(void) {
/* ms_init();
ms_filter_enable_statistics(TRUE);
ortp_init();*/
return 0;
}
static int tester_cleanup(void) {
/* ms_exit();*/
return 0;
}
extern MSFilterDesc ms_alaw_dec_desc;
static void filter_register_tester(void) {
ms_init();
ms_init();
CU_ASSERT_PTR_NOT_NULL(ms_filter_lookup_by_name(ms_void_source_desc.name));
MSFilter* filter= ms_filter_create_decoder(ms_alaw_dec_desc.enc_fmt);
CU_ASSERT_PTR_NOT_NULL(filter);
ms_free(filter);
ms_exit();
CU_ASSERT_PTR_NOT_NULL(ms_filter_lookup_by_name(ms_void_source_desc.name));
filter= ms_filter_create_decoder(ms_alaw_dec_desc.enc_fmt);
CU_ASSERT_PTR_NOT_NULL(filter);
ms_free(filter);
ms_exit();
CU_ASSERT_PTR_NULL(ms_filter_lookup_by_name(ms_void_source_desc.name));
filter= ms_filter_create_decoder(ms_alaw_dec_desc.enc_fmt);
CU_ASSERT_PTR_NULL(filter);
}
static test_t tests[] = {
{ "Multiple ms_voip_init", filter_register_tester }
};
test_suite_t framework_test_suite = {
"Framework",
tester_init,
tester_cleanup,
sizeof(tests) / sizeof(tests[0]),
tests
};
......@@ -102,6 +102,7 @@ void mediastreamer2_tester_init(void) {
add_test_suite(&basic_audio_test_suite);
add_test_suite(&sound_card_test_suite);
add_test_suite(&audio_stream_test_suite);
add_test_suite(&framework_test_suite);
}
void mediastreamer2_tester_uninit(void) {
......
......@@ -48,6 +48,7 @@ extern "C" {
extern test_suite_t basic_audio_test_suite;
extern test_suite_t sound_card_test_suite;
extern test_suite_t audio_stream_test_suite;
extern test_suite_t framework_test_suite;
extern int mediastreamer2_tester_nb_test_suites(void);
......
......@@ -192,9 +192,9 @@ void ms_tester_tone_generation_and_detection_loop(void) {
for (i = 0; i < (sizeof(tone_definition) / sizeof(tone_definition[0])); i++) {
ms_tester_tone_detected = FALSE;
ms_filter_call_method(ms_tester_tonedet, MS_TONE_DETECTOR_CLEAR_SCANS, NULL);
ms_filter_call_method(ms_tester_tonedet, MS_TONE_DETECTOR_ADD_SCAN, &tone_definition[i].expected_tone);
ms_filter_call_method(ms_tester_dtmfgen, MS_DTMF_GEN_PLAY_CUSTOM, &tone_definition[i].generated_tone);
CU_ASSERT_EQUAL(0,ms_filter_call_method(ms_tester_tonedet, MS_TONE_DETECTOR_CLEAR_SCANS, NULL));
CU_ASSERT_EQUAL(0,ms_filter_call_method(ms_tester_tonedet, MS_TONE_DETECTOR_ADD_SCAN, &tone_definition[i].expected_tone));
CU_ASSERT_EQUAL(0,ms_filter_call_method(ms_tester_dtmfgen, MS_DTMF_GEN_PLAY_CUSTOM, &tone_definition[i].generated_tone));
ms_sleep(1);
CU_ASSERT_EQUAL(ms_tester_tone_detected, TRUE);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment