Statistics
| Branch: | Revision:

janus-gateway / sdp-utils.h @ 0351dafc

History | View | Annotate | Download (3.37 KB)

1
/*! \file    sdp-utils.h
2
 * \author   Lorenzo Miniero <lorenzo@meetecho.com>
3
 * \copyright GNU General Public License v3
4
 * \brief    SDP utilities (headers)
5
 * \details  Implementation of an internal SDP representation. Allows
6
 * to parse SDP strings to an internal janus_sdp object, the manipulation
7
 * of such object by playing with its properties, and a serialization
8
 * to an SDP string that can be passed around. Since they don't have any
9
 * core dependencies, these utilities can be used by plugins as well.
10
 * 
11
 * \ingroup core
12
 * \ref core
13
 */
14
 
15
#ifndef _JANUS_SDP_UTILS_H
16
#define _JANUS_SDP_UTILS_H
17

    
18

    
19
#include <inttypes.h>
20
#include <glib.h>
21

    
22
/*! \brief Janus SDP internal object representation */
23
typedef struct janus_sdp {
24
        /*! \brief v= */
25
        int version;
26
        /*! \brief o= name */
27
        char *o_name;
28
        /*! \brief o= session ID */
29
        guint64 o_sessid;
30
        /*! \brief o= version */
31
        guint64 o_version;
32
        /*! \brief o= protocol */
33
        gboolean o_ipv4;
34
        /*! \brief o= address */
35
        char *o_addr;
36
        /*! \brief s= */
37
        char *s_name;
38
        /*! \brief t= start */
39
        guint64 t_start;
40
        /*! \brief t= stop */
41
        guint64 t_stop;
42
        /*! \brief List of global a= attributes */
43
        GList *attributes;
44
        /*! \brief List of m= m-lines */
45
        GList *m_lines;
46
} janus_sdp;
47

    
48
/*! \brief Helper enumeration to quickly identify m-line media types */
49
typedef enum janus_sdp_mtype {
50
        /*! \brief m=audio */
51
        JANUS_SDP_AUDIO,
52
        /*! \brief m=video */
53
        JANUS_SDP_VIDEO,
54
        /*! \brief m=application */
55
        JANUS_SDP_APPLICATION,
56
        /*! \brief m=whatever (we don't care, unsupported) */
57
        JANUS_SDP_OTHER
58
} janus_sdp_mtype;
59

    
60
/*! \brief SDP m-line representation */
61
typedef struct janus_sdp_mline {
62
        /*! \brief Media type as a janus_sdp_mtype enumerator */
63
        janus_sdp_mtype type;
64
        /*! \brief Media type (string) */
65
        char *type_str;
66
        /*! \brief Media port */
67
        guint16 port;
68
        /*! \brief Media protocol */
69
        char *proto;
70
        /*! \brief List of payload types */
71
        GList *ptypes;
72
        /*! \brief Media c= protocol */
73
        gboolean c_ipv4;
74
        /*! \brief Media c= address */
75
        char *c_addr;
76
        /*! \brief Media b= type */
77
        char *b_name;
78
        /*! \brief Media b= value */
79
        int b_value;
80
        /*! \brief Media direction */
81
        char *direction;
82
        /*! \brief List of m-line attributes */
83
        GList *attributes;
84
} janus_sdp_mline;
85

    
86
/*! \brief SDP a= attribute representation */
87
typedef struct janus_sdp_attribute {
88
        /*! \brief Attribute name */
89
        char *name;
90
        /*! \brief Attribute value */
91
        char *value;
92
} janus_sdp_attribute;
93
/*! \brief Helper method to quickly create a janus_sdp_attribute instance
94
 * @param[in] name Name of the attribute
95
 * @param[in] value Value of the attribute, as a printf compliant string (variable arguments)
96
 * @returns A pointer to a valid janus_sdp_attribute instance, if successfull, NULL otherwise */
97
janus_sdp_attribute *janus_sdp_attribute_create(const char *name, const char *value, ...) G_GNUC_PRINTF(2, 3);
98

    
99
/*! \brief Method to parse an SDP string to a janus_sdp object
100
 * @param[in] sdp The SDP string to parse
101
 * @returns A pointer to a janus_sdp object, if successful, NULL otherwise */
102
janus_sdp *janus_sdp_import(const char *sdp);
103

    
104
/*! \brief Method to serialize a janus_sdp object to an SDP string
105
 * @param[in] sdp The janus_sdp object to serialize
106
 * @returns A pointer to a string with the serialized SDP, if successful, NULL otherwise */
107
char *janus_sdp_export(janus_sdp *sdp);
108

    
109
/*! \brief Method to free a Janus SDP object
110
 * @param[in] sdp The Janus SDP object to free */
111
void janus_sdp_free(janus_sdp *sdp);
112

    
113
#endif