Fork me on GitHub
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;
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 
110 void janus_sdp_find_preferred_codecs(janus_sdp *sdp, const char **acodec, const char **vcodec);
119 void janus_sdp_find_first_codecs(janus_sdp *sdp, const char **acodec, const char **vcodec);
125 const char *janus_sdp_match_preferred_codec(janus_sdp_mtype type, char *codec);
126 
128 typedef struct janus_sdp_mline {
132  char *type_str;
134  guint16 port;
136  char *proto;
138  GList *fmts;
140  GList *ptypes;
142  gboolean c_ipv4;
144  char *c_addr;
146  char *b_name;
148  uint32_t b_value;
152  GList *attributes;
154  volatile gint destroyed;
167 janus_sdp_mline *janus_sdp_mline_create(janus_sdp_mtype type, guint16 port, const char *proto, janus_sdp_mdirection direction);
188 
190 typedef struct janus_sdp_attribute {
192  char *name;
194  char *value;
198  volatile gint destroyed;
206 janus_sdp_attribute *janus_sdp_attribute_create(const char *name, const char *value, ...) G_GNUC_PRINTF(2, 3);
216 
223 janus_sdp *janus_sdp_parse(const char *sdp, char *error, size_t errlen);
224 
229 int janus_sdp_remove_payload_type(janus_sdp *sdp, int pt);
230 
234 char *janus_sdp_write(janus_sdp *sdp);
235 
242 janus_sdp *janus_sdp_new(const char *name, const char *address);
243 
246 void janus_sdp_destroy(janus_sdp *sdp);
247 
248 typedef enum janus_sdp_oa_type {
295 
317 janus_sdp *janus_sdp_generate_offer(const char *name, const char *address, ...);
337 
346 int janus_sdp_get_codec_pt(janus_sdp *sdp, const char *codec);
347 
357 int janus_sdp_get_codec_pt_full(janus_sdp *sdp, const char *codec, const char *profile);
358 
363 const char *janus_sdp_get_codec_name(janus_sdp *sdp, int pt);
364 
368 const char *janus_sdp_get_codec_rtpmap(const char *codec);
369 
374 const char *janus_sdp_get_fmtp(janus_sdp *sdp, int pt);
375 
380 
381 #endif
Reference counter mechanism.
void janus_sdp_destroy(janus_sdp *sdp)
Method to destroy a Janus SDP object.
Definition: sdp-utils.c:35
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:651
struct janus_sdp_mline janus_sdp_mline
SDP m-line representation.
int janus_sdp_get_opusred_pt(janus_sdp *sdp)
Helper to get the opus/red payload type from an SDP, if present.
Definition: sdp-utils.c:919
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:626
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:1201
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
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
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:141
const char * janus_sdp_get_codec_rtpmap(const char *codec)
Helper to get the rtpmap associated to a specific codec.
Definition: sdp-utils.c:858
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:179
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:1176
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:1160
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,...
Definition: sdp-utils.c:1075
int janus_sdp_get_codec_pt_full(janus_sdp *sdp, const char *codec, const char *profile)
Helper to get the payload type associated to a specific codec, taking into account a codec profile as...
Definition: sdp-utils.c:655
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:798
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:245
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:1467
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:227
struct janus_sdp_attribute janus_sdp_attribute
SDP a= attribute representation.
struct janus_sdp janus_sdp
Janus SDP internal object representation.
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:186
janus_sdp_mdirection
Helper enumeration to quickly identify m-line directions.
Definition: sdp-utils.h:79
@ JANUS_SDP_SENDONLY
sendonly
Definition: sdp-utils.h:85
@ JANUS_SDP_RECVONLY
recvonly
Definition: sdp-utils.h:87
@ JANUS_SDP_INVALID
invalid direction (when parsing)
Definition: sdp-utils.h:91
@ JANUS_SDP_DEFAULT
default=sendrecv
Definition: sdp-utils.h:81
@ JANUS_SDP_SENDRECV
sendrecv
Definition: sdp-utils.h:83
@ JANUS_SDP_INACTIVE
inactive
Definition: sdp-utils.h:89
const char * janus_sdp_get_fmtp(janus_sdp *sdp, int pt)
Helper to get the fmtp associated to a specific payload type.
Definition: sdp-utils.c:892
janus_sdp_mtype
Helper enumeration to quickly identify m-line media types.
Definition: sdp-utils.h:59
@ JANUS_SDP_APPLICATION
m=application
Definition: sdp-utils.h:65
@ JANUS_SDP_VIDEO
m=video
Definition: sdp-utils.h:63
@ JANUS_SDP_OTHER
m=whatever (we don't care, unsupported)
Definition: sdp-utils.h:67
@ JANUS_SDP_AUDIO
m=audio
Definition: sdp-utils.h:61
janus_sdp_oa_type
Definition: sdp-utils.h:248
@ JANUS_SDP_OA_AUDIO
When generating an offer or answer automatically, accept/reject audio if offered (depends on value th...
Definition: sdp-utils.h:250
@ JANUS_SDP_OA_ACCEPT_EXTMAP
When generating an answer (this is ignored for offers), accept this extension (by default,...
Definition: sdp-utils.h:287
@ JANUS_SDP_OA_AUDIO_DIRECTION
When generating an offer or answer automatically, use this direction for audio (depends on value that...
Definition: sdp-utils.h:256
@ JANUS_SDP_OA_DONE
MUST be used as the last argument in janus_sdp_generate_offer and janus_sdp_generate_answer.
Definition: sdp-utils.h:293
@ JANUS_SDP_OA_VIDEO
When generating an offer or answer automatically, accept/reject video if offered (depends on value th...
Definition: sdp-utils.h:252
@ JANUS_SDP_OA_AUDIO_PT
When generating an offer (this is ignored for answers), use this payload type for audio (depends on v...
Definition: sdp-utils.h:268
@ JANUS_SDP_OA_AUDIO_CODEC
When generating an offer or answer automatically, use this codec for audio (depends on value that fol...
Definition: sdp-utils.h:260
@ JANUS_SDP_OA_AUDIO_EXTENSION
When generating an offer (this is ignored for answers), negotiate this audio extension: needs two arg...
Definition: sdp-utils.h:283
@ JANUS_SDP_OA_VIDEO_RTCPFB_DEFAULTS
When generating an offer or answer automatically, do or do not add the rtcpfb attributes we typically...
Definition: sdp-utils.h:279
@ JANUS_SDP_OA_VIDEO_FMTP
When generating an offer or answer automatically, add this custom fmtp string for video.
Definition: sdp-utils.h:277
@ JANUS_SDP_OA_VIDEO_CODEC
When generating an offer or answer automatically, use this codec for video (depends on value that fol...
Definition: sdp-utils.h:262
@ JANUS_SDP_OA_VIDEO_PT
When generating an offer (this is ignored for answers), use this payload type for video (depends on v...
Definition: sdp-utils.h:270
@ JANUS_SDP_OA_DATA
When generating an offer or answer automatically, accept/reject datachannels if offered (depends on v...
Definition: sdp-utils.h:254
@ JANUS_SDP_OA_ACCEPT_OPUSRED
When generating an answer (this is ignored for offers), accept opus/red if offered.
Definition: sdp-utils.h:291
@ JANUS_SDP_OA_VIDEO_DIRECTION
When generating an offer or answer automatically, use this direction for video (depends on value that...
Definition: sdp-utils.h:258
@ JANUS_SDP_OA_H264_PROFILE
When generating an offer or answer automatically, use this profile for H.264 (depends on value that f...
Definition: sdp-utils.h:266
@ JANUS_SDP_OA_DATA_LEGACY
When generating an offer (this is ignored for answers), use the old "DTLS/SCTP" instead of the new "U...
Definition: sdp-utils.h:281
@ JANUS_SDP_OA_AUDIO_FMTP
When generating an offer or answer automatically, add this custom fmtp string for audio.
Definition: sdp-utils.h:274
@ JANUS_SDP_OA_OPUSRED_PT
When generating an offer (this is ignored for answers), use this payload type for RED/Opus (depends o...
Definition: sdp-utils.h:289
@ JANUS_SDP_OA_VP9_PROFILE
When generating an offer or answer automatically, use this profile for VP9 (depends on value that fol...
Definition: sdp-utils.h:264
@ JANUS_SDP_OA_VIDEO_EXTENSION
When generating an offer (this is ignored for answers), negotiate this video extension: needs two arg...
Definition: sdp-utils.h:285
@ JANUS_SDP_OA_AUDIO_DTMF
When generating an offer or answer automatically, do or do not negotiate telephone events (FIXME tele...
Definition: sdp-utils.h:272
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,...
Definition: sdp-utils.c:1116
char * janus_sdp_write(janus_sdp *sdp)
Method to serialize a janus_sdp object to an SDP string.
Definition: sdp-utils.c:946
void janus_sdp_mline_destroy(janus_sdp_mline *mline)
Helper method to free a janus_sdp_mline instance.
Definition: sdp-utils.c:41
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.
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
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:213
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:198
Definition: refcount.h:78
SDP a= attribute representation.
Definition: sdp-utils.h:190
janus_sdp_mdirection direction
Attribute direction (e.g., for extmap)
Definition: sdp-utils.h:196
char * value
Attribute value.
Definition: sdp-utils.h:194
volatile gint destroyed
Atomic flag to check if this instance has been destroyed.
Definition: sdp-utils.h:198
char * name
Attribute name.
Definition: sdp-utils.h:192
janus_refcount ref
Reference counter for this instance.
Definition: sdp-utils.h:200
SDP m-line representation.
Definition: sdp-utils.h:128
gboolean c_ipv4
Media c= protocol.
Definition: sdp-utils.h:142
guint16 port
Media port.
Definition: sdp-utils.h:134
uint32_t b_value
Media b= value.
Definition: sdp-utils.h:148
janus_sdp_mtype type
Media type as a janus_sdp_mtype enumerator.
Definition: sdp-utils.h:130
char * type_str
Media type (string)
Definition: sdp-utils.h:132
GList * fmts
List of formats.
Definition: sdp-utils.h:138
janus_refcount ref
Reference counter for this instance.
Definition: sdp-utils.h:156
volatile gint destroyed
Atomic flag to check if this instance has been destroyed.
Definition: sdp-utils.h:154
char * b_name
Media b= type.
Definition: sdp-utils.h:146
GList * ptypes
List of payload types.
Definition: sdp-utils.h:140
char * proto
Media protocol.
Definition: sdp-utils.h:136
char * c_addr
Media c= address.
Definition: sdp-utils.h:144
janus_sdp_mdirection direction
Media direction.
Definition: sdp-utils.h:150
GList * attributes
List of m-line attributes.
Definition: sdp-utils.h:152
Janus SDP internal object representation.
Definition: sdp-utils.h:25
gboolean o_ipv4
o= protocol
Definition: sdp-utils.h:35
guint64 o_sessid
o= session ID
Definition: sdp-utils.h:31
char * o_name
o= name
Definition: sdp-utils.h:29
guint64 t_start
t= start
Definition: sdp-utils.h:41
volatile gint destroyed
Atomic flag to check if this instance has been destroyed.
Definition: sdp-utils.h:53
guint64 t_stop
t= stop
Definition: sdp-utils.h:43
char * c_addr
c= address (not rendered for WebRTC usage)
Definition: sdp-utils.h:47
janus_refcount ref
Reference counter for this instance.
Definition: sdp-utils.h:55
int version
v=
Definition: sdp-utils.h:27
gboolean c_ipv4
c= protocol (not rendered for WebRTC usage)
Definition: sdp-utils.h:45
GList * attributes
List of global a= attributes.
Definition: sdp-utils.h:49
char * o_addr
o= address
Definition: sdp-utils.h:37
GList * m_lines
List of m= m-lines.
Definition: sdp-utils.h:51
char * s_name
s=
Definition: sdp-utils.h:39
guint64 o_version
o= version
Definition: sdp-utils.h:33