Loading...
Searching...
No Matches
sdp-utils.h
Go to the documentation of this file.
#ifndef JANUS_SDP_UTILS_H
#define JANUS_SDP_UTILS_H
#include <inttypes.h>
#include <glib.h>
#include "rtp.h"
#include "refcount.h"
typedef struct janus_sdp {
int version;
char *o_name;
guint64 o_sessid;
guint64 o_version;
gboolean o_ipv4;
char *o_addr;
char *s_name;
guint64 t_start;
guint64 t_stop;
gboolean c_ipv4;
char *c_addr;
GList *attributes;
GList *m_lines;
volatile gint destroyed;
janus_refcount ref;
} janus_sdp;
typedef enum janus_sdp_mtype {
JANUS_SDP_AUDIO,
JANUS_SDP_VIDEO,
JANUS_SDP_APPLICATION,
JANUS_SDP_OTHER
} janus_sdp_mtype;
janus_sdp_mtype janus_sdp_parse_mtype(const char *type);
const char *janus_sdp_mtype_str(janus_sdp_mtype type);
typedef enum janus_sdp_mdirection {
JANUS_SDP_DEFAULT,
JANUS_SDP_SENDRECV,
JANUS_SDP_SENDONLY,
JANUS_SDP_RECVONLY,
JANUS_SDP_INACTIVE,
JANUS_SDP_INVALID
} janus_sdp_mdirection;
janus_sdp_mdirection janus_sdp_parse_mdirection(const char *direction);
const char *janus_sdp_mdirection_str(janus_sdp_mdirection direction);
void janus_sdp_find_preferred_codec(janus_sdp *sdp, janus_sdp_mtype type, int index, const char **codec);
void janus_sdp_find_first_codec(janus_sdp *sdp, janus_sdp_mtype type, int index, const char **codec);
const char *janus_sdp_match_preferred_codec(janus_sdp_mtype type, char *codec);
typedef struct janus_sdp_mline {
int index;
janus_sdp_mtype type;
char *type_str;
guint16 port;
char *proto;
GList *fmts;
GList *ptypes;
gboolean c_ipv4;
char *c_addr;
char *b_name;
uint32_t b_value;
janus_sdp_mdirection direction;
GList *attributes;
volatile gint destroyed;
janus_refcount ref;
} janus_sdp_mline;
janus_sdp_mline *janus_sdp_mline_create(janus_sdp_mtype type, guint16 port, const char *proto, janus_sdp_mdirection direction);
void janus_sdp_mline_destroy(janus_sdp_mline *mline);
janus_sdp_mline *janus_sdp_mline_find(janus_sdp *sdp, janus_sdp_mtype type);
janus_sdp_mline *janus_sdp_mline_find_by_index(janus_sdp *sdp, int index);
int janus_sdp_mline_remove(janus_sdp *sdp, janus_sdp_mtype type);
typedef struct janus_sdp_attribute {
char *name;
char *value;
janus_sdp_mdirection direction;
volatile gint destroyed;
janus_refcount ref;
} janus_sdp_attribute;
janus_sdp_attribute *janus_sdp_attribute_create(const char *name, const char *value, ...) G_GNUC_PRINTF(2, 3);
void janus_sdp_attribute_destroy(janus_sdp_attribute *attr);
int janus_sdp_attribute_add_to_mline(janus_sdp_mline *mline, janus_sdp_attribute *attr);
janus_sdp *janus_sdp_parse(const char *sdp, char *error, size_t errlen);
int janus_sdp_remove_payload_type(janus_sdp *sdp, int index, int pt);
char *janus_sdp_write(janus_sdp *sdp);
janus_sdp *janus_sdp_new(const char *name, const char *address);
void janus_sdp_destroy(janus_sdp *sdp);
typedef enum janus_sdp_oa_type {
JANUS_SDP_OA_MLINE = 1,
JANUS_SDP_OA_ENABLED,
JANUS_SDP_OA_DIRECTION,
JANUS_SDP_OA_MID,
JANUS_SDP_OA_MSID,
JANUS_SDP_OA_CODEC,
JANUS_SDP_OA_EXTENSION,
JANUS_SDP_OA_EXTENSIONS,
JANUS_SDP_OA_ACCEPT_EXTMAP,
JANUS_SDP_OA_PT,
JANUS_SDP_OA_FMTP,
JANUS_SDP_OA_AUDIO_DTMF,
JANUS_SDP_OA_OPUSRED_PT,
JANUS_SDP_OA_ACCEPT_OPUSRED,
JANUS_SDP_OA_VP9_PROFILE,
JANUS_SDP_OA_H264_PROFILE,
JANUS_SDP_OA_VIDEO_RTCPFB_DEFAULTS,
JANUS_SDP_OA_DATA_LEGACY,
JANUS_SDP_OA_DONE = 0
} janus_sdp_oa_type;
const char *janus_sdp_oa_type_str(janus_sdp_oa_type type);
janus_sdp *janus_sdp_generate_offer(const char *name, const char *address, ...);
int janus_sdp_generate_offer_mline(janus_sdp *offer, ...);
janus_sdp *janus_sdp_generate_answer(janus_sdp *offer);
int janus_sdp_generate_answer_mline(janus_sdp *offer, janus_sdp *answer, janus_sdp_mline *offered, ...);
int janus_sdp_get_codec_pt(janus_sdp *sdp, int index, const char *codec);
int janus_sdp_get_codec_pt_full(janus_sdp *sdp, int index, const char *codec, const char *profile);
const char *janus_sdp_get_codec_name(janus_sdp *sdp, int index, int pt);
const char *janus_sdp_get_rtpmap_codec(const char *rtpmap);
const char *janus_sdp_get_codec_rtpmap(const char *codec);
const char *janus_sdp_get_fmtp(janus_sdp *sdp, int index, int pt);
char *janus_sdp_get_video_profile(janus_videocodec codec, const char *fmtp);
int janus_sdp_get_opusred_pt(janus_sdp *sdp, int index);
#endif
refcount.h
Reference counter mechanism.
rtp.h
RTP processing (headers)
janus_videocodec
janus_videocodec
Definition rtp.h:116
janus_sdp_find_preferred_codec
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,...
Definition sdp-utils.c:1247
janus_sdp_destroy
void janus_sdp_destroy(janus_sdp *sdp)
Method to destroy a Janus SDP object.
Definition sdp-utils.c:33
janus_sdp_attribute_destroy
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:45
janus_sdp_mline_remove
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:152
janus_sdp_mdirection_str
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:238
janus_sdp_attribute_create
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_parse
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:298
janus_sdp_mline_find
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:126
janus_sdp_remove_payload_type
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:682
janus_sdp_attribute_add_to_mline
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:190
janus_sdp_get_codec_name
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:872
janus_sdp_mline_find_by_index
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:139
janus_sdp_oa_type_str
const char * janus_sdp_oa_type_str(janus_sdp_oa_type type)
Definition sdp-utils.c:256
janus_sdp_mtype_str
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:209
janus_sdp_match_preferred_codec
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:1314
janus_sdp_generate_answer_mline
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:1910
janus_sdp_get_codec_pt_full
int janus_sdp_get_codec_pt_full(janus_sdp *sdp, int index, const char *codec, const char *profile)
Helper to get the payload type associated to a specific codec, in an m-line, taking into account a co...
Definition sdp-utils.c:717
janus_sdp_generate_offer
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:1355
janus_sdp_get_fmtp
const char * janus_sdp_get_fmtp(janus_sdp *sdp, int index, int pt)
Helper to get the fmtp associated to a specific payload type.
Definition sdp-utils.c:1021
janus_sdp_parse_mtype
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:197
janus_sdp_generate_offer_mline
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:1569
janus_sdp_mdirection
janus_sdp_mdirection
Helper enumeration to quickly identify m-line directions.
Definition sdp-utils.h:80
JANUS_SDP_SENDONLY
@ JANUS_SDP_SENDONLY
sendonly
Definition sdp-utils.h:86
JANUS_SDP_RECVONLY
@ JANUS_SDP_RECVONLY
recvonly
Definition sdp-utils.h:88
JANUS_SDP_INVALID
@ JANUS_SDP_INVALID
invalid direction (when parsing)
Definition sdp-utils.h:92
JANUS_SDP_DEFAULT
@ JANUS_SDP_DEFAULT
default=sendrecv
Definition sdp-utils.h:82
JANUS_SDP_SENDRECV
@ JANUS_SDP_SENDRECV
sendrecv
Definition sdp-utils.h:84
JANUS_SDP_INACTIVE
@ JANUS_SDP_INACTIVE
inactive
Definition sdp-utils.h:90
janus_sdp_mline_create
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:109
janus_sdp_new
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:1330
janus_sdp_mtype
janus_sdp_mtype
Helper enumeration to quickly identify m-line media types.
Definition sdp-utils.h:60
JANUS_SDP_APPLICATION
@ JANUS_SDP_APPLICATION
m=application
Definition sdp-utils.h:66
JANUS_SDP_VIDEO
@ JANUS_SDP_VIDEO
m=video
Definition sdp-utils.h:64
JANUS_SDP_OTHER
@ JANUS_SDP_OTHER
m=whatever (we don't care, unsupported)
Definition sdp-utils.h:68
JANUS_SDP_AUDIO
@ JANUS_SDP_AUDIO
m=audio
Definition sdp-utils.h:62
janus_sdp_oa_type
janus_sdp_oa_type
Definition sdp-utils.h:257
JANUS_SDP_OA_EXTENSIONS
@ JANUS_SDP_OA_EXTENSIONS
When generating an offer (this is ignored for answers), negotiate these extensions: needs a hashtable...
Definition sdp-utils.h:274
JANUS_SDP_OA_ACCEPT_EXTMAP
@ JANUS_SDP_OA_ACCEPT_EXTMAP
When generating an answer (this is ignored for offers), accept this extension (by default,...
Definition sdp-utils.h:276
JANUS_SDP_OA_DONE
@ JANUS_SDP_OA_DONE
MUST be used as the last argument in janus_sdp_generate_offer, janus_sdp_generate_offer_mline and jan...
Definition sdp-utils.h:297
JANUS_SDP_OA_MID
@ JANUS_SDP_OA_MID
When generating an offer automatically, use this mid (depends on value that follows,...
Definition sdp-utils.h:265
JANUS_SDP_OA_VIDEO_RTCPFB_DEFAULTS
@ 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:293
JANUS_SDP_OA_FMTP
@ JANUS_SDP_OA_FMTP
When generating an offer or answer automatically, add this custom fmtp string.
Definition sdp-utils.h:281
JANUS_SDP_OA_ENABLED
@ JANUS_SDP_OA_ENABLED
Whether we should enable a specific m-line when offering/answering (depends on what follows,...
Definition sdp-utils.h:261
JANUS_SDP_OA_EXTENSION
@ JANUS_SDP_OA_EXTENSION
When generating an offer (this is ignored for answers), negotiate this extension: needs two arguments...
Definition sdp-utils.h:271
JANUS_SDP_OA_DIRECTION
@ JANUS_SDP_OA_DIRECTION
When generating an offer or answer automatically, use this direction for media (depends on value that...
Definition sdp-utils.h:263
JANUS_SDP_OA_ACCEPT_OPUSRED
@ JANUS_SDP_OA_ACCEPT_OPUSRED
When generating an answer (this is ignored for offers), accept opus/red if offered.
Definition sdp-utils.h:287
JANUS_SDP_OA_PT
@ JANUS_SDP_OA_PT
When generating an offer (this is ignored for answers), use this payload type (depends on value that ...
Definition sdp-utils.h:278
JANUS_SDP_OA_MLINE
@ JANUS_SDP_OA_MLINE
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:259
JANUS_SDP_OA_H264_PROFILE
@ 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:291
JANUS_SDP_OA_DATA_LEGACY
@ 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:295
JANUS_SDP_OA_OPUSRED_PT
@ 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:285
JANUS_SDP_OA_VP9_PROFILE
@ 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:289
JANUS_SDP_OA_MSID
@ JANUS_SDP_OA_MSID
When generating an offer or answer automatically, use this msid (depends on the two strings that foll...
Definition sdp-utils.h:267
JANUS_SDP_OA_AUDIO_DTMF
@ 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:283
JANUS_SDP_OA_CODEC
@ JANUS_SDP_OA_CODEC
When generating an offer or answer automatically, use this codec (depends on value that follows,...
Definition sdp-utils.h:269
janus_sdp_generate_answer
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:1851
janus_sdp_get_rtpmap_codec
const char * janus_sdp_get_rtpmap_codec(const char *rtpmap)
Helper to get the codec name associated to a specific rtpmap.
Definition sdp-utils.c:942
janus_sdp_get_video_profile
char * janus_sdp_get_video_profile(janus_videocodec codec, const char *fmtp)
Helper to extract the H.264 or VP9 profile from a fmtp string.
Definition sdp-utils.c:1054
janus_sdp_mline_destroy
void janus_sdp_mline_destroy(janus_sdp_mline *mline)
Helper method to free a janus_sdp_mline instance.
Definition sdp-utils.c:39
janus_sdp_find_first_codec
void janus_sdp_find_first_codec(janus_sdp *sdp, janus_sdp_mtype type, int index, const char **codec)
Helper method to return the first audio or video codec in an SDP offer or answer, (no matter whether ...
Definition sdp-utils.c:1279
janus_sdp_get_opusred_pt
int janus_sdp_get_opusred_pt(janus_sdp *sdp, int index)
Helper to get the opus/red payload type from an SDP, if present.
Definition sdp-utils.c:1085
janus_sdp_parse_mdirection
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:224
janus_sdp_get_codec_rtpmap
const char * janus_sdp_get_codec_rtpmap(const char *codec)
Helper to get the rtpmap associated to a specific codec.
Definition sdp-utils.c:983
janus_sdp_get_codec_pt
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:713
janus_sdp_write
char * janus_sdp_write(janus_sdp *sdp)
Method to serialize a janus_sdp object to an SDP string.
Definition sdp-utils.c:1118
janus_refcount
Definition refcount.h:78
janus_sdp_attribute
SDP a= attribute representation.
Definition sdp-utils.h:198
janus_sdp_attribute::direction
janus_sdp_mdirection direction
Attribute direction (e.g., for extmap)
Definition sdp-utils.h:204
janus_sdp_attribute::value
char * value
Attribute value.
Definition sdp-utils.h:202
janus_sdp_attribute::destroyed
volatile gint destroyed
Atomic flag to check if this instance has been destroyed.
Definition sdp-utils.h:206
janus_sdp_attribute::name
char * name
Attribute name.
Definition sdp-utils.h:200
janus_sdp_attribute::ref
janus_refcount ref
Reference counter for this instance.
Definition sdp-utils.h:208
janus_sdp_mline
SDP m-line representation.
Definition sdp-utils.h:131
janus_sdp_mline::c_ipv4
gboolean c_ipv4
Media c= protocol.
Definition sdp-utils.h:147
janus_sdp_mline::port
guint16 port
Media port.
Definition sdp-utils.h:139
janus_sdp_mline::b_value
uint32_t b_value
Media b= value.
Definition sdp-utils.h:153
janus_sdp_mline::type
janus_sdp_mtype type
Media type as a janus_sdp_mtype enumerator.
Definition sdp-utils.h:135
janus_sdp_mline::type_str
char * type_str
Media type (string)
Definition sdp-utils.h:137
janus_sdp_mline::fmts
GList * fmts
List of formats.
Definition sdp-utils.h:143
janus_sdp_mline::index
int index
Media index in the SDP.
Definition sdp-utils.h:133
janus_sdp_mline::ref
janus_refcount ref
Reference counter for this instance.
Definition sdp-utils.h:161
janus_sdp_mline::destroyed
volatile gint destroyed
Atomic flag to check if this instance has been destroyed.
Definition sdp-utils.h:159
janus_sdp_mline::b_name
char * b_name
Media b= type.
Definition sdp-utils.h:151
janus_sdp_mline::ptypes
GList * ptypes
List of payload types.
Definition sdp-utils.h:145
janus_sdp_mline::proto
char * proto
Media protocol.
Definition sdp-utils.h:141
janus_sdp_mline::c_addr
char * c_addr
Media c= address.
Definition sdp-utils.h:149
janus_sdp_mline::direction
janus_sdp_mdirection direction
Media direction.
Definition sdp-utils.h:155
janus_sdp_mline::attributes
GList * attributes
List of m-line attributes.
Definition sdp-utils.h:157
janus_sdp
Janus SDP internal object representation.
Definition sdp-utils.h:26
janus_sdp::o_ipv4
gboolean o_ipv4
o= protocol
Definition sdp-utils.h:36
janus_sdp::o_sessid
guint64 o_sessid
o= session ID
Definition sdp-utils.h:32
janus_sdp::o_name
char * o_name
o= name
Definition sdp-utils.h:30
janus_sdp::t_start
guint64 t_start
t= start
Definition sdp-utils.h:42
janus_sdp::destroyed
volatile gint destroyed
Atomic flag to check if this instance has been destroyed.
Definition sdp-utils.h:54
janus_sdp::t_stop
guint64 t_stop
t= stop
Definition sdp-utils.h:44
janus_sdp::c_addr
char * c_addr
c= address (not rendered for WebRTC usage)
Definition sdp-utils.h:48
janus_sdp::ref
janus_refcount ref
Reference counter for this instance.
Definition sdp-utils.h:56
janus_sdp::version
int version
v=
Definition sdp-utils.h:28
janus_sdp::c_ipv4
gboolean c_ipv4
c= protocol (not rendered for WebRTC usage)
Definition sdp-utils.h:46
janus_sdp::attributes
GList * attributes
List of global a= attributes.
Definition sdp-utils.h:50
janus_sdp::o_addr
char * o_addr
o= address
Definition sdp-utils.h:38
janus_sdp::m_lines
GList * m_lines
List of m= m-lines.
Definition sdp-utils.h:52
janus_sdp::s_name
char * s_name
s=
Definition sdp-utils.h:40
janus_sdp::o_version
guint64 o_version
o= version
Definition sdp-utils.h:34