Fork me on GitHub
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups 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 
22 #include "refcount.h"
23 
25 typedef struct janus_sdp {
27  int version;
29  char *o_name;
31  guint64 o_sessid;
33  guint64 o_version;
35  gboolean o_ipv4;
37  char *o_addr;
39  char *s_name;
41  guint64 t_start;
43  guint64 t_stop;
45  gboolean c_ipv4;
47  char *c_addr;
49  GList *attributes;
51  GList *m_lines;
53  volatile gint destroyed;
56 } janus_sdp;
57 
59 typedef enum janus_sdp_mtype {
72 janus_sdp_mtype janus_sdp_parse_mtype(const char *type);
76 const char *janus_sdp_mtype_str(janus_sdp_mtype type);
77 
79 typedef enum janus_sdp_mdirection {
100 const char *janus_sdp_mdirection_str(janus_sdp_mdirection direction);
101 
111 void janus_sdp_find_preferred_codec(janus_sdp *sdp, janus_sdp_mtype type, int index, const char **codec);
121 void janus_sdp_find_first_codecs(janus_sdp *sdp, janus_sdp_mtype type, int index, const char **codec);
127 const char *janus_sdp_match_preferred_codec(janus_sdp_mtype type, char *codec);
128 
130 typedef struct janus_sdp_mline {
132  int index;
136  char *type_str;
138  guint16 port;
140  char *proto;
142  GList *fmts;
144  GList *ptypes;
146  gboolean c_ipv4;
148  char *c_addr;
150  char *b_name;
152  uint32_t b_value;
156  GList *attributes;
158  volatile gint destroyed;
171 janus_sdp_mline *janus_sdp_mline_create(janus_sdp_mtype type, guint16 port, const char *proto, janus_sdp_mdirection direction);
195 
197 typedef struct janus_sdp_attribute {
199  char *name;
201  char *value;
205  volatile gint destroyed;
213 janus_sdp_attribute *janus_sdp_attribute_create(const char *name, const char *value, ...) G_GNUC_PRINTF(2, 3);
223 
230 janus_sdp *janus_sdp_parse(const char *sdp, char *error, size_t errlen);
231 
235 char *janus_sdp_write(janus_sdp *sdp);
236 
243 janus_sdp *janus_sdp_new(const char *name, const char *address);
244 
247 void janus_sdp_destroy(janus_sdp *sdp);
248 
249 typedef enum janus_sdp_oa_type {
277 const char *janus_sdp_oa_type_str(janus_sdp_oa_type type);
278 
304 janus_sdp *janus_sdp_generate_offer(const char *name, const char *address, ...);
351 int janus_sdp_generate_answer_mline(janus_sdp *offer, janus_sdp *answer, janus_sdp_mline *offered, ...);
352 
358 int janus_sdp_get_codec_pt(janus_sdp *sdp, int index, const char *codec);
359 
365 const char *janus_sdp_get_codec_name(janus_sdp *sdp, int index, int pt);
366 
372 int janus_sdp_remove_payload_type(janus_sdp *sdp, int index, int pt);
373 
377 const char *janus_sdp_get_codec_rtpmap(const char *codec);
378 
379 #endif
int janus_sdp_generate_offer_mline(janus_sdp *offer,...)
Method to add a single m-line to a new offer, using the same variable arguments janus_sdp_generate_of...
Definition: sdp-utils.c:1183
int janus_sdp_generate_answer_mline(janus_sdp *offer, janus_sdp *answer, janus_sdp_mline *offered,...)
Method to respond to a single m-line in an offer, using the same variable arguments janus_sdp_generat...
Definition: sdp-utils.c:1397
char * s_name
s=
Definition: sdp-utils.h:39
int janus_sdp_remove_payload_type(janus_sdp *sdp, int index, int pt)
Helper method to quickly remove all traces (m-line, rtpmap, fmtp, etc.) of a payload type...
Definition: sdp-utils.c:642
GList * m_lines
List of m= m-lines.
Definition: sdp-utils.h:51
struct janus_sdp janus_sdp
Janus SDP internal object representation.
void janus_sdp_find_preferred_codec(janus_sdp *sdp, janus_sdp_mtype type, int index, const char **codec)
Helper method to return the preferred audio or video codec 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:946
When generating an offer (this is ignored for answers), use this payload type (depends on value that ...
Definition: sdp-utils.h:261
volatile gint destroyed
Atomic flag to check if this instance has been destroyed.
Definition: sdp-utils.h:158
Reference counter mechanism.
int janus_sdp_get_codec_pt(janus_sdp *sdp, int index, const char *codec)
Helper to get the payload type associated to a specific codec in an m-line.
Definition: sdp-utils.c:673
When generating an offer or answer automatically, do or do not add the rtcpfb attributes we typically...
Definition: sdp-utils.h:267
janus_sdp_mtype type
Media type as a janus_sdp_mtype enumerator.
Definition: sdp-utils.h:134
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:192
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:240
When generating an answer (this is ignored for offers), accept this extension (by default...
Definition: sdp-utils.h:273
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:111
const char * janus_sdp_get_codec_rtpmap(const char *codec)
Helper to get the rtpmap associated to a specific codec.
Definition: sdp-utils.c:806
inactive
Definition: sdp-utils.h:89
guint16 port
Media port.
Definition: sdp-utils.h:138
default=sendrecv
Definition: sdp-utils.h:81
SDP m-line representation.
Definition: sdp-utils.h:130
void janus_sdp_mline_destroy(janus_sdp_mline *mline)
Helper method to free a janus_sdp_mline instance.
Definition: sdp-utils.c:41
char * o_name
o= name
Definition: sdp-utils.h:29
janus_refcount ref
Reference counter for this instance.
Definition: sdp-utils.h:207
m=whatever (we don't care, unsupported)
Definition: sdp-utils.h:67
GList * attributes
List of global a= attributes.
Definition: sdp-utils.h:49
sendonly
Definition: sdp-utils.h:85
janus_sdp_mtype
Helper enumeration to quickly identify m-line media types.
Definition: sdp-utils.h:59
const char * janus_sdp_get_codec_name(janus_sdp *sdp, int index, int pt)
Helper to get the codec name associated to a specific payload type in an m-line.
Definition: sdp-utils.c:749
struct janus_sdp_mline janus_sdp_mline
SDP m-line representation.
janus_sdp_mline * janus_sdp_mline_find_by_index(janus_sdp *sdp, int index)
Helper method to get the janus_sdp_mline by its index.
Definition: sdp-utils.c:141
char * o_addr
o= address
Definition: sdp-utils.h:37
char * proto
Media protocol.
Definition: sdp-utils.h:140
GList * fmts
List of formats.
Definition: sdp-utils.h:142
When generating an offer or answer automatically, use this codec (depends on value that follows...
Definition: sdp-utils.h:259
janus_sdp_mdirection direction
Attribute direction (e.g., for extmap)
Definition: sdp-utils.h:203
When generating an offer or answer automatically, use this direction for media (depends on value that...
Definition: sdp-utils.h:255
Definition: refcount.h:78
Janus SDP internal object representation.
Definition: sdp-utils.h:25
guint64 o_sessid
o= session ID
Definition: sdp-utils.h:31
const char * janus_sdp_oa_type_str(janus_sdp_oa_type type)
Definition: sdp-utils.c:258
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:211
char * c_addr
c= address (not rendered for WebRTC usage)
Definition: sdp-utils.h:47
GList * ptypes
List of payload types.
Definition: sdp-utils.h:144
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:1008
uint32_t b_value
Media b= value.
Definition: sdp-utils.h:152
gboolean c_ipv4
c= protocol (not rendered for WebRTC usage)
Definition: sdp-utils.h:45
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:199
invalid direction (when parsing)
Definition: sdp-utils.h:91
Add a new m-line of the specific kind (used as a separator for audio, video and data details passed t...
Definition: sdp-utils.h:251
guint64 o_version
o= version
Definition: sdp-utils.h:33
guint64 t_start
t= start
Definition: sdp-utils.h:41
Whether we should enable a specific m-line when offering/answering (depends on what follows...
Definition: sdp-utils.h:253
janus_sdp_mdirection
Helper enumeration to quickly identify m-line directions.
Definition: sdp-utils.h:79
When generating an offer or answer automatically, do or do not negotiate telephone events (FIXME tele...
Definition: sdp-utils.h:265
gboolean c_ipv4
Media c= protocol.
Definition: sdp-utils.h:146
struct janus_sdp_attribute janus_sdp_attribute
SDP a= attribute representation.
When generating an offer or answer automatically, add this custom fmtp string.
Definition: sdp-utils.h:263
janus_sdp_mdirection direction
Media direction.
Definition: sdp-utils.h:154
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:128
char * b_name
Media b= type.
Definition: sdp-utils.h:150
SDP a= attribute representation.
Definition: sdp-utils.h:197
gboolean o_ipv4
o= protocol
Definition: sdp-utils.h:35
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:1024
When generating an offer or answer automatically, do or do not add the default fmtp attribute for H...
Definition: sdp-utils.h:269
MUST be used as the last argument in janus_sdp_generate_offer, janus_sdp_generate_offer_mline and jan...
Definition: sdp-utils.h:275
char * janus_sdp_write(janus_sdp *sdp)
Method to serialize a janus_sdp object to an SDP string.
Definition: sdp-utils.c:833
int version
v=
Definition: sdp-utils.h:27
m=video
Definition: sdp-utils.h:63
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:290
m=audio
Definition: sdp-utils.h:61
janus_sdp_oa_type
Definition: sdp-utils.h:249
int index
Media index in the SDP.
Definition: sdp-utils.h:132
recvonly
Definition: sdp-utils.h:87
When generating an offer automatically, use this mid media (depends on value that follows...
Definition: sdp-utils.h:257
char * name
Attribute name.
Definition: sdp-utils.h:199
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:226
char * c_addr
Media c= address.
Definition: sdp-utils.h:148
char * type_str
Media type (string)
Definition: sdp-utils.h:136
volatile gint destroyed
Atomic flag to check if this instance has been destroyed.
Definition: sdp-utils.h:205
janus_refcount ref
Reference counter for this instance.
Definition: sdp-utils.h:55
guint64 t_stop
t= stop
Definition: sdp-utils.h:43
m=application
Definition: sdp-utils.h:65
GList * attributes
List of m-line attributes.
Definition: sdp-utils.h:156
janus_sdp * janus_sdp_generate_answer(janus_sdp *offer)
Method to generate a janus_sdp answer to a provided janus_sdp offer. Notice that this doesn't address...
Definition: sdp-utils.c:1347
char * value
Attribute value.
Definition: sdp-utils.h:201
void janus_sdp_destroy(janus_sdp *sdp)
Method to destroy a Janus SDP object.
Definition: sdp-utils.c:35
janus_refcount ref
Reference counter for this instance.
Definition: sdp-utils.h:160
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:1046
void janus_sdp_find_first_codecs(janus_sdp *sdp, janus_sdp_mtype type, int index, const char **codec)
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:978
volatile gint destroyed
Atomic flag to check if this instance has been destroyed.
Definition: sdp-utils.h:53
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:83
When generating an offer (this is ignored for answers), use the old "DTLS/SCTP" instead of the new "U...
Definition: sdp-utils.h:271
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:154
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:47