diff options
author | Mamadou DIOP <bossiel@yahoo.fr> | 2016-02-23 22:00:35 +0100 |
---|---|---|
committer | Mamadou DIOP <bossiel@yahoo.fr> | 2016-02-23 22:00:35 +0100 |
commit | 50dfb4359619563012997bc3ddafb7667741066c (patch) | |
tree | db234c1edc3240a653363b5735fc4077af4b8720 /tinyMEDIA/test | |
parent | 94b2219209038e05dd26395f6fb700be4d1062c0 (diff) | |
download | doubango-50dfb4359619563012997bc3ddafb7667741066c.zip doubango-50dfb4359619563012997bc3ddafb7667741066c.tar.gz |
Add new QoS implementation
Code formatting
Diffstat (limited to 'tinyMEDIA/test')
-rwxr-xr-x | tinyMEDIA/test/dummy.c | 168 | ||||
-rwxr-xr-x | tinyMEDIA/test/dummy.h | 19 | ||||
-rwxr-xr-x | tinyMEDIA/test/test.c | 112 | ||||
-rwxr-xr-x | tinyMEDIA/test/test_codecs.h | 18 | ||||
-rwxr-xr-x | tinyMEDIA/test/test_contents.h | 54 | ||||
-rwxr-xr-x | tinyMEDIA/test/test_image_attr.h | 47 | ||||
-rwxr-xr-x | tinyMEDIA/test/test_qos.h | 428 | ||||
-rwxr-xr-x | tinyMEDIA/test/test_sessions.h | 314 |
8 files changed, 577 insertions, 583 deletions
diff --git a/tinyMEDIA/test/dummy.c b/tinyMEDIA/test/dummy.c index 5874de5..e7ca8cd 100755 --- a/tinyMEDIA/test/dummy.c +++ b/tinyMEDIA/test/dummy.c @@ -2,19 +2,19 @@ * Copyright (C) 2009 Mamadou Diop. * * Contact: Mamadou Diop <diopmamadou(at)yahoo.fr> -* +* * This file is part of Open Source Doubango Framework. * * DOUBANGO 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 3 of the License, or * (at your option) any later version. -* +* * DOUBANGO 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 DOUBANGO. * @@ -27,73 +27,72 @@ int dummy_start(tmedia_t* self) { - dummy_t *dummy = DUMMY(self); - TSK_DEBUG_INFO("dummy_start"); + dummy_t *dummy = DUMMY(self); + TSK_DEBUG_INFO("dummy_start"); - return 0; + return 0; } int dummy_pause(tmedia_t* self) { - dummy_t *dummy = DUMMY(self); - TSK_DEBUG_INFO("dummy_pause"); + dummy_t *dummy = DUMMY(self); + TSK_DEBUG_INFO("dummy_pause"); - return 0; + return 0; } int dummy_stop(tmedia_t* self) { - dummy_t *dummy = DUMMY(self); - TSK_DEBUG_INFO("dummy_stop"); - - return 0; + dummy_t *dummy = DUMMY(self); + TSK_DEBUG_INFO("dummy_stop"); + + return 0; } const tsdp_header_M_t* dummy_get_local_offer(tmedia_t* self, va_list *app) { - dummy_t *dummy = DUMMY(self); - const tsk_object_def_t* objdef; - tsdp_header_t* header; + dummy_t *dummy = DUMMY(self); + const tsk_object_def_t* objdef; + tsdp_header_t* header; - TSK_DEBUG_INFO("dummy_get_local_offer"); - while((objdef = va_arg(*app, const tsk_object_def_t*))){ - header = tsk_object_new_2(objdef, app); + TSK_DEBUG_INFO("dummy_get_local_offer"); + while((objdef = va_arg(*app, const tsk_object_def_t*))) { + header = tsk_object_new_2(objdef, app); - TSK_OBJECT_SAFE_FREE(header); - } + TSK_OBJECT_SAFE_FREE(header); + } - return tsk_null; + return tsk_null; } const tsdp_header_M_t* dummy_get_negotiated_offer(tmedia_t* self) { - dummy_t *dummy = DUMMY(self); - TSK_DEBUG_INFO("dummy_get_negotiated_offer"); + dummy_t *dummy = DUMMY(self); + TSK_DEBUG_INFO("dummy_get_negotiated_offer"); - return tsk_null; + return tsk_null; } int dummy_set_remote_offer(tmedia_t* self, const tsdp_message_t* offer) { - dummy_t *dummy = DUMMY(self); - TSK_DEBUG_INFO("dummy_set_remote_offer"); + dummy_t *dummy = DUMMY(self); + TSK_DEBUG_INFO("dummy_set_remote_offer"); - return 0; + return 0; } int dummy_perform(tmedia_t* self, tmedia_action_t action, const tsk_params_L_t* params) { - dummy_t *dummy = DUMMY(self); - - switch(action){ - case tma_dummy_say_hello: - { - TSK_DEBUG_INFO("dummy_perform (hello to \"%s\")", tsk_params_get_param_value(params, "to")); - break; - } - } - - return 0; + dummy_t *dummy = DUMMY(self); + + switch(action) { + case tma_dummy_say_hello: { + TSK_DEBUG_INFO("dummy_perform (hello to \"%s\")", tsk_params_get_param_value(params, "to")); + break; + } + } + + return 0; } @@ -102,50 +101,48 @@ int dummy_perform(tmedia_t* self, tmedia_action_t action, const tsk_params_L_t* // static void* dummy_create(tsk_object_t *self, va_list * app) { - dummy_t *dummy = self; - if(dummy) - { - // Parameters MUST appear in this order - const char* name = va_arg(*app, const char*); - const char* host = va_arg(*app, const char*); - tnet_socket_type_t socket_type = va_arg(*app, tnet_socket_type_t); - - tmedia_init(TMEDIA(dummy), name); - - TMEDIA(dummy)->protocol = tsk_strdup("TCP/DUMMY"); - } - else{ - TSK_DEBUG_ERROR("Failed to create new dummy media."); - } - return self; + dummy_t *dummy = self; + if(dummy) { + // Parameters MUST appear in this order + const char* name = va_arg(*app, const char*); + const char* host = va_arg(*app, const char*); + tnet_socket_type_t socket_type = va_arg(*app, tnet_socket_type_t); + + tmedia_init(TMEDIA(dummy), name); + + TMEDIA(dummy)->protocol = tsk_strdup("TCP/DUMMY"); + } + else { + TSK_DEBUG_ERROR("Failed to create new dummy media."); + } + return self; } static void* dummy_destroy(tsk_object_t *self) { - dummy_t *dummy = self; - if(dummy){ - tmedia_deinit(TMEDIA(dummy)); - TSK_FREE(dummy->local_sdp); - TSK_FREE(dummy->remote_sdp); - TSK_FREE(dummy->negotiated_sdp); - } - else{ - TSK_DEBUG_ERROR("Null dummy media."); - } - - return self; + dummy_t *dummy = self; + if(dummy) { + tmedia_deinit(TMEDIA(dummy)); + TSK_FREE(dummy->local_sdp); + TSK_FREE(dummy->remote_sdp); + TSK_FREE(dummy->negotiated_sdp); + } + else { + TSK_DEBUG_ERROR("Null dummy media."); + } + + return self; } static int dummy_cmp(const tsk_object_t *obj1, const tsk_object_t *obj2) { - return -1; + return -1; } -static const tsk_object_def_t dummy_def_s = -{ - sizeof(dummy_t), - dummy_create, - dummy_destroy, - dummy_cmp +static const tsk_object_def_t dummy_def_s = { + sizeof(dummy_t), + dummy_create, + dummy_destroy, + dummy_cmp }; const tsk_object_def_t *dummy_def_t = &dummy_def_s; @@ -153,21 +150,20 @@ const tsk_object_def_t *dummy_def_t = &dummy_def_s; //======================================================== // Dummy media plugin definition // -static const tmedia_plugin_def_t dummy_plugin_def_s = -{ - &dummy_def_s, - "dummy plugin", - "audio", +static const tmedia_plugin_def_t dummy_plugin_def_s = { + &dummy_def_s, + "dummy plugin", + "audio", - dummy_start, - dummy_pause, - dummy_stop, + dummy_start, + dummy_pause, + dummy_stop, - dummy_get_local_offer, - dummy_get_negotiated_offer, - dummy_set_remote_offer, + dummy_get_local_offer, + dummy_get_negotiated_offer, + dummy_set_remote_offer, - dummy_perform + dummy_perform }; const tmedia_plugin_def_t *dummy_plugin_def_t = &dummy_plugin_def_s; diff --git a/tinyMEDIA/test/dummy.h b/tinyMEDIA/test/dummy.h index a916ea6..cb0d82e 100755 --- a/tinyMEDIA/test/dummy.h +++ b/tinyMEDIA/test/dummy.h @@ -2,19 +2,19 @@ * Copyright (C) 2009 Mamadou Diop. * * Contact: Mamadou Diop <diopmamadou(at)yahoo.fr> -* +* * This file is part of Open Source Doubango Framework. * * DOUBANGO 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 3 of the License, or * (at your option) any later version. -* +* * DOUBANGO 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 DOUBANGO. * @@ -26,13 +26,12 @@ #define DUMMY(self) ((dummy_t*)(self)) -typedef struct dummy_s -{ - TMED_DECLARE_MEDIA; - - char* local_sdp; - char* remote_sdp; - char* negotiated_sdp; +typedef struct dummy_s { + TMED_DECLARE_MEDIA; + + char* local_sdp; + char* remote_sdp; + char* negotiated_sdp; } dummy_t; diff --git a/tinyMEDIA/test/test.c b/tinyMEDIA/test/test.c index 759a96b..c11f2a0 100755 --- a/tinyMEDIA/test/test.c +++ b/tinyMEDIA/test/test.c @@ -2,19 +2,19 @@ * Copyright (C) 2009 Mamadou Diop. * * Contact: Mamadou Diop <diopmamadou(at)yahoo.fr> -* +* * This file is part of Open Source Doubango Framework. * * DOUBANGO 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 3 of the License, or * (at your option) any later version. -* +* * DOUBANGO 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 DOUBANGO. * @@ -50,78 +50,78 @@ int _tmain(int argc, _TCHAR* argv[]) int main() #endif { - /* Register dummy plugins */ - test_register_dummy_plugins(); - /* Register content plugins */ - test_register_contents_plugins(); + /* Register dummy plugins */ + test_register_dummy_plugins(); + /* Register content plugins */ + test_register_contents_plugins(); - do { + do { #if RUN_TEST_ALL || RUN_TEST_CODECS - test_codecs(); + test_codecs(); #endif #if RUN_TEST_ALL || RUN_TEST_SESSIONS - test_sessions(); + test_sessions(); #endif #if RUN_TEST_ALL || RUN_TEST_QOS - test_qos(); + test_qos(); #endif #if RUN_TEST_ALL || RUN_TEST_IMAGEATTR - test_qos_imageattr(); + test_qos_imageattr(); #endif #if RUN_TEST_ALL || RUN_TEST_CONTENTS - test_contents(); + test_contents(); #endif - - } - while(RUN_TEST_LOOP); - - return 0; + + } + while(RUN_TEST_LOOP); + + return 0; } void test_register_contents_plugins() { - tmedia_content_plugin_register("text/html", tmedia_content_dummy_plugin_def_t); - tmedia_content_plugin_register("text/plain", tmedia_content_dummy_plugin_def_t); - tmedia_content_plugin_register("message/CPIM", tmedia_content_cpim_plugin_def_t); + tmedia_content_plugin_register("text/html", tmedia_content_dummy_plugin_def_t); + tmedia_content_plugin_register("text/plain", tmedia_content_dummy_plugin_def_t); + tmedia_content_plugin_register("message/CPIM", tmedia_content_cpim_plugin_def_t); } void test_register_dummy_plugins() { - int ret; - - /* === Sessions === */ - if((ret = tmedia_session_plugin_register(tmedia_session_daudio_plugin_def_t))){ - TSK_DEBUG_ERROR("Failed to register audio plugin"); - } - if((ret = tmedia_session_plugin_register(tmedia_session_dvideo_plugin_def_t))){ - TSK_DEBUG_ERROR("Failed to register video plugin"); - } - if((ret = tmedia_session_plugin_register(tmedia_session_dmsrp_plugin_def_t))){ - TSK_DEBUG_ERROR("Failed to register msrp plugin"); - } - if((ret = tmedia_session_plugin_register(tmedia_session_ghost_plugin_def_t))){ - TSK_DEBUG_ERROR("Failed to register ghost plugin"); - } - - /* === Codecs === */ - if((ret = tmedia_codec_plugin_register(tmedia_codec_dpcma_plugin_def_t))){ - TSK_DEBUG_ERROR("Failed to register G.711a plugin"); - } - if((ret = tmedia_codec_plugin_register(tmedia_codec_dpcmu_plugin_def_t))){ - TSK_DEBUG_ERROR("Failed to register G.711u plugin"); - } - if((ret = tmedia_codec_plugin_register(tmedia_codec_dh263_plugin_def_t))){ - TSK_DEBUG_ERROR("Failed to register H.263-1996 plugin"); - } - if((ret = tmedia_codec_plugin_register(tmedia_codec_dh264_plugin_def_t))){ - TSK_DEBUG_ERROR("Failed to register H.264 (Base profile 10) plugin"); - } + int ret; + + /* === Sessions === */ + if((ret = tmedia_session_plugin_register(tmedia_session_daudio_plugin_def_t))) { + TSK_DEBUG_ERROR("Failed to register audio plugin"); + } + if((ret = tmedia_session_plugin_register(tmedia_session_dvideo_plugin_def_t))) { + TSK_DEBUG_ERROR("Failed to register video plugin"); + } + if((ret = tmedia_session_plugin_register(tmedia_session_dmsrp_plugin_def_t))) { + TSK_DEBUG_ERROR("Failed to register msrp plugin"); + } + if((ret = tmedia_session_plugin_register(tmedia_session_ghost_plugin_def_t))) { + TSK_DEBUG_ERROR("Failed to register ghost plugin"); + } + + /* === Codecs === */ + if((ret = tmedia_codec_plugin_register(tmedia_codec_dpcma_plugin_def_t))) { + TSK_DEBUG_ERROR("Failed to register G.711a plugin"); + } + if((ret = tmedia_codec_plugin_register(tmedia_codec_dpcmu_plugin_def_t))) { + TSK_DEBUG_ERROR("Failed to register G.711u plugin"); + } + if((ret = tmedia_codec_plugin_register(tmedia_codec_dh263_plugin_def_t))) { + TSK_DEBUG_ERROR("Failed to register H.263-1996 plugin"); + } + if((ret = tmedia_codec_plugin_register(tmedia_codec_dh264_plugin_def_t))) { + TSK_DEBUG_ERROR("Failed to register H.264 (Base profile 10) plugin"); + } } //#ifdef _WIN32_WCE @@ -133,23 +133,23 @@ void test_register_dummy_plugins() // while(1) // { // tmedia_t* dummy = tsk_null; -// +// // // Register dummy media // tmedia_plugin_register(dummy_plugin_def_t); // // ...if you have another one to register // // ...and another // // ...again and again -// +// // // Create dummy media // if((dummy = tmedia_factory_create("dummy plugin", "127.0.0.1", tnet_socket_type_udp_ipv4))){ // // tmedia_get_local_offer(dummy, // TSDP_HEADER_A_VA_ARGS("file-disposition", "attachment"), -// +// // tsk_null // ); // tmedia_get_negotiated_offer(dummy); -// tmedia_set_remote_offer(dummy, tsk_null); +// tmedia_set_remote_offer(dummy, tsk_null); // // tmedia_start(dummy); // tmedia_pause(dummy); @@ -160,11 +160,11 @@ void test_register_dummy_plugins() // tsk_null); // // tmedia_stop(dummy); -// +// // TSK_OBJECT_SAFE_FREE(dummy); // } // } -// +// // return 0; //} diff --git a/tinyMEDIA/test/test_codecs.h b/tinyMEDIA/test/test_codecs.h index 865953c..8fdb809 100755 --- a/tinyMEDIA/test/test_codecs.h +++ b/tinyMEDIA/test/test_codecs.h @@ -2,19 +2,19 @@ * Copyright (C) 2009 Mamadou Diop. * * Contact: Mamadou Diop <diopmamadou(at)yahoo.fr> -* +* * This file is part of Open Source Doubango Framework. * * DOUBANGO 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 3 of the License, or * (at your option) any later version. -* +* * DOUBANGO 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 DOUBANGO. * @@ -24,14 +24,14 @@ void test_codecs() { - tmedia_codec_t* pcmu, *pcma; + tmedia_codec_t* pcmu, *pcma; - /* creates codecs */ - pcmu = tmedia_codec_create(TMEDIA_CODEC_FORMAT_G711u); - pcma = tmedia_codec_create(TMEDIA_CODEC_FORMAT_G711a); + /* creates codecs */ + pcmu = tmedia_codec_create(TMEDIA_CODEC_FORMAT_G711u); + pcma = tmedia_codec_create(TMEDIA_CODEC_FORMAT_G711a); - TSK_OBJECT_SAFE_FREE(pcmu); - TSK_OBJECT_SAFE_FREE(pcma); + TSK_OBJECT_SAFE_FREE(pcmu); + TSK_OBJECT_SAFE_FREE(pcma); } #endif /* _TEST_CODECS_H_ */ diff --git a/tinyMEDIA/test/test_contents.h b/tinyMEDIA/test/test_contents.h index fe33797..abce61e 100755 --- a/tinyMEDIA/test/test_contents.h +++ b/tinyMEDIA/test/test_contents.h @@ -2,19 +2,19 @@ * Copyright (C) 2009 Mamadou Diop. * * Contact: Mamadou Diop <diopmamadou(at)yahoo.fr> -* +* * This file is part of Open Source Doubango Framework. * * DOUBANGO 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 3 of the License, or * (at your option) any later version. -* +* * DOUBANGO 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 DOUBANGO. * @@ -28,9 +28,9 @@ static void test_content_cpim(); static void test_contents() { - test_content_dummy(); - test_content_text_plain(); - test_content_cpim(); + test_content_dummy(); + test_content_text_plain(); + test_content_cpim(); } @@ -38,28 +38,28 @@ static void test_content_dummy() { #define CONTENT_DUMMY_DATA "salut" #define CONTENT_DUMMY_TYPE "cool/ok" - tmedia_content_t* content = tmedia_content_parse(CONTENT_DUMMY_DATA, tsk_strlen(CONTENT_DUMMY_DATA), CONTENT_DUMMY_TYPE); - if(content){ - tsk_buffer_t* data = tmedia_content_get_data(content); - TSK_DEBUG_INFO("content-type=%s\n\ncontent=%s", TMEDIA_CONTENT(content)->type, TSK_BUFFER_DATA(data)); - tsk_object_unref(data); - } + tmedia_content_t* content = tmedia_content_parse(CONTENT_DUMMY_DATA, tsk_strlen(CONTENT_DUMMY_DATA), CONTENT_DUMMY_TYPE); + if(content) { + tsk_buffer_t* data = tmedia_content_get_data(content); + TSK_DEBUG_INFO("content-type=%s\n\ncontent=%s", TMEDIA_CONTENT(content)->type, TSK_BUFFER_DATA(data)); + tsk_object_unref(data); + } - TSK_OBJECT_SAFE_FREE(content); + TSK_OBJECT_SAFE_FREE(content); } static void test_content_text_plain() { #define CONTENT_TEXT_PLAIN_DATA "salut comment tu vas?" #define CONTENT_TEXT_PLAIN_TYPE "text/plain" - tmedia_content_t* content = tmedia_content_parse(CONTENT_TEXT_PLAIN_DATA, tsk_strlen(CONTENT_TEXT_PLAIN_DATA), CONTENT_TEXT_PLAIN_TYPE); - if(content){ - tsk_buffer_t* data = tmedia_content_get_data(content); - TSK_DEBUG_INFO("content-type=%s\n\ncontent=%s", TMEDIA_CONTENT(content)->type, TSK_BUFFER_DATA(data)); - tsk_object_unref(data); - } + tmedia_content_t* content = tmedia_content_parse(CONTENT_TEXT_PLAIN_DATA, tsk_strlen(CONTENT_TEXT_PLAIN_DATA), CONTENT_TEXT_PLAIN_TYPE); + if(content) { + tsk_buffer_t* data = tmedia_content_get_data(content); + TSK_DEBUG_INFO("content-type=%s\n\ncontent=%s", TMEDIA_CONTENT(content)->type, TSK_BUFFER_DATA(data)); + tsk_object_unref(data); + } - TSK_OBJECT_SAFE_FREE(content); + TSK_OBJECT_SAFE_FREE(content); } static void test_content_cpim() @@ -75,14 +75,14 @@ static void test_content_cpim() "salut comment tu vas?\r\n" #define CONTENT_CPIM_TYPE "message/CPIM" - tmedia_content_t* content = tmedia_content_parse(CONTENT_CPIM_DATA, tsk_strlen(CONTENT_CPIM_DATA), CONTENT_CPIM_TYPE); - if(content){ - tsk_buffer_t* data = tmedia_content_get_data(content); - TSK_DEBUG_INFO("content-type=%s\n\ncontent=%s", TMEDIA_CONTENT(content)->type, TSK_BUFFER_DATA(data)); - tsk_object_unref(data); - } + tmedia_content_t* content = tmedia_content_parse(CONTENT_CPIM_DATA, tsk_strlen(CONTENT_CPIM_DATA), CONTENT_CPIM_TYPE); + if(content) { + tsk_buffer_t* data = tmedia_content_get_data(content); + TSK_DEBUG_INFO("content-type=%s\n\ncontent=%s", TMEDIA_CONTENT(content)->type, TSK_BUFFER_DATA(data)); + tsk_object_unref(data); + } - TSK_OBJECT_SAFE_FREE(content); + TSK_OBJECT_SAFE_FREE(content); } #endif /* _TEST_CONTENTS_H_ */ diff --git a/tinyMEDIA/test/test_image_attr.h b/tinyMEDIA/test/test_image_attr.h index e91d25f..51dfe35 100755 --- a/tinyMEDIA/test/test_image_attr.h +++ b/tinyMEDIA/test/test_image_attr.h @@ -2,19 +2,19 @@ * Copyright (C) 20012 Doubango Telecom <http://www.doubango.org> * * Contact: Mamadou Diop <diopmamadou(at)yahoo[dot]fr> -* +* * This file is part of Open Source Doubango Framework. * * DOUBANGO 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 3 of the License, or * (at your option) any later version. -* +* * DOUBANGO 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 DOUBANGO. * @@ -22,31 +22,30 @@ #ifndef _TEST_IMG_ATTR_H_ #define _TEST_IMG_ATTR_H_ -static const char* __test_imageattrs[] = -{ - "send [x=800,y=640,sar=1.1,q=0.6] [x=480,y=320] recv [x=330,y=250]", - "recv [x=800,y=640,sar=1.1] send [x=330,y=250]", - "recv [x=800,y=640,sar=1.1] send [x=[320:16:640],y=[240:16:480],par=[1.2-1.3]]", - "send [x=[480:16:800],y=[320:16:640],par=[1.2-1.3],q=0.6] [x=[176:8:208],y=[144:8:176],par=[1.2-1.3]] recv *", - "send [x=176,y=144] [x=224,y=176] [x=272,y=224] [x=320,y=240] recv [x=176,y=144] [x=224,y=176] [x=272,y=224,q=0.6] [x=320,y=240]", - "send [x=320,y=240]", - "recv [x=320,y=240]", - "send [x=[400:16:800],y=[320:16:640],sar=[1.0-1.3],par=[1.2-1.3]] recv [x=800,y=600,sar=1.1]", - "recv [x=464,y=384,sar=1.15] send [x=800,y=600,sar=1.1]" +static const char* __test_imageattrs[] = { + "send [x=800,y=640,sar=1.1,q=0.6] [x=480,y=320] recv [x=330,y=250]", + "recv [x=800,y=640,sar=1.1] send [x=330,y=250]", + "recv [x=800,y=640,sar=1.1] send [x=[320:16:640],y=[240:16:480],par=[1.2-1.3]]", + "send [x=[480:16:800],y=[320:16:640],par=[1.2-1.3],q=0.6] [x=[176:8:208],y=[144:8:176],par=[1.2-1.3]] recv *", + "send [x=176,y=144] [x=224,y=176] [x=272,y=224] [x=320,y=240] recv [x=176,y=144] [x=224,y=176] [x=272,y=224,q=0.6] [x=320,y=240]", + "send [x=320,y=240]", + "recv [x=320,y=240]", + "send [x=[400:16:800],y=[320:16:640],sar=[1.0-1.3],par=[1.2-1.3]] recv [x=800,y=600,sar=1.1]", + "recv [x=464,y=384,sar=1.15] send [x=800,y=600,sar=1.1]" }; void test_qos_imageattr() { - tsk_size_t i; - tmedia_imageattr_xt imageattr; - for(i = 0; i < sizeof(__test_imageattrs)/sizeof(__test_imageattrs[0]); ++i){ - if(tmedia_imageattr_parse(&imageattr, __test_imageattrs[i], tsk_strlen(__test_imageattrs[i])) == 0){ - TSK_DEBUG_INFO("image-attr parsed (OK): %s", __test_imageattrs[i]); - } - else{ - TSK_DEBUG_ERROR("image-attr parsed (NOK): %s", __test_imageattrs[i]); - } - } + tsk_size_t i; + tmedia_imageattr_xt imageattr; + for(i = 0; i < sizeof(__test_imageattrs)/sizeof(__test_imageattrs[0]); ++i) { + if(tmedia_imageattr_parse(&imageattr, __test_imageattrs[i], tsk_strlen(__test_imageattrs[i])) == 0) { + TSK_DEBUG_INFO("image-attr parsed (OK): %s", __test_imageattrs[i]); + } + else { + TSK_DEBUG_ERROR("image-attr parsed (NOK): %s", __test_imageattrs[i]); + } + } } diff --git a/tinyMEDIA/test/test_qos.h b/tinyMEDIA/test/test_qos.h index 3565cc2..b1c21ac 100755 --- a/tinyMEDIA/test/test_qos.h +++ b/tinyMEDIA/test/test_qos.h @@ -2,19 +2,19 @@ * Copyright (C) 2009 Mamadou Diop. * * Contact: Mamadou Diop <diopmamadou(at)yahoo.fr> -* +* * This file is part of Open Source Doubango Framework. * * DOUBANGO 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 3 of the License, or * (at your option) any later version. -* +* * DOUBANGO 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 DOUBANGO. * @@ -24,244 +24,244 @@ char* test_qos_tostring(const tmedia_qos_tline_t* tline) { - char* ret = tsk_null; - tsdp_header_M_t* M; - - if(!tline){ - TSK_DEBUG_ERROR("Invalid parameter"); - return tsk_null; - } - - M = tsdp_header_M_create("audio", 20000, "RTP/AVP"); - tmedia_qos_tline_to_sdp(tline, M); - - ret = tsdp_header_tostring(TSDP_HEADER(M)); - TSK_OBJECT_SAFE_FREE(M); - - return ret; + char* ret = tsk_null; + tsdp_header_M_t* M; + + if(!tline) { + TSK_DEBUG_ERROR("Invalid parameter"); + return tsk_null; + } + + M = tsdp_header_M_create("audio", 20000, "RTP/AVP"); + tmedia_qos_tline_to_sdp(tline, M); + + ret = tsdp_header_tostring(TSDP_HEADER(M)); + TSK_OBJECT_SAFE_FREE(M); + + return ret; } void test_qos_parser() { - tsdp_header_M_t* M; - tmedia_qos_tline_e2e_t* e2e; - tmedia_qos_tline_segmented_t* segmented; - char* temp = tsk_null; - tmedia_qos_stype_t type; - tsk_bool_t canresume; - - /* test E2E */ - M = tsdp_header_M_create("audio", 20000, "RTP/AVP"); - e2e = tmedia_qos_tline_e2e_create(tmedia_qos_strength_mandatory); - // to_sdp - tmedia_qos_tline_e2e_to_sdp(e2e, M); - if((type = tmedia_qos_get_type(M)) != tmedia_qos_stype_e2e){ - TSK_DEBUG_ERROR("Invalid type"); - } - if((temp = tsdp_header_tostring(TSDP_HEADER(M)))){ - TSK_DEBUG_INFO("E2E to_sdp: %s", temp); - TSK_FREE(temp); - } - // from_sdp - TSK_OBJECT_SAFE_FREE(e2e); - e2e = tmedia_qos_tline_e2e_from_sdp(M); - canresume = tmedia_qos_tline_e2e_canresume(e2e); - tmedia_qos_tline_e2e_to_sdp(e2e, M); - if((temp = tsdp_header_tostring(TSDP_HEADER(M)))){ - TSK_DEBUG_INFO("e2e from_sdp: %s", temp); - TSK_FREE(temp); - } - - - TSK_OBJECT_SAFE_FREE(e2e); - TSK_OBJECT_SAFE_FREE(M); - - /* test Segmented */ - M = tsdp_header_M_create("video", 20002, "RTP/AVP"); - segmented = tmedia_qos_tline_segmented_create(tmedia_qos_strength_none); - segmented->remote_send.strength = tmedia_qos_strength_optional; - // to_sdp - tmedia_qos_tline_segmented_to_sdp(segmented, M); - if((type = tmedia_qos_get_type(M)) != tmedia_qos_stype_segmented){ - TSK_DEBUG_ERROR("Invalid type"); - } - if((temp = tsdp_header_tostring(TSDP_HEADER(M)))){ - TSK_DEBUG_INFO("Segmented to_sdp: %s", temp); - TSK_FREE(temp); - } - // from_sdp - TSK_OBJECT_SAFE_FREE(segmented); - segmented = tmedia_qos_tline_segmented_from_sdp(M); - canresume = tmedia_qos_tline_segmented_canresume(segmented); - tmedia_qos_tline_segmented_to_sdp(segmented, M); - if((temp = tsdp_header_tostring(TSDP_HEADER(M)))){ - TSK_DEBUG_INFO("Segmented from_sdp: %s", temp); - TSK_FREE(temp); - } - - - - TSK_OBJECT_SAFE_FREE(segmented); - TSK_OBJECT_SAFE_FREE(M); + tsdp_header_M_t* M; + tmedia_qos_tline_e2e_t* e2e; + tmedia_qos_tline_segmented_t* segmented; + char* temp = tsk_null; + tmedia_qos_stype_t type; + tsk_bool_t canresume; + + /* test E2E */ + M = tsdp_header_M_create("audio", 20000, "RTP/AVP"); + e2e = tmedia_qos_tline_e2e_create(tmedia_qos_strength_mandatory); + // to_sdp + tmedia_qos_tline_e2e_to_sdp(e2e, M); + if((type = tmedia_qos_get_type(M)) != tmedia_qos_stype_e2e) { + TSK_DEBUG_ERROR("Invalid type"); + } + if((temp = tsdp_header_tostring(TSDP_HEADER(M)))) { + TSK_DEBUG_INFO("E2E to_sdp: %s", temp); + TSK_FREE(temp); + } + // from_sdp + TSK_OBJECT_SAFE_FREE(e2e); + e2e = tmedia_qos_tline_e2e_from_sdp(M); + canresume = tmedia_qos_tline_e2e_canresume(e2e); + tmedia_qos_tline_e2e_to_sdp(e2e, M); + if((temp = tsdp_header_tostring(TSDP_HEADER(M)))) { + TSK_DEBUG_INFO("e2e from_sdp: %s", temp); + TSK_FREE(temp); + } + + + TSK_OBJECT_SAFE_FREE(e2e); + TSK_OBJECT_SAFE_FREE(M); + + /* test Segmented */ + M = tsdp_header_M_create("video", 20002, "RTP/AVP"); + segmented = tmedia_qos_tline_segmented_create(tmedia_qos_strength_none); + segmented->remote_send.strength = tmedia_qos_strength_optional; + // to_sdp + tmedia_qos_tline_segmented_to_sdp(segmented, M); + if((type = tmedia_qos_get_type(M)) != tmedia_qos_stype_segmented) { + TSK_DEBUG_ERROR("Invalid type"); + } + if((temp = tsdp_header_tostring(TSDP_HEADER(M)))) { + TSK_DEBUG_INFO("Segmented to_sdp: %s", temp); + TSK_FREE(temp); + } + // from_sdp + TSK_OBJECT_SAFE_FREE(segmented); + segmented = tmedia_qos_tline_segmented_from_sdp(M); + canresume = tmedia_qos_tline_segmented_canresume(segmented); + tmedia_qos_tline_segmented_to_sdp(segmented, M); + if((temp = tsdp_header_tostring(TSDP_HEADER(M)))) { + TSK_DEBUG_INFO("Segmented from_sdp: %s", temp); + TSK_FREE(temp); + } + + + + TSK_OBJECT_SAFE_FREE(segmented); + TSK_OBJECT_SAFE_FREE(M); } void test_qos_e2e_neg() { - tmedia_qos_tline_e2e_t *e2eA = tsk_null, *e2eB = tsk_null; - char* temp = tsk_null; + tmedia_qos_tline_e2e_t *e2eA = tsk_null, *e2eB = tsk_null; + char* temp = tsk_null; - /* SDP1: A includes end-to-end quality of service preconditions in the - initial offer. + /* SDP1: A includes end-to-end quality of service preconditions in the + initial offer. - m=audio 20000 RTP/AVP 0 + m=audio 20000 RTP/AVP 0 c=IN IP4 192.0.2.1 a=curr:qos e2e none a=des:qos mandatory e2e sendrecv - */ - e2eA = tmedia_qos_tline_e2e_create(tmedia_qos_strength_mandatory); - if((temp = test_qos_tostring((const tmedia_qos_tline_t*)e2eA))){ - TSK_DEBUG_INFO("SDP1=\n%s", temp); - TSK_FREE(temp); - } - - /* SDP2: Since B uses RSVP, it can know when resources in its "send" - direction are available, because it will receive RESV messages from - the network. However, it does not know the status of the - reservations in the other direction. B requests confirmation for - resource reservations in its "recv" direction to the peer user agent - A in its answer. - - m=audio 30000 RTP/AVP 0 + */ + e2eA = tmedia_qos_tline_e2e_create(tmedia_qos_strength_mandatory); + if((temp = test_qos_tostring((const tmedia_qos_tline_t*)e2eA))) { + TSK_DEBUG_INFO("SDP1=\n%s", temp); + TSK_FREE(temp); + } + + /* SDP2: Since B uses RSVP, it can know when resources in its "send" + direction are available, because it will receive RESV messages from + the network. However, it does not know the status of the + reservations in the other direction. B requests confirmation for + resource reservations in its "recv" direction to the peer user agent + A in its answer. + + m=audio 30000 RTP/AVP 0 c=IN IP4 192.0.2.4 a=curr:qos e2e none a=des:qos mandatory e2e sendrecv a=conf:qos e2e recv - */ - e2eB = tmedia_qos_tline_e2e_create(tmedia_qos_strength_mandatory); - tmedia_qos_tline_e2e_set_ro(e2eB, e2eA); - if((temp = test_qos_tostring((const tmedia_qos_tline_t*)e2eB))){ - TSK_DEBUG_INFO("SDP2=\n%s", temp); - TSK_FREE(temp); - } - - /* SDP3: When A receives RESV messages, it sends an updated offer (5) to B: - - m=audio 20000 RTP/AVP 0 - c=IN IP4 192.0.2.1 - a=curr:qos e2e send - a=des:qos mandatory e2e sendrecv - */ - tmedia_qos_tline_e2e_set_ro(e2eA, e2eB); - if((temp = test_qos_tostring((const tmedia_qos_tline_t*)e2eA))){ - TSK_DEBUG_INFO("SDP3=\n%s", temp); - TSK_FREE(temp); - } - - /* SDP4: B responds with an answer (6) which contains the current status - of the resource reservation (i.e., sendrecv): - - m=audio 30000 RTP/AVP 0 - c=IN IP4 192.0.2.4 - a=curr:qos e2e sendrecv - a=des:qos mandatory e2e sendrecv - */ - tmedia_qos_tline_e2e_set_ro(e2eB, e2eA); - if((temp = test_qos_tostring((const tmedia_qos_tline_t*)e2eB))){ - TSK_DEBUG_INFO("SDP4=\n%s", temp); - TSK_FREE(temp); - } - - /* A receive B's response */ - tmedia_qos_tline_e2e_set_ro(e2eA, e2eB); - if((temp = test_qos_tostring((const tmedia_qos_tline_t*)e2eA))){ - TSK_DEBUG_INFO("SDP5=\n%s", temp); - TSK_FREE(temp); - } - - if(tmedia_qos_tline_e2e_canresume(e2eA)){ - TSK_DEBUG_INFO("A can resume"); - } - else{ - TSK_DEBUG_ERROR("A can't resume"); - } - - if(tmedia_qos_tline_e2e_canresume(e2eB)){ - TSK_DEBUG_INFO("B can resume"); - } - else{ - TSK_DEBUG_ERROR("B can't resume"); - } - - TSK_OBJECT_SAFE_FREE(e2eB); - TSK_OBJECT_SAFE_FREE(e2eA); + */ + e2eB = tmedia_qos_tline_e2e_create(tmedia_qos_strength_mandatory); + tmedia_qos_tline_e2e_set_ro(e2eB, e2eA); + if((temp = test_qos_tostring((const tmedia_qos_tline_t*)e2eB))) { + TSK_DEBUG_INFO("SDP2=\n%s", temp); + TSK_FREE(temp); + } + + /* SDP3: When A receives RESV messages, it sends an updated offer (5) to B: + + m=audio 20000 RTP/AVP 0 + c=IN IP4 192.0.2.1 + a=curr:qos e2e send + a=des:qos mandatory e2e sendrecv + */ + tmedia_qos_tline_e2e_set_ro(e2eA, e2eB); + if((temp = test_qos_tostring((const tmedia_qos_tline_t*)e2eA))) { + TSK_DEBUG_INFO("SDP3=\n%s", temp); + TSK_FREE(temp); + } + + /* SDP4: B responds with an answer (6) which contains the current status + of the resource reservation (i.e., sendrecv): + + m=audio 30000 RTP/AVP 0 + c=IN IP4 192.0.2.4 + a=curr:qos e2e sendrecv + a=des:qos mandatory e2e sendrecv + */ + tmedia_qos_tline_e2e_set_ro(e2eB, e2eA); + if((temp = test_qos_tostring((const tmedia_qos_tline_t*)e2eB))) { + TSK_DEBUG_INFO("SDP4=\n%s", temp); + TSK_FREE(temp); + } + + /* A receive B's response */ + tmedia_qos_tline_e2e_set_ro(e2eA, e2eB); + if((temp = test_qos_tostring((const tmedia_qos_tline_t*)e2eA))) { + TSK_DEBUG_INFO("SDP5=\n%s", temp); + TSK_FREE(temp); + } + + if(tmedia_qos_tline_e2e_canresume(e2eA)) { + TSK_DEBUG_INFO("A can resume"); + } + else { + TSK_DEBUG_ERROR("A can't resume"); + } + + if(tmedia_qos_tline_e2e_canresume(e2eB)) { + TSK_DEBUG_INFO("B can resume"); + } + else { + TSK_DEBUG_ERROR("B can't resume"); + } + + TSK_OBJECT_SAFE_FREE(e2eB); + TSK_OBJECT_SAFE_FREE(e2eA); } void test_qos_segmented_neg() { - tmedia_qos_tline_segmented_t *segA = tsk_null, *segB = tsk_null; - char* temp = tsk_null; - - /* INVITE - a=curr:qos local none - a=curr:qos remote none - a=des:qos mandatory local sendrecv - a=des:qos mandatory remote sendrecv - */ - segA = tmedia_qos_tline_segmented_create(tmedia_qos_strength_mandatory); - if((temp = test_qos_tostring((const tmedia_qos_tline_t*)segA))){ - TSK_DEBUG_INFO("INVITE=\n%s", temp); - TSK_FREE(temp); - } - - /* 183 Sesson progress - a=curr:qos local none - a=curr:qos remote none - a=des:qos mandatory local sendrecv - a=des:qos mandatory remote sendrecv - a=conf:qos remote sendrecv - */ - segB = tmedia_qos_tline_segmented_create(tmedia_qos_strength_mandatory); - tmedia_qos_tline_segmented_set_ro(segB, segA); - if((temp = test_qos_tostring((const tmedia_qos_tline_t*)segB))){ - TSK_DEBUG_INFO("183=\n%s", temp); - TSK_FREE(temp); - } - - /* UPDATE - a=curr:qos local sendrecv - a=curr:qos remote none - a=des:qos mandatory local sendrecv - a=des:qos mandatory remote sendrecv - */ - tmedia_qos_tline_segmented_set_ro(segA, segB); - if((temp = test_qos_tostring((const tmedia_qos_tline_t*)segA))){ - TSK_DEBUG_INFO("UPDATE=\n%s", temp); - TSK_FREE(temp); - } - - /* 200 OK - a=curr:qos local sendrecv - a=curr:qos remote sendrecv - a=des:qos mandatory local sendrecv - a=des:qos mandatory remote sendrecv - */ - tmedia_qos_tline_segmented_set_ro(segB, segA); - if((temp = test_qos_tostring((const tmedia_qos_tline_t*)segB))){ - TSK_DEBUG_INFO("200OK=\n%s", temp); - TSK_FREE(temp); - } - - TSK_OBJECT_SAFE_FREE(segA); - TSK_OBJECT_SAFE_FREE(segB); + tmedia_qos_tline_segmented_t *segA = tsk_null, *segB = tsk_null; + char* temp = tsk_null; + + /* INVITE + a=curr:qos local none + a=curr:qos remote none + a=des:qos mandatory local sendrecv + a=des:qos mandatory remote sendrecv + */ + segA = tmedia_qos_tline_segmented_create(tmedia_qos_strength_mandatory); + if((temp = test_qos_tostring((const tmedia_qos_tline_t*)segA))) { + TSK_DEBUG_INFO("INVITE=\n%s", temp); + TSK_FREE(temp); + } + + /* 183 Sesson progress + a=curr:qos local none + a=curr:qos remote none + a=des:qos mandatory local sendrecv + a=des:qos mandatory remote sendrecv + a=conf:qos remote sendrecv + */ + segB = tmedia_qos_tline_segmented_create(tmedia_qos_strength_mandatory); + tmedia_qos_tline_segmented_set_ro(segB, segA); + if((temp = test_qos_tostring((const tmedia_qos_tline_t*)segB))) { + TSK_DEBUG_INFO("183=\n%s", temp); + TSK_FREE(temp); + } + + /* UPDATE + a=curr:qos local sendrecv + a=curr:qos remote none + a=des:qos mandatory local sendrecv + a=des:qos mandatory remote sendrecv + */ + tmedia_qos_tline_segmented_set_ro(segA, segB); + if((temp = test_qos_tostring((const tmedia_qos_tline_t*)segA))) { + TSK_DEBUG_INFO("UPDATE=\n%s", temp); + TSK_FREE(temp); + } + + /* 200 OK + a=curr:qos local sendrecv + a=curr:qos remote sendrecv + a=des:qos mandatory local sendrecv + a=des:qos mandatory remote sendrecv + */ + tmedia_qos_tline_segmented_set_ro(segB, segA); + if((temp = test_qos_tostring((const tmedia_qos_tline_t*)segB))) { + TSK_DEBUG_INFO("200OK=\n%s", temp); + TSK_FREE(temp); + } + + TSK_OBJECT_SAFE_FREE(segA); + TSK_OBJECT_SAFE_FREE(segB); } void test_qos() { - //test_qos_parser(); - //test_qos_e2e_neg(); - test_qos_segmented_neg(); + //test_qos_parser(); + //test_qos_e2e_neg(); + test_qos_segmented_neg(); } #endif /* _TEST_QOS_H_ */ diff --git a/tinyMEDIA/test/test_sessions.h b/tinyMEDIA/test/test_sessions.h index 97f5d56..bb39fd7 100755 --- a/tinyMEDIA/test/test_sessions.h +++ b/tinyMEDIA/test/test_sessions.h @@ -2,19 +2,19 @@ * Copyright (C) 2009 Mamadou Diop. * * Contact: Mamadou Diop <diopmamadou(at)yahoo.fr> -* +* * This file is part of Open Source Doubango Framework. * * DOUBANGO 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 3 of the License, or * (at your option) any later version. -* +* * DOUBANGO 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 DOUBANGO. * @@ -71,176 +71,176 @@ void test_sessions_client() { - tmedia_session_mgr_t* mgr; - const tsdp_message_t* sdp_lo; - tsdp_message_t* sdp_ro; - char* temp; - tsk_bool_t canresume; - tmedia_type_t media_type = (tmedia_audio | tmedia_video | tmedia_msrp | tmedia_t38); - - int32_t width = 176; - int64_t height = 144LL; - - - /* create manager */ - mgr = tmedia_session_mgr_create((tmedia_audio | tmedia_video | tmedia_msrp | tmedia_t38), - "0.0.0.0", tsk_false, tsk_true); - tmedia_session_mgr_set_qos(mgr, tmedia_qos_stype_segmented, tmedia_qos_strength_mandatory); - - tmedia_session_mgr_set(mgr, - TMEDIA_SESSION_VIDEO_SET_INT32("width", width), - TMEDIA_SESSION_VIDEO_SET_INT64("height", height), - TMEDIA_SESSION_VIDEO_SET_STR("description", "This is my session"), - TMEDIA_SESSION_AUDIO_SET_INT32("rate", "8000"), - TMEDIA_SESSION_SET_STR(tmedia_audio | tmedia_video, "hello", "world"), - TMEDIA_SESSION_SET_NULL()); - - /* get lo */ - sdp_lo = tmedia_session_mgr_get_lo(mgr); - if((temp = tsdp_message_tostring(sdp_lo))){ - TSK_DEBUG_INFO("sdp_lo=%s", temp); - TSK_FREE(temp); - } - - /* set ro */ - if((sdp_ro = tsdp_message_parse(SDP_RO, tsk_strlen(SDP_RO)))){ - tmedia_session_mgr_set_ro(mgr, sdp_ro); - TSK_OBJECT_SAFE_FREE(sdp_ro); - } - - /* get lo */ - sdp_lo = tmedia_session_mgr_get_lo(mgr); - if((temp = tsdp_message_tostring(sdp_lo))){ - TSK_DEBUG_INFO("sdp_lo=%s", temp); - TSK_FREE(temp); - } - - tmedia_session_mgr_start(mgr); - - canresume = tmedia_session_mgr_canresume(mgr); - - TSK_OBJECT_SAFE_FREE(mgr); + tmedia_session_mgr_t* mgr; + const tsdp_message_t* sdp_lo; + tsdp_message_t* sdp_ro; + char* temp; + tsk_bool_t canresume; + tmedia_type_t media_type = (tmedia_audio | tmedia_video | tmedia_msrp | tmedia_t38); + + int32_t width = 176; + int64_t height = 144LL; + + + /* create manager */ + mgr = tmedia_session_mgr_create((tmedia_audio | tmedia_video | tmedia_msrp | tmedia_t38), + "0.0.0.0", tsk_false, tsk_true); + tmedia_session_mgr_set_qos(mgr, tmedia_qos_stype_segmented, tmedia_qos_strength_mandatory); + + tmedia_session_mgr_set(mgr, + TMEDIA_SESSION_VIDEO_SET_INT32("width", width), + TMEDIA_SESSION_VIDEO_SET_INT64("height", height), + TMEDIA_SESSION_VIDEO_SET_STR("description", "This is my session"), + TMEDIA_SESSION_AUDIO_SET_INT32("rate", "8000"), + TMEDIA_SESSION_SET_STR(tmedia_audio | tmedia_video, "hello", "world"), + TMEDIA_SESSION_SET_NULL()); + + /* get lo */ + sdp_lo = tmedia_session_mgr_get_lo(mgr); + if((temp = tsdp_message_tostring(sdp_lo))) { + TSK_DEBUG_INFO("sdp_lo=%s", temp); + TSK_FREE(temp); + } + + /* set ro */ + if((sdp_ro = tsdp_message_parse(SDP_RO, tsk_strlen(SDP_RO)))) { + tmedia_session_mgr_set_ro(mgr, sdp_ro); + TSK_OBJECT_SAFE_FREE(sdp_ro); + } + + /* get lo */ + sdp_lo = tmedia_session_mgr_get_lo(mgr); + if((temp = tsdp_message_tostring(sdp_lo))) { + TSK_DEBUG_INFO("sdp_lo=%s", temp); + TSK_FREE(temp); + } + + tmedia_session_mgr_start(mgr); + + canresume = tmedia_session_mgr_canresume(mgr); + + TSK_OBJECT_SAFE_FREE(mgr); } void test_sessions_server() { - tmedia_session_mgr_t* mgr = tsk_null; - const tsdp_message_t* sdp_lo; - tsdp_message_t* sdp_ro = tsk_null; - char* temp; - tmedia_type_t type; - - /* parse ro */ - if(!(sdp_ro = tsdp_message_parse(SDP_RO, tsk_strlen(SDP_RO)))){ - TSK_DEBUG_ERROR("Failed to parse ro"); - return; - } - else{ - /* get ro media type */ - type = tmedia_type_from_sdp(sdp_ro); - } - - /* create manager */ - mgr = tmedia_session_mgr_create(type, "192.168.16.82", tsk_false, tsk_false); - - /* set ro */ - tmedia_session_mgr_set_ro(mgr, sdp_ro); - - /* get lo */ - sdp_lo = tmedia_session_mgr_get_lo(mgr); - if((temp = tsdp_message_tostring(sdp_lo))){ - TSK_DEBUG_INFO("sdp_lo=%s", temp); - TSK_FREE(temp); - } - - TSK_OBJECT_SAFE_FREE(sdp_ro); - TSK_OBJECT_SAFE_FREE(mgr); + tmedia_session_mgr_t* mgr = tsk_null; + const tsdp_message_t* sdp_lo; + tsdp_message_t* sdp_ro = tsk_null; + char* temp; + tmedia_type_t type; + + /* parse ro */ + if(!(sdp_ro = tsdp_message_parse(SDP_RO, tsk_strlen(SDP_RO)))) { + TSK_DEBUG_ERROR("Failed to parse ro"); + return; + } + else { + /* get ro media type */ + type = tmedia_type_from_sdp(sdp_ro); + } + + /* create manager */ + mgr = tmedia_session_mgr_create(type, "192.168.16.82", tsk_false, tsk_false); + + /* set ro */ + tmedia_session_mgr_set_ro(mgr, sdp_ro); + + /* get lo */ + sdp_lo = tmedia_session_mgr_get_lo(mgr); + if((temp = tsdp_message_tostring(sdp_lo))) { + TSK_DEBUG_INFO("sdp_lo=%s", temp); + TSK_FREE(temp); + } + + TSK_OBJECT_SAFE_FREE(sdp_ro); + TSK_OBJECT_SAFE_FREE(mgr); } void test_sessions_hold_resume() { - tmedia_session_mgr_t* mgr; - const tsdp_message_t* sdp_lo; - char* temp; - tmedia_type_t type = tmedia_audio | tmedia_video | tmedia_msrp | tmedia_t38; - - /* create manager */ - mgr = tmedia_session_mgr_create(type, "192.168.16.82", tsk_false, tsk_true); - - /* get lo */ - sdp_lo = tmedia_session_mgr_get_lo(mgr); - if((temp = tsdp_message_tostring(sdp_lo))){ - TSK_DEBUG_INFO("sdp_lo=%s", temp); - TSK_FREE(temp); - } - - /* hold */ - tmedia_session_mgr_hold(mgr, type); - sdp_lo = tmedia_session_mgr_get_lo(mgr); - if((temp = tsdp_message_tostring(sdp_lo))){ - TSK_DEBUG_INFO("sdp_lo(hold)=%s", temp); - TSK_FREE(temp); - } - TSK_DEBUG_INFO("Hold local=%s and remote=%s", - tmedia_session_mgr_is_held(mgr, type, tsk_true) ? "yes" : "no", - tmedia_session_mgr_is_held(mgr, type, tsk_false) ? "yes" : "no" - ); - - /* resume */ - tmedia_session_mgr_resume(mgr, type, tsk_true); - sdp_lo = tmedia_session_mgr_get_lo(mgr); - if((temp = tsdp_message_tostring(sdp_lo))){ - TSK_DEBUG_INFO("sdp_lo(resume)=%s", temp); - TSK_FREE(temp); - } - TSK_DEBUG_INFO("Hold local=%s and remote=%s", - tmedia_session_mgr_is_held(mgr, type, tsk_true) ? "yes" : "no", - tmedia_session_mgr_is_held(mgr, type, tsk_false) ? "yes" : "no" - ); - - TSK_OBJECT_SAFE_FREE(mgr); + tmedia_session_mgr_t* mgr; + const tsdp_message_t* sdp_lo; + char* temp; + tmedia_type_t type = tmedia_audio | tmedia_video | tmedia_msrp | tmedia_t38; + + /* create manager */ + mgr = tmedia_session_mgr_create(type, "192.168.16.82", tsk_false, tsk_true); + + /* get lo */ + sdp_lo = tmedia_session_mgr_get_lo(mgr); + if((temp = tsdp_message_tostring(sdp_lo))) { + TSK_DEBUG_INFO("sdp_lo=%s", temp); + TSK_FREE(temp); + } + + /* hold */ + tmedia_session_mgr_hold(mgr, type); + sdp_lo = tmedia_session_mgr_get_lo(mgr); + if((temp = tsdp_message_tostring(sdp_lo))) { + TSK_DEBUG_INFO("sdp_lo(hold)=%s", temp); + TSK_FREE(temp); + } + TSK_DEBUG_INFO("Hold local=%s and remote=%s", + tmedia_session_mgr_is_held(mgr, type, tsk_true) ? "yes" : "no", + tmedia_session_mgr_is_held(mgr, type, tsk_false) ? "yes" : "no" + ); + + /* resume */ + tmedia_session_mgr_resume(mgr, type, tsk_true); + sdp_lo = tmedia_session_mgr_get_lo(mgr); + if((temp = tsdp_message_tostring(sdp_lo))) { + TSK_DEBUG_INFO("sdp_lo(resume)=%s", temp); + TSK_FREE(temp); + } + TSK_DEBUG_INFO("Hold local=%s and remote=%s", + tmedia_session_mgr_is_held(mgr, type, tsk_true) ? "yes" : "no", + tmedia_session_mgr_is_held(mgr, type, tsk_false) ? "yes" : "no" + ); + + TSK_OBJECT_SAFE_FREE(mgr); } void test_sessions_add_remove() { - tmedia_session_mgr_t* mgr = tsk_null; - const tsdp_message_t* sdp_lo; - tsdp_message_t* sdp_ro = tsk_null; - char* temp; - tmedia_type_t type; - - /* parse ro */ - if(!(sdp_ro = tsdp_message_parse(SDP_RO, tsk_strlen(SDP_RO)))){ - TSK_DEBUG_ERROR("Failed to parse ro"); - return; - } - else{ - /* get ro media type */ - type = tmedia_type_from_sdp(sdp_ro); - } - - /* create manager */ - mgr = tmedia_session_mgr_create(type, "192.168.16.82", tsk_false, tsk_false); - - /* set ro */ - tmedia_session_mgr_set_ro(mgr, sdp_ro); - - /* get lo */ - sdp_lo = tmedia_session_mgr_get_lo(mgr); - if((temp = tsdp_message_tostring(sdp_lo))){ - TSK_DEBUG_INFO("sdp_lo=%s", temp); - TSK_FREE(temp); - } - - TSK_OBJECT_SAFE_FREE(sdp_ro); - TSK_OBJECT_SAFE_FREE(mgr); + tmedia_session_mgr_t* mgr = tsk_null; + const tsdp_message_t* sdp_lo; + tsdp_message_t* sdp_ro = tsk_null; + char* temp; + tmedia_type_t type; + + /* parse ro */ + if(!(sdp_ro = tsdp_message_parse(SDP_RO, tsk_strlen(SDP_RO)))) { + TSK_DEBUG_ERROR("Failed to parse ro"); + return; + } + else { + /* get ro media type */ + type = tmedia_type_from_sdp(sdp_ro); + } + + /* create manager */ + mgr = tmedia_session_mgr_create(type, "192.168.16.82", tsk_false, tsk_false); + + /* set ro */ + tmedia_session_mgr_set_ro(mgr, sdp_ro); + + /* get lo */ + sdp_lo = tmedia_session_mgr_get_lo(mgr); + if((temp = tsdp_message_tostring(sdp_lo))) { + TSK_DEBUG_INFO("sdp_lo=%s", temp); + TSK_FREE(temp); + } + + TSK_OBJECT_SAFE_FREE(sdp_ro); + TSK_OBJECT_SAFE_FREE(mgr); } void test_sessions() { - test_sessions_client(); - //test_sessions_server(); - //test_sessions_hold_resume(); + test_sessions_client(); + //test_sessions_server(); + //test_sessions_hold_resume(); } #endif /* _TEST_SESSIONS_H_ */ |