Fork me on GitHub
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
sdp-utils.h
Go to the documentation of this file.
1 
15 #ifndef _JANUS_SDP_UTILS_H
16 #define _JANUS_SDP_UTILS_H
17 
18 
19 #include <inttypes.h>
20 #include <glib.h>
21 
23 typedef struct janus_sdp {
25  int version;
27  char *o_name;
29  guint64 o_sessid;
31  guint64 o_version;
33  gboolean o_ipv4;
35  char *o_addr;
37  char *s_name;
39  guint64 t_start;
41  guint64 t_stop;
43  gboolean c_ipv4;
45  char *c_addr;
47  GList *attributes;
49  GList *m_lines;
50 } janus_sdp;
51 
53 typedef enum janus_sdp_mtype {
66 janus_sdp_mtype janus_sdp_parse_mtype(const char *type);
70 const char *janus_sdp_mtype_str(janus_sdp_mtype type);
71 
73 typedef enum janus_sdp_mdirection {
94 const char *janus_sdp_mdirection_str(janus_sdp_mdirection direction);
95 
104 void janus_sdp_find_preferred_codecs(janus_sdp *sdp, const char **acodec, const char **vcodec);
113 void janus_sdp_find_first_codecs(janus_sdp *sdp, const char **acodec, const char **vcodec);
119 const char *janus_sdp_match_preferred_codec(janus_sdp_mtype type, char *codec);
120 
122 typedef struct janus_sdp_mline {
126  char *type_str;
128  guint16 port;
130  char *proto;
132  GList *fmts;
134  GList *ptypes;
136  gboolean c_ipv4;
138  char *c_addr;
140  char *b_name;
142  int b_value;
146  GList *attributes;
157 janus_sdp_mline *janus_sdp_mline_create(janus_sdp_mtype type, guint16 port, const char *proto, janus_sdp_mdirection direction);
178 
180 typedef struct janus_sdp_attribute {
182  char *name;
184  char *value;
192 janus_sdp_attribute *janus_sdp_attribute_create(const char *name, const char *value, ...) G_GNUC_PRINTF(2, 3);
202 
209 janus_sdp *janus_sdp_parse(const char *sdp, char *error, size_t errlen);
210 
215 int janus_sdp_remove_payload_type(janus_sdp *sdp, int pt);
216 
220 char *janus_sdp_write(janus_sdp *sdp);
221 
228 janus_sdp *janus_sdp_new(const char *name, const char *address);
229 
232 void janus_sdp_free(janus_sdp *sdp);
233 
235 #define JANUS_SDP_OA_AUDIO 1
236 
237 #define JANUS_SDP_OA_VIDEO 2
238 
239 #define JANUS_SDP_OA_DATA 3
240 
241 #define JANUS_SDP_OA_AUDIO_DIRECTION 4
242 
243 #define JANUS_SDP_OA_VIDEO_DIRECTION 5
244 
245 #define JANUS_SDP_OA_AUDIO_CODEC 6
246 
247 #define JANUS_SDP_OA_VIDEO_CODEC 7
248 
249 #define JANUS_SDP_OA_AUDIO_PT 8
250 
251 #define JANUS_SDP_OA_VIDEO_PT 9
252 
253 #define JANUS_SDP_OA_AUDIO_DTMF 10
254 
255 #define JANUS_SDP_OA_VIDEO_RTCPFB_DEFAULTS 11
256 
257 #define JANUS_SDP_OA_VIDEO_H264_FMTP 12
258 
259 #define JANUS_SDP_OA_DONE 0
260 
282 janus_sdp *janus_sdp_generate_offer(const char *name, const char *address, ...);
302 
307 int janus_sdp_get_codec_pt(janus_sdp *sdp, const char *codec);
308 
313 const char *janus_sdp_get_codec_name(janus_sdp *sdp, int pt);
314 
318 const char *janus_sdp_get_codec_rtpmap(const char *codec);
319 
320 #endif
char * s_name
s=
Definition: sdp-utils.h:37
GList * m_lines
List of m= m-lines.
Definition: sdp-utils.h:49
struct janus_sdp janus_sdp
Janus SDP internal object representation.
janus_sdp_mtype type
Media type as a janus_sdp_mtype enumerator.
Definition: sdp-utils.h:124
int b_value
Media b= value.
Definition: sdp-utils.h:142
int janus_sdp_attribute_add_to_mline(janus_sdp_mline *mline, janus_sdp_attribute *attr)
Helper method to add an attribute to a media line.
Definition: sdp-utils.c:152
const char * janus_sdp_mdirection_str(janus_sdp_mdirection direction)
Helper method to get the string associated to a janus_sdp_mdirection value.
Definition: sdp-utils.c:200
janus_sdp_mline * janus_sdp_mline_create(janus_sdp_mtype type, guint16 port, const char *proto, janus_sdp_mdirection direction)
Helper method to quickly create a janus_sdp_mline instance.
Definition: sdp-utils.c:59
const char * janus_sdp_get_codec_rtpmap(const char *codec)
Helper to get the rtpmap associated to a specific codec.
Definition: sdp-utils.c:661
inactive
Definition: sdp-utils.h:83
guint16 port
Media port.
Definition: sdp-utils.h:128
default=sendrecv
Definition: sdp-utils.h:75
SDP m-line representation.
Definition: sdp-utils.h:122
void janus_sdp_mline_destroy(janus_sdp_mline *mline)
Helper method to free a janus_sdp_mline instance.
Definition: sdp-utils.c:74
char * o_name
o= name
Definition: sdp-utils.h:27
m=whatever (we don't care, unsupported)
Definition: sdp-utils.h:61
GList * attributes
List of global a= attributes.
Definition: sdp-utils.h:47
int janus_sdp_get_codec_pt(janus_sdp *sdp, const char *codec)
Helper to get the payload type associated to a specific codec.
Definition: sdp-utils.c:540
sendonly
Definition: sdp-utils.h:79
janus_sdp_mtype
Helper enumeration to quickly identify m-line media types.
Definition: sdp-utils.h:53
struct janus_sdp_mline janus_sdp_mline
SDP m-line representation.
char * o_addr
o= address
Definition: sdp-utils.h:35
void janus_sdp_find_preferred_codecs(janus_sdp *sdp, const char **acodec, const char **vcodec)
Helper method to return the preferred audio and video codecs in an SDP offer or answer, (where by preferred we mean the codecs we prefer ourselves, and not the m-line SDP order) as long as the m-line direction is not disabled (port=0 or direction=inactive) in the SDP.
Definition: sdp-utils.c:799
char * proto
Media protocol.
Definition: sdp-utils.h:130
GList * fmts
List of formats.
Definition: sdp-utils.h:132
janus_sdp_mdirection direction
Attribute direction (e.g., for extmap)
Definition: sdp-utils.h:186
Janus SDP internal object representation.
Definition: sdp-utils.h:23
guint64 o_sessid
o= session ID
Definition: sdp-utils.h:29
void janus_sdp_find_first_codecs(janus_sdp *sdp, const char **acodec, const char **vcodec)
Helper method to return the first audio and video codecs in an SDP offer or answer, (no matter whether we personally prefer them ourselves or not) as long as the m-line direction is not disabled (port=0 or direction=inactive) in the SDP.
Definition: sdp-utils.c:838
const char * janus_sdp_mtype_str(janus_sdp_mtype type)
Helper method to get the string associated to a janus_sdp_mtype value.
Definition: sdp-utils.c:171
char * c_addr
c= address (not rendered for WebRTC usage)
Definition: sdp-utils.h:45
GList * ptypes
List of payload types.
Definition: sdp-utils.h:134
const char * janus_sdp_match_preferred_codec(janus_sdp_mtype type, char *codec)
Helper method to match a codec to one of the preferred codecs.
Definition: sdp-utils.c:875
gboolean c_ipv4
c= protocol (not rendered for WebRTC usage)
Definition: sdp-utils.h:43
janus_sdp_mtype janus_sdp_parse_mtype(const char *type)
Helper method to get a janus_sdp_mtype from a string.
Definition: sdp-utils.c:159
invalid direction (when parsing)
Definition: sdp-utils.h:85
guint64 o_version
o= version
Definition: sdp-utils.h:31
guint64 t_start
t= start
Definition: sdp-utils.h:39
janus_sdp_mdirection
Helper enumeration to quickly identify m-line directions.
Definition: sdp-utils.h:73
gboolean c_ipv4
Media c= protocol.
Definition: sdp-utils.h:136
struct janus_sdp_attribute janus_sdp_attribute
SDP a= attribute representation.
janus_sdp_mdirection direction
Media direction.
Definition: sdp-utils.h:144
janus_sdp_mline * janus_sdp_mline_find(janus_sdp *sdp, janus_sdp_mtype type)
Helper method to get the janus_sdp_mline associated to a media type.
Definition: sdp-utils.c:95
char * b_name
Media b= type.
Definition: sdp-utils.h:140
SDP a= attribute representation.
Definition: sdp-utils.h:180
gboolean o_ipv4
o= protocol
Definition: sdp-utils.h:33
janus_sdp * janus_sdp_new(const char *name, const char *address)
Method to quickly generate a janus_sdp instance from a few selected fields.
Definition: sdp-utils.c:891
char * janus_sdp_write(janus_sdp *sdp)
Method to serialize a janus_sdp object to an SDP string.
Definition: sdp-utils.c:688
void janus_sdp_free(janus_sdp *sdp)
Method to free a Janus SDP object.
Definition: sdp-utils.c:33
int version
v=
Definition: sdp-utils.h:25
m=video
Definition: sdp-utils.h:57
janus_sdp * janus_sdp_parse(const char *sdp, char *error, size_t errlen)
Method to parse an SDP string to a janus_sdp object.
Definition: sdp-utils.c:218
m=audio
Definition: sdp-utils.h:55
janus_sdp * janus_sdp_generate_answer(janus_sdp *offer,...)
Method to generate a janus_sdp answer to a provided janus_sdp offer, using variable arguments to dict...
Definition: sdp-utils.c:1036
recvonly
Definition: sdp-utils.h:81
char * name
Attribute name.
Definition: sdp-utils.h:182
janus_sdp_mdirection janus_sdp_parse_mdirection(const char *direction)
Helper method to get a janus_sdp_mdirection from a string.
Definition: sdp-utils.c:186
char * c_addr
Media c= address.
Definition: sdp-utils.h:138
char * type_str
Media type (string)
Definition: sdp-utils.h:126
int janus_sdp_remove_payload_type(janus_sdp *sdp, int pt)
Helper method to quickly remove all traces (m-line, rtpmap, fmtp, etc.) of a payload type...
Definition: sdp-utils.c:515
const char * janus_sdp_get_codec_name(janus_sdp *sdp, int pt)
Helper to get the codec name associated to a specific payload type.
Definition: sdp-utils.c:610
guint64 t_stop
t= stop
Definition: sdp-utils.h:41
m=application
Definition: sdp-utils.h:59
GList * attributes
List of m-line attributes.
Definition: sdp-utils.h:146
char * value
Attribute value.
Definition: sdp-utils.h:184
janus_sdp * janus_sdp_generate_offer(const char *name, const char *address,...)
Method to generate a janus_sdp offer, using variable arguments to dictate what to negotiate (e...
Definition: sdp-utils.c:911
janus_sdp_attribute * janus_sdp_attribute_create(const char *name, const char *value,...) G_GNUC_PRINTF(2
Helper method to quickly create a janus_sdp_attribute instance.
sendrecv
Definition: sdp-utils.h:77
int janus_sdp_mline_remove(janus_sdp *sdp, janus_sdp_mtype type)
Helper method to remove the janus_sdp_mline associated to a media type from the SDP.
Definition: sdp-utils.c:108
janus_sdp_attribute void janus_sdp_attribute_destroy(janus_sdp_attribute *attr)
Helper method to free a janus_sdp_attribute instance.
Definition: sdp-utils.c:144