Commit 2e8c945a authored by Sandrine Avakian's avatar Sandrine Avakian

Removing static MSWebCamManager. There is now manager for webcam and one for sound

 accessible from the MSFactory.
Adding MSWebCamManager* in MSFactory.
Adding MSFactory to MSWebCamManager* and pointer to manager in MSWebCam.
Using ms_factory_wbc_amanger or snd_manager get  to get pointers to the managers.
Using ms_factory_create to create a new factory and initialize it
(ticals ms_factory_new and ms_factory_init plugins and voip).
parent 68d3b502
......@@ -43,7 +43,9 @@ struct _MSFactory{
bool_t statistics_enabled;
bool_t voip_initd;
int ref_count;
int managers_ref;
struct _MSSndCardManager* sndcardmanager;
struct _MSWebCamManager* wbcmanager;
};
typedef struct _MSFactory MSFactory;
......@@ -88,6 +90,8 @@ MS2_PUBLIC void ms_factory_destroy(MSFactory *factory);
**/
MS2_PUBLIC MSFactory* ms_factory_exit(MSFactory* factory);
MS2_PUBLIC MSFactory* ms_factory_create(MSFactory* f);
MS2_PUBLIC struct _MSSndCardManager* ms_factory_get_snd_manager(MSFactory *f);
......
......@@ -39,6 +39,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
struct _MSWebCamManager{
MSFactory* factory;
MSList *cams;
MSList *descs;
};
......@@ -74,6 +75,7 @@ struct _MSWebCamDesc{
typedef struct _MSWebCamDesc MSWebCamDesc;
struct _MSWebCam{
MSWebCamManager* wbcmanager;
MSWebCamDesc *desc;
char *name;
char *id;
......@@ -95,13 +97,17 @@ extern "C"{
*
* Returns: MSWebCamManager if successfull, NULL otherwise.
*/
MS2_PUBLIC MSWebCamManager * ms_web_cam_manager_get(void);
MS2_PUBLIC MSWebCamManager * ms_web_cam_manager_get(MSWebCamManager *scm);
MS2_PUBLIC MSFactory * ms_web_cam_factory_get(MSWebCam *c);
MS2_PUBLIC MSWebCamManager* ms_factory_get_wbc_manager(MSFactory* f);
/**
* Destroy the webcam manager object.
*
*/
MS2_PUBLIC void ms_web_cam_manager_destroy(void);
MS2_PUBLIC void ms_web_cam_manager_destroy(MSWebCamManager* scm);
/**
* Retreive a webcam object based on its name.
......@@ -139,7 +145,9 @@ MS2_PUBLIC const MSList * ms_web_cam_manager_get_list(MSWebCamManager *m);
*
*/
MS2_PUBLIC void ms_web_cam_manager_add_cam(MSWebCamManager *m, MSWebCam *c);
MS2_PUBLIC void ms_web_cam_set_manager(MSWebCamManager*m, MSWebCam *c);
/**
* Add a webcam object on top of list of the webcam manager's list.
*
......
......@@ -111,15 +111,17 @@ const MSList * ms_snd_card_manager_get_list(MSSndCardManager *m){
return m->cards;
}
void ms_snd_card_set_manager(MSSndCardManager*m, MSSndCard *c){
c->sndcardmanager = m;
}
void ms_snd_card_manager_add_card(MSSndCardManager *m, MSSndCard *c){
ms_snd_card_set_manager(m,c);
ms_message("Card '%s' added",ms_snd_card_get_string_id(c));
m->cards=ms_list_append(m->cards,c);
}
void ms_snd_card_set_manager(MSSndCardManager*m, MSSndCard *c){
c->sndcardmanager = m;
}
void ms_snd_card_manager_prepend_cards(MSSndCardManager *m, MSList *l) {
MSList *elem;
MSList *lcopy = ms_list_copy(l);
......
......@@ -24,14 +24,15 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "mediastreamer2/mswebcam.h"
#include "mediastreamer2/msfilter.h"
static MSWebCamManager *scm=NULL;
//static MSWebCamManager *scm=NULL;
static MSWebCamManager * create_manager(void){
MSWebCamManager *obj=(MSWebCamManager *)ms_new0(MSWebCamManager,1);
obj->factory = NULL;
return obj;
}
void ms_web_cam_manager_destroy(void){
void ms_web_cam_manager_destroy(MSWebCamManager* scm){
if (scm!=NULL){
ms_list_for_each(scm->cams,(void (*)(void*))ms_web_cam_destroy);
ms_list_free(scm->cams);
......@@ -41,11 +42,20 @@ void ms_web_cam_manager_destroy(void){
scm=NULL;
}
MSWebCamManager * ms_web_cam_manager_get(void){
MSWebCamManager * ms_web_cam_manager_get(MSWebCamManager* scm){
if (scm==NULL) scm=create_manager();
return scm;
}
MSFactory * ms_web_cam_factory_get(MSWebCam *c){
return (ms_web_cam_manager_get(c->wbcmanager))->factory;
}
MSWebCamManager* ms_factory_get_wbc_manager(MSFactory* f){
if(f == NULL) return create_manager();
return ms_web_cam_manager_get(f->wbcmanager);
}
MSWebCam * ms_web_cam_manager_get_cam(MSWebCamManager *m, const char *id){
MSList *elem;
for (elem=m->cams;elem!=NULL;elem=elem->next){
......@@ -67,11 +77,17 @@ const MSList * ms_web_cam_manager_get_list(MSWebCamManager *m){
return m->cams;
}
void ms_web_cam_set_manager(MSWebCamManager*m, MSWebCam *c){
c->wbcmanager = m;
}
void ms_web_cam_manager_add_cam(MSWebCamManager *m, MSWebCam *c){
ms_web_cam_set_manager(m,c);
ms_message("Webcam %s added",ms_web_cam_get_string_id(c));
m->cams=ms_list_append(m->cams,c);
}
void ms_web_cam_manager_prepend_cam(MSWebCamManager *m, MSWebCam *c){
ms_message("Webcam %s prepended",ms_web_cam_get_string_id(c));
m->cams=ms_list_prepend(m->cams,c);
......
......@@ -258,7 +258,7 @@ void ms_voip_init(){
ms_factory_init_voip(ms_factory_get_fallback());
}
static int managers_ref=0;
//static int managers_ref=0;
void ms_factory_init_voip(MSFactory *obj){
MSSndCardManager *cm;
......@@ -271,7 +271,7 @@ void ms_factory_init_voip(MSFactory *obj){
ms_factory_register_filter(obj,ms_voip_filter_descs[i]);
}
if (managers_ref == 0){
if (obj->managers_ref == 0){
cm=ms_snd_card_manager_get(obj->sndcardmanager);
if (cm->descs==NULL){
ms_message("Registering all soundcard handlers");
......@@ -285,8 +285,10 @@ void ms_factory_init_voip(MSFactory *obj){
#ifdef VIDEO_ENABLED
{
MSWebCamManager *wm;
wm=ms_web_cam_manager_get();
wm=ms_web_cam_manager_get(obj->wbcmanager);
if (wm->descs==NULL){
wm->factory = obj;
obj->wbcmanager = wm;
ms_message("Registering all webcam handlers");
for (i=0;ms_web_cam_descs[i]!=NULL;i++){
ms_web_cam_manager_register_desc(wm,ms_web_cam_descs[i]);
......@@ -295,7 +297,7 @@ void ms_factory_init_voip(MSFactory *obj){
}
#endif
}
managers_ref++;
obj->managers_ref++;
#ifdef VIDEO_ENABLED
{
MSVideoPresetsManager *vpm = ms_video_presets_manager_new(obj);
......@@ -324,11 +326,11 @@ void ms_factory_init_voip(MSFactory *obj){
void ms_factory_uninit_voip(MSFactory *obj){
ms_srtp_shutdown();
managers_ref--;
if (managers_ref==0){
obj->managers_ref--;
if (obj->managers_ref==0){
ms_snd_card_manager_destroy(obj->sndcardmanager);
#ifdef VIDEO_ENABLED
ms_web_cam_manager_destroy();
ms_web_cam_manager_destroy(obj->wbcmanager);
#endif
if (obj->voip_initd){
#ifdef VIDEO_ENABLED
......@@ -340,7 +342,16 @@ void ms_factory_uninit_voip(MSFactory *obj){
}
}
MSFactory* ms_factory_create(MSFactory* f){
if (f == NULL){
f = ms_factory_new();
}
ms_factory_init_voip(f);
ms_factory_init_plugins(f);
return f;
}
MSFactory* ms_factory_exit(MSFactory* factory){
ms_factory_uninit_voip(factory);
factory->ref_count--;
......
......@@ -676,7 +676,7 @@ int video_stream_start (VideoStream *stream, RtpProfile *profile, const char *re
const char *rem_rtcp_ip, int rem_rtcp_port, int payload, int jitt_comp, MSWebCam *cam){
MSMediaStreamIO io = MS_MEDIA_STREAM_IO_INITIALIZER;
if (cam == NULL){
cam = ms_web_cam_manager_get_default_cam( ms_web_cam_manager_get() );
cam = ms_web_cam_manager_get_default_cam( cam->wbcmanager);
}
io.input.type = MSResourceCamera;
io.input.camera = cam;
......
......@@ -41,15 +41,15 @@ static RtpProfile rtp_profile;
#define EDGE_BW 10
#define THIRDGENERATION_BW 200
static MSFactory *factory;
static MSFactory *_factory = NULL;
static int tester_before_all(void) {
//ms_init();
factory = ms_factory_new();
ms_factory_init_voip(factory);
ms_factory_init_plugins(factory);
_factory = ms_factory_new();
ms_factory_init_voip(_factory);
ms_factory_init_plugins(_factory);
//ms_filter_enable_statistics(TRUE);
ms_factory_enable_statistics(factory, TRUE);
ms_factory_enable_statistics(_factory, TRUE);
ortp_init();
rtp_profile_set_payload (&rtp_profile,0,&payload_type_pcmu8000);
rtp_profile_set_payload (&rtp_profile,OPUS_PAYLOAD_TYPE,&payload_type_opus);
......@@ -67,7 +67,7 @@ static int tester_after_all(void) {
ortp_exit();
//ms_exit();
factory = ms_factory_exit(factory);
_factory = ms_factory_exit(_factory);
rtp_profile_clear_all(&rtp_profile);
return 0;
}
......@@ -104,10 +104,10 @@ stream_manager_t * stream_manager_new(MSFormatType type) {
mgr->user_data = 0;
if (mgr->type==MSAudio){
mgr->audio_stream=audio_stream_new (mgr->local_rtp, mgr->local_rtcp,FALSE, factory);
mgr->audio_stream=audio_stream_new (mgr->local_rtp, mgr->local_rtcp,FALSE, _factory);
}else{
#if VIDEO_ENABLED
mgr->video_stream=video_stream_new (mgr->local_rtp, mgr->local_rtcp,FALSE, factory);
mgr->video_stream=video_stream_new (mgr->local_rtp, mgr->local_rtcp,FALSE, _factory);
#else
ms_fatal("Unsupported stream type [%s]",ms_format_type_to_string(mgr->type));
#endif
......@@ -203,7 +203,7 @@ void start_adaptive_stream(MSFormatType type, stream_manager_t ** pmarielle, str
MediaStream *marielle_ms,*margaux_ms;
OrtpNetworkSimulatorParams params={0};
#if VIDEO_ENABLED
MSWebCam * marielle_webcam=mediastreamer2_tester_get_mire_webcam(ms_web_cam_manager_get());
MSWebCam * marielle_webcam=mediastreamer2_tester_get_mire_webcam(ms_factory_get_wbc_manager(_factory));
#endif
stream_manager_t *marielle=*pmarielle=stream_manager_new(type);
stream_manager_t *margaux=*pmargaux=stream_manager_new(type);
......@@ -356,7 +356,7 @@ static void packet_duplication(void) {
static void upload_bandwidth_computation(void) {
//bool_t supported = ms_filter_codec_supported("pcma");
bool_t supported = ms_factory_codec_supported(factory, "pcma");
bool_t supported = ms_factory_codec_supported(_factory, "pcma");
if( supported ) {
stream_manager_t * marielle, * margaux;
......@@ -377,7 +377,7 @@ static void upload_bandwidth_computation(void) {
static void loss_rate_estimation(void) {
//bool_t supported = ms_filter_codec_supported("pcma");
bool_t supported = ms_factory_codec_supported(factory, "pcma");
bool_t supported = ms_factory_codec_supported(_factory, "pcma");
if( supported ) {
LossRateEstimatorCtx ctx;
stream_manager_t * marielle, * margaux;
......@@ -404,7 +404,7 @@ static void loss_rate_estimation(void) {
void upload_bitrate(const char* codec, int payload, int target_bw, int expect_bw) {
//bool_t supported = ms_filter_codec_supported("pcma");
bool_t supported = ms_factory_codec_supported(factory, "pcma");
bool_t supported = ms_factory_codec_supported(_factory, "pcma");
if( supported ) {
float upload_bw;
stream_manager_t * marielle, * margaux;
......
......@@ -27,7 +27,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "mediastreamer2_tester_private.h"
static RtpProfile rtp_profile;
static MSFactory *factory ;
static MSFactory *_factory= NULL;
#define OPUS_PAYLOAD_TYPE 121
#define SPEEX16_PAYLOAD_TYPE 122
......@@ -36,12 +36,12 @@ static MSFactory *factory ;
static int tester_before_all(void) {
//ms_init();
factory = ms_factory_new();
ms_factory_init_voip(factory);
ms_factory_init_plugins(factory);
_factory = ms_factory_new();
ms_factory_init_voip(_factory);
ms_factory_init_plugins(_factory);
//ms_filter_enable_statistics(TRUE);
ms_factory_enable_statistics(factory, TRUE);
ms_factory_enable_statistics(_factory, TRUE);
ortp_init();
rtp_profile_set_payload (&rtp_profile,0,&payload_type_pcmu8000);
rtp_profile_set_payload (&rtp_profile,OPUS_PAYLOAD_TYPE,&payload_type_opus);
......@@ -55,7 +55,7 @@ static int tester_before_all(void) {
static int tester_after_all(void) {
//ms_exit();
factory = ms_factory_exit(factory);
_factory = ms_factory_exit(_factory);
rtp_profile_clear_all(&rtp_profile);
return 0;
}
......@@ -138,9 +138,9 @@ static void basic_audio_stream_base_2( const char* marielle_local_ip
, int margaux_local_rtcp_port
, int margaux_remote_rtcp_port
, int lost_percentage) {
AudioStream * marielle = audio_stream_new2 (marielle_local_ip, marielle_local_rtp_port, marielle_local_rtcp_port, factory);
AudioStream * marielle = audio_stream_new2 (marielle_local_ip, marielle_local_rtp_port, marielle_local_rtcp_port, _factory);
stats_t marielle_stats;
AudioStream * margaux = audio_stream_new2 (margaux_local_ip, margaux_local_rtp_port,margaux_local_rtcp_port, factory);
AudioStream * margaux = audio_stream_new2 (margaux_local_ip, margaux_local_rtp_port,margaux_local_rtcp_port, _factory);
stats_t margaux_stats;
RtpProfile* profile = rtp_profile_new("default profile");
char* hello_file = bc_tester_res(HELLO_8K_1S_FILE);
......@@ -249,8 +249,8 @@ static void encrypted_audio_stream_base( bool_t change_ssrc,
,bool_t set_both_send_recv_key
,bool_t send_key_first
,bool_t encryption_mandatory) {
AudioStream * marielle = audio_stream_new (MARIELLE_RTP_PORT, MARIELLE_RTCP_PORT,FALSE, factory);
AudioStream * margaux = audio_stream_new (MARGAUX_RTP_PORT,MARGAUX_RTCP_PORT, FALSE, factory);
AudioStream * marielle = audio_stream_new (MARIELLE_RTP_PORT, MARIELLE_RTCP_PORT,FALSE, _factory);
AudioStream * margaux = audio_stream_new (MARGAUX_RTP_PORT,MARGAUX_RTCP_PORT, FALSE, _factory);
RtpProfile* profile = rtp_profile_new("default profile");
char* hello_file = bc_tester_res(HELLO_8K_1S_FILE);
char* recorded_file = bc_tester_file(RECORDED_8K_1S_FILE);
......@@ -358,7 +358,7 @@ static void encrypted_audio_stream_base( bool_t change_ssrc,
if (change_ssrc) {
audio_stream_stop(marielle);
marielle = audio_stream_new (MARIELLE_RTP_PORT, MARIELLE_RTCP_PORT,FALSE, factory);
marielle = audio_stream_new (MARIELLE_RTP_PORT, MARIELLE_RTCP_PORT,FALSE, _factory);
BC_ASSERT_EQUAL(audio_stream_start_full(marielle
, profile
, MARGAUX_IP
......@@ -429,9 +429,9 @@ static void encrypted_audio_stream_with_key_change_encryption_mandatory(void) {
}
static void codec_change_for_audio_stream(void) {
AudioStream *marielle = audio_stream_new2(MARIELLE_IP, MARIELLE_RTP_PORT, MARIELLE_RTCP_PORT, factory);
AudioStream *marielle = audio_stream_new2(MARIELLE_IP, MARIELLE_RTP_PORT, MARIELLE_RTCP_PORT, _factory);
stats_t marielle_stats;
AudioStream *margaux = audio_stream_new2(MARGAUX_IP, MARGAUX_RTP_PORT, MARGAUX_RTCP_PORT, factory);
AudioStream *margaux = audio_stream_new2(MARGAUX_IP, MARGAUX_RTP_PORT, MARGAUX_RTCP_PORT, _factory);
stats_t margaux_stats;
RtpProfile *profile = rtp_profile_new("default profile");
char* hello_file = bc_tester_res(HELLO_8K_1S_FILE);
......@@ -468,7 +468,7 @@ static void codec_change_for_audio_stream(void) {
audio_stream_stop(marielle);
reset_stats(&marielle_stats);
reset_stats(&margaux_stats);
marielle = audio_stream_new2(MARIELLE_IP, MARIELLE_RTP_PORT, MARIELLE_RTCP_PORT,factory);
marielle = audio_stream_new2(MARIELLE_IP, MARIELLE_RTP_PORT, MARIELLE_RTCP_PORT,_factory);
BC_ASSERT_EQUAL(audio_stream_start_full(marielle, profile, MARGAUX_IP, MARGAUX_RTP_PORT, MARGAUX_IP, MARGAUX_RTCP_PORT,
8, 50, hello_file, NULL, NULL, NULL, 0), 0, int, "%d");
......@@ -495,9 +495,9 @@ static void codec_change_for_audio_stream(void) {
}
static void tmmbr_feedback_for_audio_stream(void) {
AudioStream *marielle = audio_stream_new2(MARIELLE_IP, MARIELLE_RTP_PORT, MARIELLE_RTCP_PORT,factory);
AudioStream *marielle = audio_stream_new2(MARIELLE_IP, MARIELLE_RTP_PORT, MARIELLE_RTCP_PORT,_factory);
stats_t marielle_stats;
AudioStream *margaux = audio_stream_new2(MARGAUX_IP, MARGAUX_RTP_PORT, MARGAUX_RTCP_PORT,factory);
AudioStream *margaux = audio_stream_new2(MARGAUX_IP, MARGAUX_RTP_PORT, MARGAUX_RTCP_PORT,_factory);
stats_t margaux_stats;
RtpProfile *profile = rtp_profile_new("default profile");
RtpSession *marielle_session;
......
......@@ -28,21 +28,19 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "mediastreamer2_tester_private.h"
#include "private.h"
static MSFactory *factory;
static MSFactory *f = NULL;
static int basic_audio_tester_before_all(void) {
//ms_init();
factory = ms_factory_new();
ms_factory_init_voip(factory);
ms_factory_init_plugins(factory);
f = ms_factory_create(f);
ms_factory_enable_statistics(factory, TRUE);
ms_factory_enable_statistics(f, TRUE);
ortp_init();
return 0;
}
static int basic_audio_tester_after_all(void) {
//ms_exit();
factory = ms_factory_exit(factory);
f = ms_factory_exit(f);
ortp_exit();
return 0;
}
......@@ -59,10 +57,10 @@ static void dtmfgen_tonedet(void) {
// ms_filter_reset_statistics();
ms_factory_reset_statistics(factory);
ms_factory_reset_statistics(f);
ms_tester_create_ticker();
ms_tester_create_filters(filter_mask, factory);
ms_tester_create_filters(filter_mask, f);
ms_filter_add_notify_callback(ms_tester_tonedet, (MSFilterNotifyFunc)tone_detected_cb, NULL,TRUE);
ms_filter_call_method(ms_tester_voidsource, MS_VOID_SOURCE_SEND_SILENCE, &send_silence);
ms_connection_helper_start(&h);
......@@ -83,7 +81,7 @@ static void dtmfgen_tonedet(void) {
ms_connection_helper_unlink(&h, ms_tester_dtmfgen, 0, 0);
ms_connection_helper_unlink(&h, ms_tester_tonedet, 0, 0);
ms_connection_helper_unlink(&h, ms_tester_voidsink, 0, -1);
ms_factory_log_statistics(factory);
ms_factory_log_statistics(f);
//ms_filter_log_statistics();
ms_tester_destroy_filters(filter_mask);
ms_tester_destroy_ticker();
......@@ -96,7 +94,7 @@ static void dtmfgen_enc_dec_tonedet(char *mime, int sample_rate, int nchannels)
| FILTER_MASK_DECODER | FILTER_MASK_TONEDET | FILTER_MASK_VOIDSINK;
bool_t send_silence = TRUE;
MSSndCardManager *scm = ms_factory_get_snd_manager(factory);
MSSndCardManager *scm = ms_factory_get_snd_manager(f);
ms_factory_reset_statistics(scm->factory);
//ms_filter_reset_statistics();
......@@ -151,7 +149,7 @@ static void dtmfgen_enc_dec_tonedet_pcmu(void) {
}
static void dtmfgen_enc_dec_tonedet_isac(void) {
bool_t supported = ms_factory_codec_supported(factory, "iSAC");
bool_t supported = ms_factory_codec_supported(f, "iSAC");
// bool_t supported = ms_filter_codec_supported("iSAC");
if( supported ) {
dtmfgen_enc_dec_tonedet("iSAC", 16000, 1);
......@@ -170,13 +168,13 @@ static void dtmfgen_enc_rtp_dec_tonedet(void) {
unsigned int filter_mask = FILTER_MASK_VOIDSOURCE | FILTER_MASK_DTMFGEN | FILTER_MASK_ENCODER
| FILTER_MASK_RTPSEND | FILTER_MASK_RTPRECV | FILTER_MASK_DECODER | FILTER_MASK_TONEDET | FILTER_MASK_VOIDSINK;
bool_t send_silence = TRUE;
MSSndCardManager *scm = ms_factory_get_snd_manager(factory);
ms_factory_reset_statistics(factory);
MSSndCardManager *scm = ms_factory_get_snd_manager(f);
ms_factory_reset_statistics(f);
//ms_filter_reset_statistics();
ms_tester_create_ticker();
ms_tester_codec_mime = "pcmu";
ms_tester_create_filters(filter_mask, factory);
ms_tester_create_filters(filter_mask, f);
ms_filter_add_notify_callback(ms_tester_tonedet, (MSFilterNotifyFunc)tone_detected_cb, NULL,TRUE);
rtps = ms_create_duplex_rtp_session("0.0.0.0", 50060, 0);
rtp_session_set_remote_addr_full(rtps, "127.0.0.1", 50060, "127.0.0.1", 50061);
......@@ -228,9 +226,9 @@ static void dtmfgen_filerec_fileplay_tonedet(void) {
char* recorded_file = bc_tester_file(DTMFGEN_FILE_NAME);
ms_factory_reset_statistics(factory);
ms_factory_reset_statistics(f);
ms_tester_create_ticker();
ms_tester_create_filters(filter_mask, factory);
ms_tester_create_filters(filter_mask, f);
ms_filter_add_notify_callback(ms_tester_tonedet, (MSFilterNotifyFunc)tone_detected_cb, NULL,TRUE);
// Generate tones and save them to a file
......@@ -267,7 +265,7 @@ static void dtmfgen_filerec_fileplay_tonedet(void) {
ms_connection_helper_unlink(&h, ms_tester_fileplay, -1, 0);
ms_connection_helper_unlink(&h, ms_tester_tonedet, 0, 0);
ms_connection_helper_unlink(&h, ms_tester_voidsink, 0, -1);
ms_factory_log_statistics(factory);
ms_factory_log_statistics(f);
// ms_filter_log_statistics();
ms_tester_destroy_filters(filter_mask);
ms_tester_destroy_ticker();
......
......@@ -41,13 +41,10 @@ static int tester_after_all(void) {
static void filter_register_tester(void) {
MSFilter* filter;
MSFactory* factory;
MSFactory* factory = NULL;
factory = ms_factory_new();
ms_factory_init_voip(factory);
ms_factory_init_plugins(factory);
ms_factory_init_voip(factory);
ms_factory_init_plugins(factory);
factory = ms_factory_create(factory);
factory = ms_factory_create(factory);
//ms_init();
//ms_init();
......@@ -156,9 +153,8 @@ static void test_is_multicast(void) {
static void test_filterdesc_enable_disable_base(const char* mime, const char* filtername,bool_t is_enc) {
MSFilter *filter;
MSFactory *factory = ms_factory_new();
ms_factory_init_voip(factory);
ms_factory_init_plugins(factory);
MSFactory *factory = NULL;
factory = ms_factory_create(factory);
if (is_enc)
filter = ms_factory_create_encoder(factory,mime);
......
......@@ -21,17 +21,15 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "mediastreamer2/msmediaplayer.h"
#include "mediastreamer2/mediastream.h"
static MSFactory* factory;
static MSFactory* _factory = NULL;
static int tester_before_all(void) {
factory = ms_factory_new();
ms_factory_init_voip(factory);
ms_factory_init_plugins(factory);
_factory = ms_factory_create(_factory);
return 0;
}
static int tester_after_all(void) {
factory = ms_factory_exit(factory);
_factory = ms_factory_exit(_factory);
return 0;
}
......@@ -69,7 +67,7 @@ static void play_file(const char *filepath, bool_t unsupported_format, bool_t se
bool_t succeed;
Eof eof;
MSMediaPlayer *file_player = NULL;
MSSndCard *snd_card = ms_snd_card_manager_get_default_playback_card(ms_factory_get_snd_manager(factory));
MSSndCard *snd_card = ms_snd_card_manager_get_default_playback_card(ms_factory_get_snd_manager(_factory));
const char *display_name = video_stream_get_default_video_renderer();
int duration, timeout;
const int seek_time = 6100;
......@@ -85,7 +83,7 @@ static void play_file(const char *filepath, bool_t unsupported_format, bool_t se
BC_ASSERT_EQUAL(ms_media_player_get_state(file_player), MSPlayerClosed, int, "%d");
ms_media_player_set_eof_callback(file_player, eof_callback, &eof);
succeed = ms_media_player_open(file_player, filepath,factory);
succeed = ms_media_player_open(file_player, filepath,_factory);
if(unsupported_format) {
BC_ASSERT_FALSE(succeed);
BC_ASSERT_EQUAL(ms_media_player_get_state(file_player), MSPlayerClosed, int, "%d");
......@@ -129,7 +127,7 @@ static void play_file(const char *filepath, bool_t unsupported_format, bool_t se
if(play_twice) {
eof_init(&eof);
BC_ASSERT_TRUE(ms_media_player_open(file_player, filepath, factory));
BC_ASSERT_TRUE(ms_media_player_open(file_player, filepath, _factory));
BC_ASSERT_TRUE(ms_media_player_start(file_player));
wait_for_eof(&eof, 100, timeout);
ms_media_player_close(file_player);
......
......@@ -142,7 +142,7 @@ void ms_tester_create_filters(unsigned int filter_mask, MSFactory * f) {
}
if (filter_mask & FILTER_MASK_VIDEOCAPTURE) {
BC_ASSERT_PTR_NULL(ms_tester_videocapture);
cam_manager = ms_web_cam_manager_get();
cam_manager = ms_factory_get_wbc_manager(f);
camera = ms_web_cam_manager_get_default_cam(cam_manager);
BC_ASSERT_PTR_NOT_NULL_FATAL(camera);
ms_tester_videocapture = ms_web_cam_create_reader(camera, f);
......
......@@ -32,13 +32,11 @@ static RtpProfile rtp_profile;
#define T140_PAYLOAD_TYPE 98
#define T140_RED_PAYLOAD_TYPE 99
static MSFactory *factory;
static MSFactory *_factory = NULL;
static int tester_init(void) {
//ms_init();
factory = ms_factory_new();
ms_factory_init_voip(factory);
ms_factory_init_plugins(factory);
_factory = ms_factory_create(_factory);
ortp_init();
rtp_profile_set_payload(&rtp_profile, T140_PAYLOAD_TYPE, &payload_type_t140);
rtp_profile_set_payload(&rtp_profile, T140_RED_PAYLOAD_TYPE, &payload_type_t140_red);
......@@ -48,7 +46,7 @@ static int tester_init(void) {
static int tester_cleanup(void) {
//ms_exit();
factory = ms_factory_exit(factory);
_factory = ms_factory_exit(_factory);
rtp_profile_clear_all(&rtp_profile);
return 0;
}
......@@ -103,7 +101,7 @@ void text_stream_tester_destroy(text_stream_tester_t* obj) {
}
static void create_text_stream(text_stream_tester_t *tst, int payload_type) {
tst->ts = text_stream_new2(tst->local_ip, tst->local_rtp, tst->local_rtcp, factory);
tst->ts = text_stream_new2(tst->local_ip, tst->local_rtp, tst->local_rtcp, _factory);
tst->local_rtp = rtp_session_get_local_port(tst->ts->ms.sessions.rtp_session);
tst->local_rtcp = rtp_session_get_local_rtcp_port(tst->ts->ms.sessions.rtp_session);
reset_stats(&tst->stats);
......@@ -138,9 +136,9 @@ static void init_text_streams(text_stream_tester_t *tst1, text_stream_tester_t *
rtp_session_enable_network_simulation(tst2->ts->ms.sessions.rtp_session, params);
}
text_stream_start(tst1->ts, &rtp_profile, tst2->local_ip, tst2->local_rtp, tst2->local_ip, tst2->local_rtcp, payload_type, factory);
text_stream_start(tst1->ts, &rtp_profile, tst2->local_ip, tst2->local_rtp, tst2->local_ip, tst2->local_rtcp, payload_type, _factory);
ms_filter_add_notify_callback(tst1->ts->rttsink, real_time_text_character_received, tst1, TRUE);
text_stream_start(tst2->ts, &rtp_profile, tst1->local_ip, tst1->local_rtp, tst1->local_ip, tst1->local_rtcp, payload_type, factory);
text_stream_start(tst2->ts, &rtp_profile, tst1->local_ip, tst1->local_rtp, tst1->local_ip, tst1->local_rtcp, payload_type, _factory);
ms_filter_add_notify_callback(tst2->ts->rttsink, real_time_text_character_received, tst2, TRUE);
}
......
......@@ -28,7 +28,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#endif
static RtpProfile rtp_profile;
static MSFactory* factory;
static MSFactory* _factory = NULL;
#define VP8_PAYLOAD_TYPE 103
#define H264_PAYLOAD_TYPE 104
......@@ -52,11 +52,9 @@ MSWebCam* mediastreamer2_tester_get_mire_webcam(MSWebCamManager *mgr) {
static int tester_before_all(void) {
//ms_init();
factory = ms_factory_new();
ms_factory_init_voip(factory);
ms_factory_init_plugins(factory);
_factory = ms_factory_create(_factory);
ms_factory_create_filter(factory, TRUE);
ms_factory_create_filter(_factory, TRUE);
ortp_init();
rtp_profile_set_payload(&rtp_profile, VP8_PAYLOAD_TYPE, &payload_type_vp8);
rtp_profile_set_payload(&rtp_profile, H264_PAYLOAD_TYPE, &payload_type_h264);
......@@ -67,7 +65,7 @@ static int tester_before_all(void) {
static int tester_after_all(void) {
//ms_exit();
factory = ms_factory_exit(factory);
_factory = ms_factory_exit(_factory);
rtp_profile_clear_all(&rtp_profile);
return 0;
}
......@@ -111,7 +109,7 @@ void video_stream_tester_set_local_ip(video_stream_tester_t* obj,const char*ip)
video_stream_tester_t* video_stream_tester_new(void) {
video_stream_tester_t* vst = ms_new0(video_stream_tester_t,1);
video_stream_tester_set_local_ip(vst,"127.0.0.1");
vst->cam = ms_web_cam_manager_get_cam(ms_web_cam_manager_get(), "StaticImage: Static picture");
vst->cam = ms_web_cam_manager_get_cam(ms_factory_get_wbc_manager(_factory), "StaticImage: Static picture");
vst->local_rtp=-1; /*random*/
vst->local_rtcp=-1; /*random*/
return vst;
......@@ -212,7 +210,7 @@ static void event_queue_cb(MediaStream *ms, void *user_pointer) {
}
static void create_video_stream(video_stream_tester_t *vst, int payload_type) {
vst->vs = video_stream_new2(vst->local_ip, vst->local_rtp, vst->local_rtcp,factory);
vst->vs = video_stream_new2(vst->local_ip, vst->local_rtp, vst->local_rtcp,_factory);
vst->vs->staticimage_webcam_fps_optimization = FALSE;
vst->local_rtp = rtp_session_get_local_port(vst->vs->ms.sessions.rtp_session);
vst->local_rtcp = rtp_session_get_local_rtcp_port(vst->vs->ms.sessions.rtp_session);
......@@ -289,7 +287,7 @@ static void uninit_video_streams(video_stream_tester_t *vst1, video_stream_teste
}
static void change_codec(video_stream_tester_t *vst1, video_stream_tester_t *vst2, int payload_type) {
MSWebCam *no_webcam = ms_web_cam_manager_get_cam(ms_web_cam_manager_get(), "StaticImage: Static picture");
MSWebCam *no_webcam = ms_web_cam_manager_get_cam(ms_factory_get_wbc_manager(_factory), "StaticImage: Static picture");
if (vst1->payload_type == payload_type) return;
......@@ -301,7 +299,7 @@ static void change_codec(video_stream_tester_t *vst1, video_stream_tester_t *vst
static void basic_video_stream(void) {
video_stream_tester_t* marielle=video_stream_tester_new();
video_stream_tester_t* margaux=video_stream_tester_new();
bool_t supported = ms_factory_codec_supported(factory, "vp8");
bool_t supported = ms_factory_codec_supported(_factory, "vp8");
if (supported) {
init_video_streams(marielle, margaux, FALSE, FALSE, NULL,VP8_PAYLOAD_TYPE);
......@@ -320,7 +318,7 @@ static void basic_video_stream(void) {
static void basic_one_way_video_stream(void) {
video_stream_tester_t* marielle=video_stream_tester_new();
video_stream_tester_t* margaux=video_stream_tester_new();
bool_t supported = ms_factory_codec_supported(factory, "vp8");
bool_t supported = ms_factory_codec_supported(_factory, "vp8");
if (supported) {
init_video_streams(marielle, margaux, FALSE, TRUE, NULL,VP8_PAYLOAD_TYPE);
......@@ -339,9 +337,9 @@ static void basic_one_way_video_stream(void) {
static void codec_change_for_video_stream(void) {
video_stream_tester_t *marielle = video_stream_tester_new();
video_stream_tester_t *margaux = video_stream_tester_new();
bool_t vp8_supported = ms_factory_codec_supported(factory, "vp8");
bool_t h264_supported = ms_factory_codec_supported(factory, "h264");
bool_t mp4v_supported = ms_factory_codec_supported(factory, "mp4v-es");
bool_t vp8_supported = ms_factory_codec_supported(_factory, "vp8");
bool_t h264_supported = ms_factory_codec_supported(_factory, "h264");
bool_t mp4v_supported = ms_factory_codec_supported(_factory, "mp4v-es");
if