diff options
author | Mamadou DIOP <bossiel@yahoo.fr> | 2015-08-17 01:56:35 +0200 |
---|---|---|
committer | Mamadou DIOP <bossiel@yahoo.fr> | 2015-08-17 01:56:35 +0200 |
commit | 631fffee8a28b1bec5ed1f1d26a20e0135967f99 (patch) | |
tree | 74afe3bf3efe15aa82bcd0272b2b0f4d48c2d837 /tinySDP/include/tinysdp | |
parent | 7908865936604036e6f200f1b5e069f8752f3a3a (diff) | |
download | doubango-631fffee8a28b1bec5ed1f1d26a20e0135967f99.zip doubango-631fffee8a28b1bec5ed1f1d26a20e0135967f99.tar.gz |
-
Diffstat (limited to 'tinySDP/include/tinysdp')
20 files changed, 1565 insertions, 0 deletions
diff --git a/tinySDP/include/tinysdp/headers/tsdp_header.h b/tinySDP/include/tinysdp/headers/tsdp_header.h new file mode 100644 index 0000000..ce669b5 --- /dev/null +++ b/tinySDP/include/tinysdp/headers/tsdp_header.h @@ -0,0 +1,124 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop <diopmamadou(at)doubango[dot]org> +* +* 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. +* +*/ + +/**@file tsdp_header.h + * @brief Defines a SDP header/line (<type>=<value>). + * + * @author Mamadou Diop <diopmamadou(at)doubango[dot]org> + * + + */ +#ifndef TINYSDP_HEADER_H +#define TINYSDP_HEADER_H + +#include "tinysdp_config.h" + +#include "tsk_ragel_state.h" +#include "tsk_list.h" + +TSDP_BEGIN_DECLS + +struct tsdp_header_s; + +#define TSDP_HEADER(self) ((tsdp_header_t*)(self)) +#define TSDP_HEADER_CONST(self) ((const tsdp_header_t*)(self)) +#define TSDP_HEADER_VALUE_TOSTRING_F(self) ((tsdp_header_value_tostring_f)(self)) + +typedef int (*tsdp_header_value_tostring_f)(const struct tsdp_header_s* header, tsk_buffer_t* output); +typedef struct tsdp_header_s* (*tsdp_header_clone_f)(const struct tsdp_header_s* header); + +#define TSDP_HTYPE_V_RANK 0 +#define TSDP_HTYPE_O_RANK 1 +#define TSDP_HTYPE_S_RANK 2 +#define TSDP_HTYPE_I_RANK 3 +#define TSDP_HTYPE_U_RANK 4 +#define TSDP_HTYPE_E_RANK 5 +#define TSDP_HTYPE_P_RANK 6 +#define TSDP_HTYPE_C_RANK 7 +#define TSDP_HTYPE_B_RANK 8 +#define TSDP_HTYPE_Z_RANK 11 +#define TSDP_HTYPE_K_RANK 12 +#define TSDP_HTYPE_A_RANK 13 +#define TSDP_HTYPE_T_RANK 9 +#define TSDP_HTYPE_R_RANK 10 +#define TSDP_HTYPE_M_RANK 14 +//#define TSDP_HTYPE_I_RANK 15 +//#define TSDP_HTYPE_C_RANK 16 +//#define TSDP_HTYPE_B_RANK 17 + +#define TSDP_HTYPE_DUMMY_RANK 255 + +/** + * @enum tsdp_header_type_e + * + * @brief List of all supported headers. +**/ +typedef enum tsdp_header_type_e +{ + tsdp_htype_A, + tsdp_htype_B, + tsdp_htype_C, + tsdp_htype_Dummy, + tsdp_htype_E, + tsdp_htype_I, + tsdp_htype_K, + tsdp_htype_M, + tsdp_htype_O, + tsdp_htype_P, + tsdp_htype_R, + tsdp_htype_S, + tsdp_htype_T, + tsdp_htype_U, + tsdp_htype_V, + tsdp_htype_Z +} +tsdp_header_type_t; + +/*================================ +*/ +typedef struct tsdp_header_s +{ + TSK_DECLARE_OBJECT; + tsdp_header_type_t type; + //! Because all SDP headers shall appear in a fixed order, the rank is used to place each header. + // Info: RFC 4566 - 5. SDP Specification. + uint8_t rank; + tsdp_header_value_tostring_f tostring; + tsdp_header_clone_f clone; +} +tsdp_header_t; + +#define TSDP_DECLARE_HEADER tsdp_header_t __header__ +typedef tsk_list_t tsdp_headers_L_t; /**< List of @ref tsdp_header_t elements. */ +/* +================================*/ + +int tsdp_header_rank_cmp(const tsdp_header_t*, const tsdp_header_t*); +TINYSDP_API tsdp_header_t* tsdp_header_clone(const tsdp_header_t*); +TINYSDP_API char tsdp_header_get_name(tsdp_header_type_t type); +TINYSDP_API char tsdp_header_get_nameex(const tsdp_header_t *self); +TINYSDP_API int tsdp_header_serialize(const tsdp_header_t *self, tsk_buffer_t *output); +TINYSDP_API char* tsdp_header_tostring(const tsdp_header_t *self); + +TSDP_END_DECLS + +#endif /* TINYSDP_HEADER_H */ diff --git a/tinySDP/include/tinysdp/headers/tsdp_header_A.h b/tinySDP/include/tinysdp/headers/tsdp_header_A.h new file mode 100644 index 0000000..04aff7f --- /dev/null +++ b/tinySDP/include/tinysdp/headers/tsdp_header_A.h @@ -0,0 +1,76 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop <diopmamadou(at)doubango[dot]org> +* +* 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. +* +*/ + +/**@file tsdp_header_A.h + * @brief SDP "a=" header (Attributes). + * + * @author Mamadou Diop <diopmamadou(at)doubango[dot]org> + * + * + */ +#ifndef _TSDP_HEADER_A_H_ +#define _TSDP_HEADER_A_H_ + +#include "tinysdp_config.h" +#include "tinysdp/headers/tsdp_header.h" + +TSDP_BEGIN_DECLS + +#define TSDP_HEADER_A_VA_ARGS(field, value) tsdp_header_A_def_t, (const char*)(field), (const char*)(value) + +#define TSDP_HEADER_A(self) ((tsdp_header_A_t*)(self)) + +//////////////////////////////////////////////////////////////////////////////////////////////////// +/// @struct +/// +/// @brief SDP "a=" header (Attributes). +/// +/// @par ABNF : a=attribute +/// attribute = (att-field ":" att-value) / att-field +/// att-field = token +/// att-value = byte-string +/// +//////////////////////////////////////////////////////////////////////////////////////////////////// +typedef struct tsdp_header_A_s +{ + TSDP_DECLARE_HEADER; + + char* field; + char* value; +} +tsdp_header_A_t; + +typedef tsk_list_t tsdp_headers_A_L_t; + +TINYSDP_API tsdp_header_A_t* tsdp_header_A_create(const char* field, const char* value); +TINYSDP_API tsdp_header_A_t* tsdp_header_A_create_null(); + +TINYSDP_API tsdp_header_A_t *tsdp_header_A_parse(const char *data, tsk_size_t size); +TINYSDP_API int tsdp_header_A_removeAll_by_field(tsdp_headers_A_L_t *attributes, const char* field); +TINYSDP_API int tsdp_header_A_removeAll_by_fields(tsdp_headers_A_L_t *attributes, const char** fields, tsk_size_t fields_count); + +TINYSDP_GEXTERN const tsk_object_def_t *tsdp_header_A_def_t; + +TSDP_END_DECLS + +#endif /* _TSDP_HEADER_A_H_ */ + diff --git a/tinySDP/include/tinysdp/headers/tsdp_header_B.h b/tinySDP/include/tinysdp/headers/tsdp_header_B.h new file mode 100644 index 0000000..360d3d7 --- /dev/null +++ b/tinySDP/include/tinysdp/headers/tsdp_header_B.h @@ -0,0 +1,72 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop <diopmamadou(at)doubango[dot]org> +* +* 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. +* +*/ + +/**@file tsdp_header_B.h + * @brief SDP "b=" header (Bandwidth). + * + * @author Mamadou Diop <diopmamadou(at)doubango[dot]org> + * + * + */ +#ifndef _TSDP_HEADER_B_H_ +#define _TSDP_HEADER_B_H_ + +#include "tinysdp_config.h" +#include "tinysdp/headers/tsdp_header.h" + +TSDP_BEGIN_DECLS + + +#define TSDP_HEADER_B_VA_ARGS(bwtype, bandwidth) tsdp_header_B_def_t, (const char*)bwtype, (uint32_t)bandwidth + +//////////////////////////////////////////////////////////////////////////////////////////////////// +/// @struct +/// +/// @brief SDP "b=" header (Bandwidth). +/// +/// @par ABNF : b=<bwtype> HCOLON <bandwidth> +/// bwtype = token +/// bandwidth = 1*DIGIT +/// +//////////////////////////////////////////////////////////////////////////////////////////////////// +typedef struct tsdp_header_B_s +{ + TSDP_DECLARE_HEADER; + + char* bwtype; + uint32_t bandwidth; +} +tsdp_header_B_t; + +typedef tsk_list_t tsdp_headers_B_L_t; + +TINYSDP_API tsdp_header_B_t* tsdp_header_B_create(const char* bwtype, uint32_t bandwidth); +TINYSDP_API tsdp_header_B_t* tsdp_header_b_create_null(); + +TINYSDP_API tsdp_header_B_t *tsdp_header_B_parse(const char *data, tsk_size_t size); + +TINYSDP_GEXTERN const tsk_object_def_t *tsdp_header_B_def_t; + +TSDP_END_DECLS + +#endif /* _TSDP_HEADER_B_H_ */ + diff --git a/tinySDP/include/tinysdp/headers/tsdp_header_C.h b/tinySDP/include/tinysdp/headers/tsdp_header_C.h new file mode 100644 index 0000000..e5c5399 --- /dev/null +++ b/tinySDP/include/tinysdp/headers/tsdp_header_C.h @@ -0,0 +1,76 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop <diopmamadou(at)doubango[dot]org> +* +* 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. +* +*/ + +/**@file tsdp_header_C.h + * @brief SDP "c=" header (Connection Data). + * + * @author Mamadou Diop <diopmamadou(at)doubango[dot]org> + * + * + */ +#ifndef _TSDP_HEADER_C_H_ +#define _TSDP_HEADER_C_H_ + +#include "tinysdp_config.h" +#include "tinysdp/headers/tsdp_header.h" + +TSDP_BEGIN_DECLS + +#define TSDP_HEADER_C_VA_ARGS(nettype, addrtype, addr) tsdp_header_C_def_t, (const char*)(nettype), (const char*)(addrtype), (const char*)(addr) + +//////////////////////////////////////////////////////////////////////////////////////////////////// +/// @struct +/// +/// @brief SDP "c=" header (Connection Data). +/// A session description MUST contain either at least one "c=" field in +/// each media description or a single "c=" field at the session level. +/// It MAY contain a single session-level "c=" field and additional "c=" +/// field(s) per media description, in which case the per-media values +/// override the session-level settings for the respective media. +/// +/// +/// +/// @par ABNF : c= nettype SP addrtype SP connection-address +/// +//////////////////////////////////////////////////////////////////////////////////////////////////// +typedef struct tsdp_header_C_s +{ + TSDP_DECLARE_HEADER; + char* nettype; + char* addrtype; + char* addr; +} +tsdp_header_C_t; + +typedef tsk_list_t tsdp_headers_C_L_t; + +TINYSDP_API tsdp_header_C_t* tsdp_header_c_create(const char* nettype, const char* addrtype, const char* addr); +TINYSDP_API tsdp_header_C_t* tsdp_header_c_create_null(); + +TINYSDP_API tsdp_header_C_t *tsdp_header_C_parse(const char *data, tsk_size_t size); + +TINYSDP_GEXTERN const tsk_object_def_t *tsdp_header_C_def_t; + +TSDP_END_DECLS + +#endif /* _TSDP_HEADER_C_H_ */ + diff --git a/tinySDP/include/tinysdp/headers/tsdp_header_Dummy.h b/tinySDP/include/tinysdp/headers/tsdp_header_Dummy.h new file mode 100644 index 0000000..e9ec9b5 --- /dev/null +++ b/tinySDP/include/tinysdp/headers/tsdp_header_Dummy.h @@ -0,0 +1,68 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop <diopmamadou(at)doubango[dot]org> +* +* 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. +* +*/ + +/**@file tsdp_header_Dummy.h + * @brief SDP dummy header. + * + * @author Mamadou Diop <diopmamadou(at)doubango[dot]org> + * + + */ +#ifndef _TSDP_HEADER_DUMMY_H_ +#define _TSDP_HEADER_DUMMY_H_ + +#include "tinysdp_config.h" +#include "tinysdp/headers/tsdp_header.h" + +TSDP_BEGIN_DECLS + +#define TSDP_HEADER_DUMMY_VA_ARGS(name, value) tsdp_header_Dummy_def_t, (char)name, (const char*)value + +//////////////////////////////////////////////////////////////////////////////////////////////////// +/// @struct +/// +/// @brief SDP Dummy header. +/// +/// @par ABNF : alpha SP* "=" SP*<: any* +/// +//////////////////////////////////////////////////////////////////////////////////////////////////// +typedef struct tsdp_header_Dummy_s +{ + TSDP_DECLARE_HEADER; + char name; + char *value; +} +tsdp_header_Dummy_t; + +typedef tsk_list_t tsdp_headers_Dummy_L_t; + +TINYSDP_API tsdp_header_Dummy_t* tsdp_header_dummy_create(char name, const char* value); +TINYSDP_API tsdp_header_Dummy_t* tsdp_header_dummy_create_null(); + +TINYSDP_API tsdp_header_Dummy_t *tsdp_header_Dummy_parse(const char *data, tsk_size_t size); + +TINYSDP_GEXTERN const tsk_object_def_t *tsdp_header_Dummy_def_t; + +TSDP_END_DECLS + +#endif /* _TSDP_HEADER_DUMMY_H_ */ + diff --git a/tinySDP/include/tinysdp/headers/tsdp_header_E.h b/tinySDP/include/tinysdp/headers/tsdp_header_E.h new file mode 100644 index 0000000..a024b6a --- /dev/null +++ b/tinySDP/include/tinysdp/headers/tsdp_header_E.h @@ -0,0 +1,71 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop <diopmamadou(at)doubango[dot]org> +* +* 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. +* +*/ + +/**@file tsdp_header_E.h + * @brief SDP "e=" header (Email Address). + * + * @author Mamadou Diop <diopmamadou(at)doubango[dot]org> + * + * + */ +#ifndef _TSDP_HEADER_E_H_ +#define _TSDP_HEADER_E_H_ + +#include "tinysdp_config.h" +#include "tinysdp/headers/tsdp_header.h" + +TSDP_BEGIN_DECLS + +#define TSDP_HEADER_E_VA_ARGS(value) tsdp_header_E_def_t, (const char*)value + +//////////////////////////////////////////////////////////////////////////////////////////////////// +/// @struct +/// +/// @brief SDP "e=" header (Email Address). +/// +/// The "e=" line specifies contact information for the person +/// responsible for the conference. This is not necessarily the same +/// person that created the conference announcement. +/// +/// @par ABNF : e= email-address +/// +//////////////////////////////////////////////////////////////////////////////////////////////////// +typedef struct tsdp_header_E_s +{ + TSDP_DECLARE_HEADER; + char* value; +} +tsdp_header_E_t; + +typedef tsk_list_t tsdp_headers_E_L_t; + +TINYSDP_API tsdp_header_E_t* tsdp_header_E_create(const char* value); +TINYSDP_API tsdp_header_E_t* tsdp_header_E_create_null(); + +TINYSDP_API tsdp_header_E_t *tsdp_header_E_parse(const char *data, tsk_size_t size); + +TINYSDP_GEXTERN const tsk_object_def_t *tsdp_header_E_def_t; + +TSDP_END_DECLS + +#endif /* _TSDP_HEADER_E_H_ */ + diff --git a/tinySDP/include/tinysdp/headers/tsdp_header_I.h b/tinySDP/include/tinysdp/headers/tsdp_header_I.h new file mode 100644 index 0000000..5f5d4fd --- /dev/null +++ b/tinySDP/include/tinysdp/headers/tsdp_header_I.h @@ -0,0 +1,67 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop <diopmamadou(at)doubango[dot]org> +* +* 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. +* +*/ + +/**@file tsdp_header_I.h + * @brief SDP "i=" header (Session Information). + * + * @author Mamadou Diop <diopmamadou(at)doubango[dot]org> + * + * + */ +#ifndef _TSDP_HEADER_I_H_ +#define _TSDP_HEADER_I_H_ + +#include "tinysdp_config.h" +#include "tinysdp/headers/tsdp_header.h" + +TSDP_BEGIN_DECLS + +#define TSDP_HEADER_I_VA_ARGS(value) tsdp_header_I_def_t, (const char*)value + +//////////////////////////////////////////////////////////////////////////////////////////////////// +/// @struct +/// +/// @brief SDP "i=" header (Session Information). +/// +/// @par ABNF : i=text +/// +//////////////////////////////////////////////////////////////////////////////////////////////////// +typedef struct tsdp_header_I_s +{ + TSDP_DECLARE_HEADER; + char* value; +} +tsdp_header_I_t; + +typedef tsk_list_t tsdp_headers_I_L_t; + +TINYSDP_API tsdp_header_I_t* tsdp_header_I_create(const char* value); +TINYSDP_API tsdp_header_I_t* tsdp_header_I_create_null(); + +TINYSDP_API tsdp_header_I_t *tsdp_header_I_parse(const char *data, tsk_size_t size); + +TINYSDP_GEXTERN const tsk_object_def_t *tsdp_header_I_def_t; + +TSDP_END_DECLS + +#endif /* _TSDP_HEADER_I_H_ */ + diff --git a/tinySDP/include/tinysdp/headers/tsdp_header_K.h b/tinySDP/include/tinysdp/headers/tsdp_header_K.h new file mode 100644 index 0000000..5ca090f --- /dev/null +++ b/tinySDP/include/tinysdp/headers/tsdp_header_K.h @@ -0,0 +1,73 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop <diopmamadou(at)doubango[dot]org> +* +* 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. +* +*/ + +/**@file tsdp_header_K.h + * @brief SDP "k=" header (Encryption Key). + * + * @author Mamadou Diop <diopmamadou(at)doubango[dot]org> + * + * + */ +#ifndef _TSDP_HEADER_K_H_ +#define _TSDP_HEADER_K_H_ + +#include "tinysdp_config.h" +#include "tinysdp/headers/tsdp_header.h" + +TSDP_BEGIN_DECLS + +#define TSDP_HEADER_K_VA_ARGS(value) tsdp_header_K_def_t, (const char*)value + +//////////////////////////////////////////////////////////////////////////////////////////////////// +/// @struct +/// +/// @brief SDP "k=" header (Encryption Key). +/// +/// +/// @par ABNF : k= key-type +/// key-type = "prompt" / "clear:" text / "base64:" base64 / "uri:" uri +/// base64 = *base64-unit [base64-pad] +/// base64-unit = 4base64-char +/// base64-pad = 2base64-char "==" / 3base64-pad "=" +/// base64-char = ALPHA / DIGIT / "+" / "/" +/// +//////////////////////////////////////////////////////////////////////////////////////////////////// +typedef struct tsdp_header_K_s +{ + TSDP_DECLARE_HEADER; + char* value; +} +tsdp_header_K_t; + +typedef tsk_list_t tsdp_headers_K_L_t; + +TINYSDP_API tsdp_header_K_t* tsdp_header_K_create(const char* value); +TINYSDP_API tsdp_header_K_t* tsdp_header_K_create_null(); + +tsdp_header_K_t *tsdp_header_K_parse(const char *data, tsk_size_t size); + +TINYSDP_GEXTERN const tsk_object_def_t *tsdp_header_K_def_t; + +TSDP_END_DECLS + +#endif /* _TSDP_HEADER_P_H_ */ + diff --git a/tinySDP/include/tinysdp/headers/tsdp_header_M.h b/tinySDP/include/tinysdp/headers/tsdp_header_M.h new file mode 100644 index 0000000..fad13b0 --- /dev/null +++ b/tinySDP/include/tinysdp/headers/tsdp_header_M.h @@ -0,0 +1,149 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop <diopmamadou(at)doubango[dot]org> +* +* 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. +* +*/ + +/**@file tsdp_header_M.h + * @brief SDP "m=" header (Media Descriptions). + * + * @author Mamadou Diop <diopmamadou(at)doubango[dot]org> + * + * + */ +#ifndef _TSDP_HEADER_M_H_ +#define _TSDP_HEADER_M_H_ + +#include "tinysdp_config.h" +#include "tinysdp/headers/tsdp_header.h" + +#include "tinysdp/headers/tsdp_header_A.h" +#include "tinysdp/headers/tsdp_header_B.h" +#include "tinysdp/headers/tsdp_header_C.h" +#include "tinysdp/headers/tsdp_header_I.h" +#include "tinysdp/headers/tsdp_header_K.h" + +#include "tsk_string.h" + +TSDP_BEGIN_DECLS + +#define TSDP_HEADER_M_VA_ARGS(media, port, proto) tsdp_header_M_def_t, (const char*)media, (uint32_t)port, (const char*)proto + +#define TSDP_HEADER_M(self) ((tsdp_header_M_t*)(self)) + +#define TSDP_FMT_VA_ARGS(fmt) tsdp_fmt_def_t, (const char*)fmt + +typedef tsk_string_t tsdp_fmt_t; +typedef tsk_strings_L_t tsk_fmts_L_t; +#define tsdp_fmt_def_t tsk_string_def_t +#define TSDP_FMT_STR(self) TSK_STRING_STR(self) + +TINYSDP_API tsdp_fmt_t* tsdp_fmt_create(const char* fmt); + +//#define TSDP_HEADER_M_SET_FMT(fmt) (int)0x01, (const char*)fmt +//#define TSDP_HEADER_M_SET_A(field, value) (int)0x02, (const char*)field, (const char*)value +//#define TSDP_HEADER_M_SET_NULL() (int)0x00 + +//////////////////////////////////////////////////////////////////////////////////////////////////// +/// @struct +/// +/// @brief SDP "m=" header (Media Descriptions). +/// +/// @par ABNF : m=*(media-field +/// information-field +/// *connection-field +/// bandwidth-fields +/// key-field +/// attribute-fields) +/// +/// media-field = %x6d "=" media SP port ["/" integer] SP proto 1*(SP fmt) CRLF +/// media = token +/// port = 1*DIGIT +/// proto = token *("/" token) +/// fmt = token +/// +//////////////////////////////////////////////////////////////////////////////////////////////////// +typedef struct tsdp_header_M_s +{ + TSDP_DECLARE_HEADER; + + char* media; + uint32_t port; + uint32_t nports; /**< <number of ports> */ + char* proto; + tsk_fmts_L_t* FMTs; + + // Fields below will be set by the message parser. + tsdp_header_I_t* I; + tsdp_header_C_t* C; + tsdp_headers_B_L_t* Bandwidths; // (zero or more bandwidth information lines) + tsdp_header_K_t* K; // (encryption key) + tsdp_headers_A_L_t* Attributes; // (zero or more media attribute lines) +} +tsdp_header_M_t; + +typedef enum tsdp_header_M_diff_e { + tsdp_header_M_diff_none = 0x0000000, + tsdp_header_M_diff_hold_resume = (0x0000001 << 0), + tsdp_header_M_diff_index = (0x0000001 << 1), + tsdp_header_M_diff_codecs = (0x0000001 << 2), + tsdp_header_M_diff_network_info = (0x0000001 << 3), + tsdp_header_M_diff_ice_enabled = (0x0000001 << 4), + tsdp_header_M_diff_ice_restart = (0x0000001 << 5), + tsdp_header_M_diff_dtls_fingerprint = (0x0000001 << 6), + tsdp_header_M_diff_sdes_crypto = (0x0000001 << 7), + tsdp_header_M_diff_media_type = (0x0000001 << 8), + tsdp_header_M_diff_all = 0xFFFFFFFF +} +tsdp_header_M_diff_t; + +typedef tsk_list_t tsdp_headers_M_L_t; + +TINYSDP_API tsdp_header_M_t* tsdp_header_M_create(const char* media, uint32_t port, const char* proto); +TINYSDP_API tsdp_header_M_t* tsdp_header_M_create_null(); + +TINYSDP_API tsdp_header_M_t *tsdp_header_M_parse(const char *data, tsk_size_t size); +TINYSDP_API int tsdp_header_M_remove(tsdp_header_M_t* self, tsdp_header_type_t type); +TINYSDP_API int tsdp_header_M_add(tsdp_header_M_t* self, const tsdp_header_t* header); +TINYSDP_API int tsdp_header_M_add_headers(tsdp_header_M_t* self, ...); +TINYSDP_API int tsdp_header_M_add_headers_2(tsdp_header_M_t* self, const tsdp_headers_L_t* headers); +TINYSDP_API int tsdp_header_M_add_fmt(tsdp_header_M_t* self, const char* fmt); +TINYSDP_API int tsdp_header_M_remove_fmt(tsdp_header_M_t* self, const char* fmt); +TINYSDP_API tsk_bool_t tsdp_header_M_have_fmt(const tsdp_header_M_t* self, const char* fmt); +TINYSDP_API const tsdp_header_A_t* tsdp_header_M_findA_at(const tsdp_header_M_t* self, const char* field, tsk_size_t index); +TINYSDP_API const tsdp_header_A_t* tsdp_header_M_findA(const tsdp_header_M_t* self, const char* field); +TINYSDP_API char* tsdp_header_M_getAValue(const tsdp_header_M_t* self, const char* field, const char* fmt); +#define tsdp_header_M_get_rtpmap(self, fmt) tsdp_header_M_getAValue((self), "rtpmap", (fmt)) +#define tsdp_header_M_get_fmtp(self, fmt) tsdp_header_M_getAValue((self), "fmtp", (fmt)) +#define tsdp_header_M_get_imageattr(self, fmt) tsdp_header_M_getAValue((self), "imageattr", (fmt)) +TINYSDP_API int tsdp_header_M_hold(tsdp_header_M_t* self, tsk_bool_t local); +TINYSDP_API tsk_bool_t tsdp_header_M_is_held(const tsdp_header_M_t* self, tsk_bool_t local); +TINYSDP_API int tsdp_header_M_set_holdresume_att(tsdp_header_M_t* self, tsk_bool_t lo_held, tsk_bool_t ro_held); +TINYSDP_API const char* tsdp_header_M_get_holdresume_att(const tsdp_header_M_t* self); +TINYSDP_API int tsdp_header_M_resume(tsdp_header_M_t* self, tsk_bool_t local); +TINYSDP_API tsk_bool_t tsdp_header_M_is_ice_enabled(const tsdp_header_M_t* self); +TINYSDP_API tsk_bool_t tsdp_header_M_is_ice_restart(const tsdp_header_M_t* self); +TINYSDP_API int tsdp_header_M_diff(const tsdp_header_M_t* M_old, const tsdp_header_M_t* M_new, tsdp_header_M_diff_t* diff); + +TINYSDP_GEXTERN const tsk_object_def_t *tsdp_header_M_def_t; + +TSDP_END_DECLS + +#endif /* _TSDP_HEADER_M_H_ */ + diff --git a/tinySDP/include/tinysdp/headers/tsdp_header_O.h b/tinySDP/include/tinysdp/headers/tsdp_header_O.h new file mode 100644 index 0000000..20a1994 --- /dev/null +++ b/tinySDP/include/tinysdp/headers/tsdp_header_O.h @@ -0,0 +1,119 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop <diopmamadou(at)doubango[dot]org> +* +* 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. +* +*/ + +/**@file tsdp_header_O.h + * @brief SDP "o=" header (Origin). + * + * @author Mamadou Diop <diopmamadou(at)doubango[dot]org> + * + * @date Created: Oat Nov 8 16:54:58 2009 mdiop + */ +#ifndef _TSDP_HEADER_O_H_ +#define _TSDP_HEADER_O_H_ + +#include "tinysdp_config.h" +#include "tinysdp/headers/tsdp_header.h" + +TSDP_BEGIN_DECLS + + +#define TSDP_HEADER_O_VA_ARGS(username, sess_id, sess_version, nettype, addrtype, addr) tsdp_header_O_def_t, (const char*)username, (uint32_t)sess_id, (uint32_t)sess_version, (const char*)nettype, (const char*)addrtype, (const char*)addr +#define TSDP_HEADER_O_VA_ARGS_DEFAULT(username, nettype, addrtype, addr) TSDP_HEADER_O_VA_ARGS(username, TSDP_HEADER_O_SESS_ID_DEFAULT, TSDP_HEADER_O_SESS_VERSION_DEFAULT, nettype, addrtype, addr) + +#define TSDP_HEADER_O_SESS_ID_DEFAULT 123456 +#define TSDP_HEADER_O_SESS_VERSION_DEFAULT 678901 + +//////////////////////////////////////////////////////////////////////////////////////////////////// +/// @struct +/// +/// @brief SDP "o=" header (Origin). +/// The "o=" field gives the originator of the session (her username and +/// the address of the user's host) plus a session identifier and version number. +/// +/// @par ABNF : u=username SP +/// sess-id SP sess-version SP nettype SP addrtype SP unicast-address +/// +/// username = non-ws-string +/// sess-id = 1*DIGIT +/// sess-version = 1*DIGIT +/// nettype = token +/// addrtype = token +/// unicast-address = FQDN +/// +//////////////////////////////////////////////////////////////////////////////////////////////////// +typedef struct tsdp_header_O_s +{ + TSDP_DECLARE_HEADER; + + /** <username> is the user's login on the originating host, or it is "-" + if the originating host does not support the concept of user IDs. + The <username> MUST NOT contain spaces.*/ + char* username; + /** <sess-id>, <nettype>, <addrtype>, and <unicast-address> forms a + globally unique identifier for the session. The method of + <sess-id> allocation is up to the creating tool, but it has been + suggested that a Network Time Protocol (NTP) format timestamp be + used to ensure uniqueness*/ + uint32_t sess_id; + /** <sess-version> is a version number for this session description. Its + usage is up to the creating tool, so long as <sess-version> is + increased when a modification is made to the session data. Again, + it is RECOMMENDED that an NTP format timestamp is used.*/ + uint32_t sess_version; + /** <nettype> is a text string giving the type of network. Initially + "IN" is defined to have the meaning "Internet", but other values + MAY be registered in the future (see Section 8 of RFC 4566)*/ + char* nettype; + /**<addrtype> is a text string giving the type of the address that + follows. Initially "IP4" and "IP6" are defined, but other values + MAY be registered in the future (see Section 8 of RFC 4566)*/ + char* addrtype; + /** <unicast-address> is the address of the machine from which the + session was created. For an address type of IP4, this is either + the fully qualified domain name of the machine or the dotted- + decimal representation of the IP version 4 address of the machine. + For an address type of IP6, this is either the fully qualified + domain name of the machine or the compressed textual + representation of the IP version 6 address of the machine. For + both IP4 and IP6, the fully qualified domain name is the form that + SHOULD be given unless this is unavailable, in which case the + globally unique address MAY be substituted. A local IP address + MUST NOT be used in any context where the SDP description might + leave the scope in which the address is meaningful (for example, a + local address MUST NOT be included in an application-level + referral that might leave the scope)*/ + char* addr; +} +tsdp_header_O_t; + +TINYSDP_API tsdp_header_O_t* tsdp_header_O_create(const char* username, uint32_t sess_id, uint32_t sess_version, const char* nettype, const char* addrtype, const char* addr); +TINYSDP_API tsdp_header_O_t* tsdp_header_O_create_null(); +TINYSDP_API tsdp_header_O_t* tsdp_header_O_create_default(const char* username, const char* nettype, const char* addrtype, const char* addr); + +TINYSDP_API tsdp_header_O_t *tsdp_header_O_parse(const char *data, tsk_size_t size); + +TINYSDP_GEXTERN const tsk_object_def_t *tsdp_header_O_def_t; + +TSDP_END_DECLS + +#endif /* _TSDP_HEADER_O_H_ */ + diff --git a/tinySDP/include/tinysdp/headers/tsdp_header_P.h b/tinySDP/include/tinysdp/headers/tsdp_header_P.h new file mode 100644 index 0000000..ca73886 --- /dev/null +++ b/tinySDP/include/tinysdp/headers/tsdp_header_P.h @@ -0,0 +1,71 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop <diopmamadou(at)doubango[dot]org> +* +* 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. +* +*/ + +/**@file tsdp_header_P.h + * @brief SDP "p=" header (Phone Number). + * + * @author Mamadou Diop <diopmamadou(at)doubango[dot]org> + * + * + */ +#ifndef _TSDP_HEADER_P_H_ +#define _TSDP_HEADER_P_H_ + +#include "tinysdp_config.h" +#include "tinysdp/headers/tsdp_header.h" + +TSDP_BEGIN_DECLS + +#define TSDP_HEADER_P_VA_ARGS(value) tsdp_header_P_def_t, (const char*)value + +//////////////////////////////////////////////////////////////////////////////////////////////////// +/// @struct +/// +/// @brief SDP "p=" header (Phone Number). +/// The "p=" line specifies contact information for the person +/// responsible for the conference. This is not necessarily the same +/// person that created the conference announcement. +/// +/// +/// @par ABNF : p= phone-number +/// +//////////////////////////////////////////////////////////////////////////////////////////////////// +typedef struct tsdp_header_P_s +{ + TSDP_DECLARE_HEADER; + char* value; +} +tsdp_header_P_t; + +typedef tsk_list_t tsdp_headers_P_L_t; + +TINYSDP_API tsdp_header_P_t* tsdp_header_P_create(const char* value); +TINYSDP_API tsdp_header_P_t* tsdp_header_P_create_null(); + +TINYSDP_API tsdp_header_P_t *tsdp_header_P_parse(const char *data, tsk_size_t size); + +TINYSDP_GEXTERN const tsk_object_def_t *tsdp_header_P_def_t; + +TSDP_END_DECLS + +#endif /* _TSDP_HEADER_P_H_ */ + diff --git a/tinySDP/include/tinysdp/headers/tsdp_header_R.h b/tinySDP/include/tinysdp/headers/tsdp_header_R.h new file mode 100644 index 0000000..a5277cc --- /dev/null +++ b/tinySDP/include/tinysdp/headers/tsdp_header_R.h @@ -0,0 +1,77 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop <diopmamadou(at)doubango[dot]org> +* +* 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. +* +*/ + +/**@file tsdp_header_R.h + * @brief SDP "r=" header (Repeat Times). + * + * @author Mamadou Diop <diopmamadou(at)doubango[dot]org> + * + * + */ +#ifndef _TSDP_HEADER_R_H_ +#define _TSDP_HEADER_R_H_ + +#include "tinysdp_config.h" +#include "tinysdp/headers/tsdp_header.h" + +#include "tsk_string.h" + +TSDP_BEGIN_DECLS + +#define TSDP_HEADER_R_VA_ARGS() tsdp_header_R_def_t + +//////////////////////////////////////////////////////////////////////////////////////////////////// +/// @struct +/// +/// @brief SDP "r=" header (Repeat Times). +/// +/// The "e=" line "r=" fields specify repeat times for a session. +/// +/// @par ABNF : r= repeat-interval SP typed-time 1*(SP typed-time) +/// repeat-interval = POS-DIGIT *DIGIT [fixed-len-time-unit] +/// typed-time = 1*DIGIT [fixed-len-time-unit] +/// 1*DIGIT [fixed-len-time-unit] +/// fixed-len-time-unit = "d" / "h" / "m" / "s" +/// +//////////////////////////////////////////////////////////////////////////////////////////////////// +typedef struct tsdp_header_R_s +{ + TSDP_DECLARE_HEADER; + char* repeat_interval; + char* typed_time; + tsk_strings_L_t* typed_times; +} +tsdp_header_R_t; + +typedef tsk_list_t tsdp_headers_R_L_t; + +TINYSDP_API tsdp_header_R_t* tsdp_header_R_create(); +TINYSDP_API tsdp_header_R_t* tsdp_header_R_create_null(); + +TINYSDP_API tsdp_header_R_t *tsdp_header_R_parse(const char *data, tsk_size_t size); + +TINYSDP_GEXTERN const tsk_object_def_t *tsdp_header_R_def_t; + +TSDP_END_DECLS + +#endif /* _TSDP_HEADER_R_H_ */ + diff --git a/tinySDP/include/tinysdp/headers/tsdp_header_S.h b/tinySDP/include/tinysdp/headers/tsdp_header_S.h new file mode 100644 index 0000000..4f2316a --- /dev/null +++ b/tinySDP/include/tinysdp/headers/tsdp_header_S.h @@ -0,0 +1,65 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop <diopmamadou(at)doubango[dot]org> +* +* 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. +* +*/ + +/**@file tsdp_header_S.h + * @brief SDP "s=" header (Session Name). + * + * @author Mamadou Diop <diopmamadou(at)doubango[dot]org> + * + + */ +#ifndef _TSDP_HEADER_S_H_ +#define _TSDP_HEADER_S_H_ + +#include "tinysdp_config.h" +#include "tinysdp/headers/tsdp_header.h" + +TSDP_BEGIN_DECLS + +#define TSDP_HEADER_S_VA_ARGS(value) tsdp_header_S_def_t, (const char*)value + +//////////////////////////////////////////////////////////////////////////////////////////////////// +/// @struct +/// +/// @brief SDP "s=" header (Session Name). +/// +/// @par ABNF : s=text +/// +//////////////////////////////////////////////////////////////////////////////////////////////////// +typedef struct tsdp_header_S_s +{ + TSDP_DECLARE_HEADER; + char* value; +} +tsdp_header_S_t; + +TINYSDP_API tsdp_header_S_t* tsdp_header_S_create(const char* value); +TINYSDP_API tsdp_header_S_t* tsdp_header_S_create_null(); + +TINYSDP_API tsdp_header_S_t *tsdp_header_S_parse(const char *data, tsk_size_t size); + +TINYSDP_GEXTERN const tsk_object_def_t *tsdp_header_S_def_t; + +TSDP_END_DECLS + +#endif /* _TSDP_HEADER_S_H_ */ + diff --git a/tinySDP/include/tinysdp/headers/tsdp_header_T.h b/tinySDP/include/tinysdp/headers/tsdp_header_T.h new file mode 100644 index 0000000..596094d --- /dev/null +++ b/tinySDP/include/tinysdp/headers/tsdp_header_T.h @@ -0,0 +1,81 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop <diopmamadou(at)doubango[dot]org> +* +* 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. +* +*/ + +/**@file tsdp_header_T.h + * @brief SDP "t=" header (Timing). + * + * @author Mamadou Diop <diopmamadou(at)doubango[dot]org> + * + * + */ +#ifndef _TSDP_HEADER_T_H_ +#define _TSDP_HEADER_T_H_ + +#include "tinysdp_config.h" +#include "tinysdp/headers/tsdp_header.h" + +#include "tinysdp/headers/tsdp_header_R.h" + +TSDP_BEGIN_DECLS + +#define TSDP_HEADER_T_VA_ARGS(start, stop) tsdp_header_T_def_t, (uint64_t)start, (uint64_t)stop + +//////////////////////////////////////////////////////////////////////////////////////////////////// +/// @struct +/// +/// @brief SDP "t=" header (Timing). +/// The "t=" lines specify the start and stop times for a session. +/// Multiple "t=" lines MAY be used if a session is active at multiple +/// irregularly spaced times; each additional "t=" line specifies an +/// additional period of time for which the session will be active. If +/// the session is active at regular times, an "r=" line (see below) +/// should be used in addition to, and following, a "t=" line -- in which +/// case the "t=" line specifies the start and stop times of the repeat +/// sequence. +/// +/// +/// @par ABNF : t= start-time SP stop-time *( CRLF repeat-fields ) +/// +//////////////////////////////////////////////////////////////////////////////////////////////////// +typedef struct tsdp_header_T_s +{ + TSDP_DECLARE_HEADER; + uint64_t start; + uint64_t stop; + + tsdp_headers_R_L_t* repeat_fields; +} +tsdp_header_T_t; + +typedef tsk_list_t tsdp_headers_T_L_t; + +TINYSDP_API tsdp_header_T_t* tsdp_header_T_create(uint64_t start, uint64_t stop); +TINYSDP_API tsdp_header_T_t* tsdp_header_T_create_null(); + +TINYSDP_API tsdp_header_T_t *tsdp_header_T_parse(const char *data, tsk_size_t size); + +TINYSDP_GEXTERN const tsk_object_def_t *tsdp_header_T_def_t; + +TSDP_END_DECLS + +#endif /* _TSDP_HEADER_P_H_ */ + diff --git a/tinySDP/include/tinysdp/headers/tsdp_header_U.h b/tinySDP/include/tinysdp/headers/tsdp_header_U.h new file mode 100644 index 0000000..d42a503 --- /dev/null +++ b/tinySDP/include/tinysdp/headers/tsdp_header_U.h @@ -0,0 +1,67 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop <diopmamadou(at)doubango[dot]org> +* +* 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. +* +*/ + +/**@file tsdp_header_U.h + * @brief SDP "u=" header (URI). + * + * @author Mamadou Diop <diopmamadou(at)doubango[dot]org> + * + * @date Created: Uat Nov 8 16:54:58 2009 mdiop + */ +#ifndef _TSDP_HEADER_U_H_ +#define _TSDP_HEADER_U_H_ + +#include "tinysdp_config.h" +#include "tinysdp/headers/tsdp_header.h" + +TSDP_BEGIN_DECLS + +#define TSDP_HEADER_U_VA_ARGS(value) tsdp_header_U_def_t, (const char*)value + +//////////////////////////////////////////////////////////////////////////////////////////////////// +/// @struct +/// +/// @brief SDP "u=" header (URI). +/// +/// @par ABNF : u=uri +/// +//////////////////////////////////////////////////////////////////////////////////////////////////// +typedef struct tsdp_header_U_s +{ + TSDP_DECLARE_HEADER; + char* value; +} +tsdp_header_U_t; + +typedef tsk_list_t tsdp_headers_U_L_t; + +TINYSDP_API tsdp_header_U_t* tsdp_header_U_create(const char* value); +TINYSDP_API tsdp_header_U_t* tsdp_header_U_create_null(); + +TINYSDP_API tsdp_header_U_t *tsdp_header_U_parse(const char *data, tsk_size_t size); + +TINYSDP_GEXTERN const tsk_object_def_t *tsdp_header_U_def_t; + +TSDP_END_DECLS + +#endif /* _TSDP_HEADER_U_H_ */ + diff --git a/tinySDP/include/tinysdp/headers/tsdp_header_V.h b/tinySDP/include/tinysdp/headers/tsdp_header_V.h new file mode 100644 index 0000000..bf3578a --- /dev/null +++ b/tinySDP/include/tinysdp/headers/tsdp_header_V.h @@ -0,0 +1,71 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop <diopmamadou(at)doubango[dot]org> +* +* 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. +* +*/ + +/**@file tsdp_header_V.h + * @brief SDP "v=" header (Protocol Version). + * + * @author Mamadou Diop <diopmamadou(at)doubango[dot]org> + * + + */ +#ifndef _TSDP_HEADER_V_H_ +#define _TSDP_HEADER_V_H_ + +#include "tinysdp_config.h" +#include "tinysdp/headers/tsdp_header.h" + +TSDP_BEGIN_DECLS + +#define TSDP_HEADER_V_VA_ARGS(version) tsdp_header_V_def_t, (int32_t)version + +#define TSDP_HEADER_V_DEFAULT 0 + +//////////////////////////////////////////////////////////////////////////////////////////////////// +/// @struct +/// +/// @brief SDP "v=" header (Protocol Version). +/// The "v=" field gives the version of the Session Description Protocol. +/// This memo (RFC 4566) defines version 0. There is no minor version number. +/// +/// @par ABNF : v=1*DIGIT +/// +//////////////////////////////////////////////////////////////////////////////////////////////////// +typedef struct tsdp_header_V_s +{ + TSDP_DECLARE_HEADER; + int32_t version; +} +tsdp_header_V_t; + +typedef tsk_list_t tsdp_headers_V_L_t; + +TINYSDP_API tsdp_header_V_t* tsdp_header_V_create(int32_t version); +TINYSDP_API tsdp_header_V_t* tsdp_header_V_create_null(); + +TINYSDP_API tsdp_header_V_t *tsdp_header_V_parse(const char *data, tsk_size_t size); + +TINYSDP_GEXTERN const tsk_object_def_t *tsdp_header_V_def_t; + +TSDP_END_DECLS + +#endif /* _TSDP_HEADER_V_H_ */ + diff --git a/tinySDP/include/tinysdp/headers/tsdp_header_Z.h b/tinySDP/include/tinysdp/headers/tsdp_header_Z.h new file mode 100644 index 0000000..e962cc8 --- /dev/null +++ b/tinySDP/include/tinysdp/headers/tsdp_header_Z.h @@ -0,0 +1,87 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop <diopmamadou(at)doubango[dot]org> +* +* 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. +* +*/ + +/**@file tsdp_header_Z.h + * @brief SDP "z=" header (Time Zones). + * + * @author Mamadou Diop <diopmamadou(at)doubango[dot]org> + * + * + */ +#ifndef _TSDP_HEADER_Z_H_ +#define _TSDP_HEADER_Z_H_ + +#include "tinysdp_config.h" +#include "tinysdp/headers/tsdp_header.h" + +TSDP_BEGIN_DECLS + +#define TSDP_HEADER_Z_VA_ARGS(time, shifted_back, typed_time) tsdp_header_Z_def_t, (uint64_t)time, (tsk_bool_t)shifted_back, (const char*)typed_time + +typedef struct tsdp_zone_s +{ + TSK_DECLARE_OBJECT; + + uint64_t time; + tsk_bool_t shifted_back; + char* typed_time; +} +tsdp_zone_t; +typedef tsk_list_t tsdp_zones_L_t; + +TINYSDP_API tsdp_zone_t* tsdp_zone_create(uint64_t time, tsk_bool_t shifted_back, const char* typed_time) ; +TINYSDP_API tsdp_zone_t* tsdp_zone_create_null(); + +//////////////////////////////////////////////////////////////////////////////////////////////////// +/// @struct +/// +/// @brief SDP "z=" header (Time Zones). +/// +/// @par ABNF : z=time SP ["-"] typed-time +/// *(SP time SP ["-"] typed-time) +/// time = POS-DIGIT 9*DIGIT +/// typed-time = 1*DIGIT [fixed-len-time-unit] +/// fixed-len-time-unit = "d" / "h" / "m" / "s" +/// +//////////////////////////////////////////////////////////////////////////////////////////////////// +typedef struct tsdp_header_Z_s +{ + TSDP_DECLARE_HEADER; + + tsdp_zones_L_t* zones; +} +tsdp_header_Z_t; + +typedef tsk_list_t tsdp_headers_Z_L_t; + +TINYSDP_API tsdp_header_Z_t* tsdp_header_Z_create(uint64_t time, tsk_bool_t shifted_back, const char* typed_time); +TINYSDP_API tsdp_header_Z_t* tsdp_header_Z_create_null(); + +TINYSDP_API tsdp_header_Z_t *tsdp_header_Z_parse(const char *data, tsk_size_t size); + +TINYSDP_GEXTERN const tsk_object_def_t *tsdp_header_Z_def_t; +TINYSDP_GEXTERN const tsk_object_def_t *tsdp_zone_def_t; + +TSDP_END_DECLS + +#endif /* _TSDP_HEADER_Z_H_ */ + diff --git a/tinySDP/include/tinysdp/parsers/tsdp_parser_header.h b/tinySDP/include/tinysdp/parsers/tsdp_parser_header.h new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/tinySDP/include/tinysdp/parsers/tsdp_parser_header.h diff --git a/tinySDP/include/tinysdp/parsers/tsdp_parser_message.h b/tinySDP/include/tinysdp/parsers/tsdp_parser_message.h new file mode 100644 index 0000000..811cb86 --- /dev/null +++ b/tinySDP/include/tinysdp/parsers/tsdp_parser_message.h @@ -0,0 +1,44 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop <diopmamadou(at)doubango[dot]org> +* +* 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. +* +*/ + +/**@file tsdp_parser_message.h + * @brief SDP message parser. + * + * @author Mamadou Diop <diopmamadou(at)doubango[dot]org> + * + + */ +#ifndef TINYSDP_PARSER_MESSAGE_H +#define TINYSDP_PARSER_MESSAGE_H + +#include "tinysdp_config.h" +#include "tinysdp/tsdp_message.h" +#include "tsk_ragel_state.h" + +TSDP_BEGIN_DECLS + +TINYSDP_API tsdp_message_t* tsdp_message_parse(const void *input, tsk_size_t size); + +TSDP_END_DECLS + +#endif /* TINYSDP_PARSER_MESSAGE_H */ + diff --git a/tinySDP/include/tinysdp/tsdp_message.h b/tinySDP/include/tinysdp/tsdp_message.h new file mode 100644 index 0000000..4d7c226 --- /dev/null +++ b/tinySDP/include/tinysdp/tsdp_message.h @@ -0,0 +1,107 @@ +/* +* Copyright (C) 2010-2015 Mamadou DIOP. +* +* 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. +* +*/ + +/**@file tsdp_message.h + * @brief SDP message. + * + */ +#ifndef TINYSDP_MESSAGE_H +#define TINYSDP_MESSAGE_H + +#include "tinysdp_config.h" + +#include "tinysdp/headers/tsdp_header.h" + +#include "tinysdp/headers/tsdp_header_M.h" + +TSDP_BEGIN_DECLS + +typedef struct tsdp_message_s +{ + TSK_DECLARE_OBJECT; + + //! List of @ref tsdp_header_t elements. + tsdp_headers_L_t* headers; +} +tsdp_message_t; + +typedef tsdp_message_t tsdp_offer_t; +typedef tsdp_message_t tsdp_answer_t; +typedef tsdp_message_t tsdp_caps_t; + +TINYSDP_API int tsdp_message_add_header(tsdp_message_t *self, const tsdp_header_t *hdr); +TINYSDP_API int tsdp_message_add_headers(tsdp_message_t *self, ...); + +#if defined(__SYMBIAN32__) && 0 +static void TSDP_MESSAGE_ADD_HEADER(tsdp_message_t *self, ...) + { + va_list ap; + tsdp_header_t *header; + const tsk_object_def_t *objdef; + + va_start(ap, self); + objdef = va_arg(ap, const tsk_object_def_t*); + header = (tsdp_header_t *)tsk_object_new_2(objdef, &ap); + va_end(ap); + + tsdp_message_add_header(self, header); + tsk_object_unref(header); + } +#else +#define TSDP_MESSAGE_ADD_HEADER(self, objdef, ...) \ + { \ + tsdp_header_t *header = (tsdp_header_t *)tsk_object_new(objdef, ##__VA_ARGS__); \ + tsdp_message_add_header(self, header); \ + tsk_object_unref(header); \ + } +#endif + +TINYSDP_API const tsdp_header_t *tsdp_message_get_headerAt(const tsdp_message_t *self, tsdp_header_type_t type, tsk_size_t index); +TINYSDP_API const tsdp_header_t *tsdp_message_get_header(const tsdp_message_t *self, tsdp_header_type_t type); +TINYSDP_API const tsdp_header_A_t* tsdp_message_get_headerA_at(const tsdp_message_t* self, const char* field, tsk_size_t index); +TINYSDP_API const tsdp_header_A_t* tsdp_message_get_headerA(const tsdp_message_t* self, const char* field); +TINYSDP_API const tsdp_header_t *tsdp_message_get_headerByName(const tsdp_message_t *self, char name); +TINYSDP_API int tsdp_message_get_sess_version(const tsdp_message_t *self, uint32_t *version); + +TINYSDP_API int tsdp_message_serialize(const tsdp_message_t *self, tsk_buffer_t *output); +TINYSDP_API char* tsdp_message_tostring(const tsdp_message_t *self); + +TINYSDP_API tsdp_message_t* tsdp_message_create_empty(const char* addr, tsk_bool_t ipv6, uint32_t version); +TINYSDP_API tsdp_message_t* tsdp_message_clone(const tsdp_message_t *self); +TINYSDP_API int tsdp_message_add_media(tsdp_message_t *self, const char* media, uint32_t port, const char* proto, ...); +TINYSDP_API int tsdp_message_add_media_2(tsdp_message_t *self, const char* media, uint32_t port, const char* proto, va_list *ap); +TINYSDP_API int tsdp_message_remove_media(tsdp_message_t *self, const char* media); +TINYSDP_API const tsdp_header_M_t* tsdp_message_find_media(const tsdp_message_t *self, const char* media); + + +// 3GPP TS 24.610 Communication HOLD +TINYSDP_API int tsdp_message_hold(tsdp_message_t* self, const char* media); +TINYSDP_API int tsdp_message_resume(tsdp_message_t* self, const char* media); + +TINYSDP_API tsk_bool_t tsdp_message_is_ice_enabled(const tsdp_message_t *self, tsk_size_t media_index); +TINYSDP_API tsk_bool_t tsdp_message_is_ice_restart(const tsdp_message_t *self, tsk_size_t media_index); + +TINYSDP_API tsdp_message_t* tsdp_message_create(); + +TINYSDP_GEXTERN const tsk_object_def_t *tsdp_message_def_t; + +TSDP_END_DECLS + +#endif /* TINYSDP_MESSAGE_H */ |