summaryrefslogtreecommitdiffstats
path: root/tinyMEDIA/test
diff options
context:
space:
mode:
Diffstat (limited to 'tinyMEDIA/test')
-rw-r--r--tinyMEDIA/test/droid-makefile29
-rw-r--r--tinyMEDIA/test/dummy.c173
-rw-r--r--tinyMEDIA/test/dummy.h43
-rw-r--r--tinyMEDIA/test/test.c162
-rw-r--r--tinyMEDIA/test/test.vcproj213
-rw-r--r--tinyMEDIA/test/test_codecs.h37
-rw-r--r--tinyMEDIA/test/test_contents.h89
-rw-r--r--tinyMEDIA/test/test_qos.h267
-rw-r--r--tinyMEDIA/test/test_sessions.h244
9 files changed, 1257 insertions, 0 deletions
diff --git a/tinyMEDIA/test/droid-makefile b/tinyMEDIA/test/droid-makefile
new file mode 100644
index 0000000..192affd
--- /dev/null
+++ b/tinyMEDIA/test/droid-makefile
@@ -0,0 +1,29 @@
+APP := test
+
+CFLAGS := $(CFLAGS_COMMON) -I../include -I../../tinySAK/src -I../../tinyNET/src -I../../tinySDP/include
+LDFLAGS := $(LDFLAGS_COMMON) -Wl,-Bsymbolic,--whole-archive -l$(PROJECT) -ltinySAK -ltinyNET -ltinySDP -Wl,--entry=main
+
+all: $(APP)
+
+OBJS += $(APP).o \
+ dummy.o
+
+$(APP): $(OBJS)
+ $(CC) $(LDFLAGS) -o $@ $^
+
+%.o: %.c
+ $(CC) -c $(INCLUDE) $(CFLAGS) $< -o $@
+
+install: $(APP)
+ $(ANDROID_SDK_ROOT)/tools/adb push $(APP) $(EXEC_DIR)/$(APP)
+ $(ANDROID_SDK_ROOT)/tools/adb shell chmod 777 $(EXEC_DIR)/$(APP)
+
+run:
+ $(ANDROID_SDK_ROOT)/tools/adb shell $(EXEC_DIR)/$(APP)
+
+#dbg:
+# $(MAKE) $(MAKEFILE) DEBUG="-g -DDEBUG"
+# $(MAKE) $(MAKEFILE) install
+
+clean:
+ @rm -f $(OBJS) $(APP) \ No newline at end of file
diff --git a/tinyMEDIA/test/dummy.c b/tinyMEDIA/test/dummy.c
new file mode 100644
index 0000000..18799aa
--- /dev/null
+++ b/tinyMEDIA/test/dummy.c
@@ -0,0 +1,173 @@
+/*
+* 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.
+*
+*/
+#include "dummy.h"
+
+#include "tsk_string.h"
+#include "tsk_memory.h"
+#include "tsk_debug.h"
+
+int dummy_start(tmedia_t* self)
+{
+ dummy_t *dummy = DUMMY(self);
+ TSK_DEBUG_INFO("dummy_start");
+
+ return 0;
+}
+
+int dummy_pause(tmedia_t* self)
+{
+ dummy_t *dummy = DUMMY(self);
+ TSK_DEBUG_INFO("dummy_pause");
+
+ return 0;
+}
+
+int dummy_stop(tmedia_t* self)
+{
+ 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;
+
+ 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);
+ }
+
+ 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");
+
+ 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");
+
+ 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 media object definition
+//
+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;
+}
+
+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;
+}
+static int dummy_cmp(const tsk_object_t *obj1, const tsk_object_t *obj2)
+{
+ return -1;
+}
+
+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;
+
+//========================================================
+// Dummy media plugin definition
+//
+static const tmedia_plugin_def_t dummy_plugin_def_s =
+{
+ &dummy_def_s,
+ "dummy plugin",
+ "audio",
+
+ dummy_start,
+ dummy_pause,
+ dummy_stop,
+
+ dummy_get_local_offer,
+ dummy_get_negotiated_offer,
+ dummy_set_remote_offer,
+
+ 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
new file mode 100644
index 0000000..a0319e3
--- /dev/null
+++ b/tinyMEDIA/test/dummy.h
@@ -0,0 +1,43 @@
+/*
+* 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.
+*
+*/
+#ifndef TEST_MEDIA_DUMMY_H
+#define TEST_MEDIA_DUMMY_H
+
+#include "tinymedia/tmedia.h"
+
+#define DUMMY(self) ((dummy_t*)(self))
+
+typedef struct dummy_s
+{
+ TMED_DECLARE_MEDIA;
+
+ char* local_sdp;
+ char* remote_sdp;
+ char* negotiated_sdp;
+}
+dummy_t;
+
+const tsk_object_def_t *dummy_def_t;
+const tmedia_plugin_def_t *dummy_plugin_def_t;
+
+
+#endif /* TEST_MEDIA_DUMMY_H */
diff --git a/tinyMEDIA/test/test.c b/tinyMEDIA/test/test.c
new file mode 100644
index 0000000..8235bd2
--- /dev/null
+++ b/tinyMEDIA/test/test.c
@@ -0,0 +1,162 @@
+/*
+* 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.
+*
+*/
+#include "tinymedia/tmedia.h"
+//#include "dummy.h"
+
+#include "tinymedia.h"
+
+#include "test_codecs.h"
+#include "test_sessions.h"
+#include "test_qos.h"
+#include "test_contents.h"
+
+#define RUN_TEST_LOOP 1
+
+#define RUN_TEST_ALL 0
+#define RUN_TEST_CODECS 0
+#define RUN_TEST_SESSIONS 0
+#define RUN_TEST_QOS 0
+#define RUN_TEST_CONTENTS 1
+
+static void test_register_dummy_plugins();
+static void test_register_contents_plugins();
+
+#ifdef _WIN32_WCE
+int _tmain(int argc, _TCHAR* argv[])
+#else
+int main()
+#endif
+{
+ /* Register dummy plugins */
+ test_register_dummy_plugins();
+ /* Register content plugins */
+ test_register_contents_plugins();
+
+ do {
+
+#if RUN_TEST_ALL || RUN_TEST_CODECS
+ test_codecs();
+#endif
+
+#if RUN_TEST_ALL || RUN_TEST_SESSIONS
+ test_sessions();
+#endif
+
+#if RUN_TEST_ALL || RUN_TEST_QOS
+ test_qos();
+#endif
+
+#if RUN_TEST_ALL || RUN_TEST_CONTENTS
+ test_contents();
+#endif
+
+ }
+ 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);
+}
+
+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");
+ }
+}
+
+//#ifdef _WIN32_WCE
+//int _tmain(int argc, _TCHAR* argv[])
+//#else
+//int main()
+//#endif
+//{
+// 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_start(dummy);
+// tmedia_pause(dummy);
+//
+// tmedia_perform(dummy, tma_dummy_say_hello,
+// TSK_PARAM_VA_ARGS("to", "doubango"),
+//
+// tsk_null);
+//
+// tmedia_stop(dummy);
+//
+// TSK_OBJECT_SAFE_FREE(dummy);
+// }
+// }
+//
+// return 0;
+//}
+
diff --git a/tinyMEDIA/test/test.vcproj b/tinyMEDIA/test/test.vcproj
new file mode 100644
index 0000000..94a7851
--- /dev/null
+++ b/tinyMEDIA/test/test.vcproj
@@ -0,0 +1,213 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="9.00"
+ Name="test"
+ ProjectGUID="{6ED4F246-C3B7-4DD5-9434-3A3F69CC0AD6}"
+ RootNamespace="test"
+ Keyword="Win32Proj"
+ TargetFrameworkVersion="196613"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories="&quot;$(DOUBANGO_HOME)\thirdparties\win32\include&quot;;&quot;$(SolutionDir)\include&quot;;&quot;$(DOUBANGO_HOME)\tinyNET\src&quot;;&quot;$(DOUBANGO_HOME)\tinySAK\src&quot;;&quot;$(DOUBANGO_HOME)\tinySDP\include&quot;"
+ PreprocessorDefinitions="DEBUG_LEVEL=DEBUG_LEVEL_INFO;WIN32;_DEBUG;_CONSOLE"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="3"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ WarnAsError="true"
+ DebugInformationFormat="4"
+ CompileAs="1"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="$(OutDir)\tinySAK.lib $(OutDir)\tinyMEDIA.lib $(OutDir)\tinySDP.lib"
+ LinkIncremental="2"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="1"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ EnableIntrinsicFunctions="true"
+ PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
+ RuntimeLibrary="2"
+ EnableFunctionLevelLinking="true"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ WarnAsError="true"
+ DebugInformationFormat="3"
+ CompileAs="1"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ LinkIncremental="1"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="source"
+ >
+ <File
+ RelativePath=".\test.c"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="include"
+ >
+ <File
+ RelativePath=".\dummy.h"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="tests"
+ >
+ <File
+ RelativePath=".\test_codecs.h"
+ >
+ </File>
+ <File
+ RelativePath=".\test_contents.h"
+ >
+ </File>
+ <File
+ RelativePath=".\test_qos.h"
+ >
+ </File>
+ <File
+ RelativePath=".\test_sessions.h"
+ >
+ </File>
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/tinyMEDIA/test/test_codecs.h b/tinyMEDIA/test/test_codecs.h
new file mode 100644
index 0000000..2be6c46
--- /dev/null
+++ b/tinyMEDIA/test/test_codecs.h
@@ -0,0 +1,37 @@
+/*
+* 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.
+*
+*/
+#ifndef _TEST_CODECS_H_
+#define _TEST_CODECS_H_
+
+void test_codecs()
+{
+ tmedia_codec_t* pcmu, *pcma;
+
+ /* 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);
+}
+
+#endif /* _TEST_CODECS_H_ */
diff --git a/tinyMEDIA/test/test_contents.h b/tinyMEDIA/test/test_contents.h
new file mode 100644
index 0000000..096d7cf
--- /dev/null
+++ b/tinyMEDIA/test/test_contents.h
@@ -0,0 +1,89 @@
+/*
+* 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.
+*
+*/
+#ifndef _TEST_CONTENTS_H_
+#define _TEST_CONTENTS_H_
+
+static void test_content_dummy();
+static void test_content_text_plain();
+static void test_content_cpim();
+
+static void test_contents()
+{
+ test_content_dummy();
+ test_content_text_plain();
+ test_content_cpim();
+}
+
+
+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);
+ }
+
+ 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);
+ }
+
+ TSK_OBJECT_SAFE_FREE(content);
+}
+
+static void test_content_cpim()
+{
+#define CONTENT_CPIM_DATA "To: <sip:test@doubango.org>\r\n" \
+"From: <sip:test@doubango.org>\r\n" \
+"DateTime: 2010-12-17T09:57:32.562Z\r\n" \
+"Content-Disposition: attachment; filename=\"history.xml\"; creation-date=\"2010-12-17T09:19:56.978Z\"; size=3714\r\n" \
+"\r\n" \
+"Content-Type: application/octet-stream\r\n" \
+"Content-ID: <1234567890@doubango.org>\r\n" \
+"\r\n" \
+"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);
+ }
+
+ TSK_OBJECT_SAFE_FREE(content);
+}
+
+#endif /* _TEST_CONTENTS_H_ */
+
diff --git a/tinyMEDIA/test/test_qos.h b/tinyMEDIA/test/test_qos.h
new file mode 100644
index 0000000..c91b294
--- /dev/null
+++ b/tinyMEDIA/test/test_qos.h
@@ -0,0 +1,267 @@
+/*
+* 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.
+*
+*/
+#ifndef _TEST_QOS_H_
+#define _TEST_QOS_H_
+
+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;
+}
+
+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);
+}
+
+
+void test_qos_e2e_neg()
+{
+ 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.
+
+ 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
+ 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);
+}
+
+
+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);
+}
+
+void test_qos()
+{
+ //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
new file mode 100644
index 0000000..0807511
--- /dev/null
+++ b/tinyMEDIA/test/test_sessions.h
@@ -0,0 +1,244 @@
+/*
+* 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.
+*
+*/
+#ifndef _TEST_SESSIONS_H_
+#define _TEST_SESSIONS_H_
+
+#define SDP_RO \
+ "v=0\r\n" \
+ "o=alice 2890844526 2890844526 IN IP4 host.atlanta.example.com\r\n" \
+ "s=\r\n" \
+ "i=A Seminar on the session description protocol\r\n" \
+ "u=http://www.example.com/seminars/sdp.pdf\r\n" \
+ "e=j.doe@example.com (Jane Doe)\r\n" \
+ "p=+1 617 555-6011\r\n" \
+ "c=IN IP4 host.atlanta.example.com\r\n" \
+ "b=X-YZ:128\r\n" \
+ "z=2882844526 -1h 2898848070 0\r\n" \
+ "k=base64:ZWFzdXJlLg==\r\n" \
+ "t=3034423619 3042462419\r\n" \
+ "r=7d 1h 0 25h\r\n" \
+ "r=604800 3600 0 90000\r\n" \
+ "w=my dummy header\r\n" \
+ "m=audio 49170 RTP/AVP 8 0 97 98\r\n" \
+ "i=Audio line\r\n" \
+ "c=IN IP4 otherhost.biloxi.example.com\r\n" \
+ "k=base64:ZWFzdXJlLgdddddddddddddddddddddd==\r\n" \
+ "a=rtpmap:8 PCMA/8000\r\n" \
+ "a=rtpmap:0 PCMU/8000\r\n" \
+ "a=rtpmap:97 iLBC/8000\r\n" \
+ "a=rtpmap:98 AMR-WB/16000\r\n" \
+ "a=curr:qos local none\r\n" \
+ "a=curr:qos remote none\r\n" \
+ "a=des:qos mandatory local sendrecv\r\n" \
+ "a=des:qos mandatory remote sendrecv\r\n" \
+ "a=conf:qos remote sendrecv\r\n" \
+ "a=fmtp:98 octet-align=1\r\n" \
+ "m=video 51372 RTP/AVP 31 32 98\r\n" \
+ "i=Video line\r\n" \
+ "b=A-YZ:92\r\n" \
+ "b=B-YZ:256\r\n" \
+ "a=rtpmap:31 H261/90000\r\n" \
+ "a=rtpmap:32 MPV/90000\r\n" \
+ "a=rtpmap:98 H264/90000\r\n" \
+ "a=fmtp:98 profile-level-id=42A01E\r\n" \
+ "a=recvonly\r\n" \
+ "m=toto 51372 RTP/AVP 31 32\r\n" \
+ "i=Video line\r\n" \
+ "b=A-YZ:92\r\n" \
+ "b=B-YZ:256\r\n" \
+ "a=rtpmap:31 H261/90000\r\n" \
+ "a=rtpmap:32 MPV/90000\r\n" \
+ "a=recvonly\r\n"
+
+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);
+ }
+
+ 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);
+}
+
+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);
+ 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);
+}
+
+void test_sessions()
+{
+ test_sessions_client();
+ //test_sessions_server();
+ //test_sessions_hold_resume();
+}
+
+#endif /* _TEST_SESSIONS_H_ */
OpenPOWER on IntegriCloud