summaryrefslogtreecommitdiffstats
path: root/branches/1.0/tinySDP/include/tinysdp/headers/tsdp_header.h
blob: 128155f2608a446faf76d1a99e248248150146be (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
/*
* Copyright (C) 2009-2010 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou(at)doubango.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.org>
 *
 * @date Created: Sat Nov 8 16:54:58 2009 mdiop
 */
#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		9
#define TSDP_HTYPE_K_RANK		10
#define TSDP_HTYPE_A_RANK		11
#define TSDP_HTYPE_T_RANK		12
#define TSDP_HTYPE_R_RANK		13
#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 */
OpenPOWER on IntegriCloud