Loading...
Searching...
No Matches
sdp-utils.h File Reference
Core

SDP utilities (headers). More...

`#include <inttypes.h>`
`#include <glib.h>`
`#include "rtp.h"`
`#include "refcount.h"`
Include dependency graph for sdp-utils.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

## Data Structures

struct | janus_sdp
| Janus SDP internal object representation. More...
struct | janus_sdp_mline
| SDP m-line representation. More...
struct | janus_sdp_attribute
| SDP a= attribute representation. More...

## Typedefs

typedef struct janus_sdp | janus_sdp
| Janus SDP internal object representation.
typedef enum janus_sdp_mtype | janus_sdp_mtype
| Helper enumeration to quickly identify m-line media types.
typedef enum janus_sdp_mdirection | janus_sdp_mdirection
| Helper enumeration to quickly identify m-line directions.
typedef struct janus_sdp_mline | janus_sdp_mline
| SDP m-line representation.
typedef struct janus_sdp_attribute | janus_sdp_attribute
| SDP a= attribute representation.
typedef enum janus_sdp_oa_type | janus_sdp_oa_type

## Enumerations

enum | janus_sdp_mtype { JANUS_SDP_AUDIO , JANUS_SDP_VIDEO , JANUS_SDP_APPLICATION , JANUS_SDP_OTHER }
| Helper enumeration to quickly identify m-line media types. More...
enum | janus_sdp_mdirection { JANUS_SDP_DEFAULT , JANUS_SDP_SENDRECV , JANUS_SDP_SENDONLY , JANUS_SDP_RECVONLY , JANUS_SDP_INACTIVE , JANUS_SDP_INVALID }
| Helper enumeration to quickly identify m-line directions. More...

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
}

## Functions

janus_sdp_mtype | janus_sdp_parse_mtype (const char *type)
| Helper method to get a janus_sdp_mtype from a string.
const char * | janus_sdp_mtype_str (janus_sdp_mtype type)
| Helper method to get the string associated to a janus_sdp_mtype value.
janus_sdp_mdirection | janus_sdp_parse_mdirection (const char *direction)
| Helper method to get a janus_sdp_mdirection from a string.
const char * | janus_sdp_mdirection_str (janus_sdp_mdirection direction)
| Helper method to get the string associated to a janus_sdp_mdirection value.
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.
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 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.
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.
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.
void | janus_sdp_mline_destroy (janus_sdp_mline *mline)
| Helper method to free a janus_sdp_mline instance.
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.
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.
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.
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_attribute void | janus_sdp_attribute_destroy (janus_sdp_attribute *attr)
| Helper method to free a janus_sdp_attribute instance.
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.
janus_sdp * | janus_sdp_parse (const char *sdp, char *error, size_t errlen)
| Method to parse an SDP string to a janus_sdp object.
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.
char * | janus_sdp_write (janus_sdp *sdp)
| Method to serialize a janus_sdp object to an SDP string.
janus_sdp * | janus_sdp_new (const char *name, const char *address)
| Method to quickly generate a janus_sdp instance from a few selected fields.
void | janus_sdp_destroy (janus_sdp *sdp)
| Method to destroy a Janus SDP object.
const char * | janus_sdp_oa_type_str (janus_sdp_oa_type type)
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.g., in terms of media to offer, directions, etc.). Variable arguments are in the form of a sequence of name-value terminated by a JANUS_SDP_OA_DONE, e.g.:
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_offer supports. This is useful whenever you need to create a new offer, but don't know in advance how many m-lines you'll need, or it would be hard to do programmatically in a single call to janus_sdp_generate_offer. The first argument MUST be JANUS_SDP_OA_MLINE, specifying the type of the media.
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 the individual m-lines: it will just create an empty response, create the corresponding m-lines, but leave them all "rejected". To answer each m-line you'll have to iterate on the offer m-lines and call janus_sdp_generate_answer_mline instead, e.g.:
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_generate_offer_mline supports. The first argument MUST be JANUS_SDP_OA_MLINE, specifying the type of the media, e.g.:
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.
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 codec profile as a hint as well.
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.
const char * | janus_sdp_get_rtpmap_codec (const char *rtpmap)
| Helper to get the codec name associated to a specific rtpmap.
const char * | janus_sdp_get_codec_rtpmap (const char *codec)
| Helper to get the rtpmap associated to a specific codec.
const char * | janus_sdp_get_fmtp (janus_sdp *sdp, int index, int pt)
| Helper to get the fmtp associated to a specific payload type.
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.
int | janus_sdp_get_opusred_pt (janus_sdp *sdp, int index)
| Helper to get the opus/red payload type from an SDP, if present.

## Detailed Description

SDP utilities (headers).

Author
  Lorenzo Miniero loren.nosp@m.zo@m.nosp@m.eetec.nosp@m.ho.c.nosp@m.om

Copyright
  GNU General Public License v3

Implementation of an internal SDP representation. Allows to parse SDP strings to an internal janus_sdp object, the manipulation of such object by playing with its properties, and a serialization to an SDP string that can be passed around. Since they don't have any core dependencies, these utilities can be used by plugins as well.

Core

## Typedef Documentation

## janus_sdp

typedef struct janus_sdp janus_sdp

Janus SDP internal object representation.

## janus_sdp_attribute

typedef struct janus_sdp_attribute janus_sdp_attribute

SDP a= attribute representation.

## janus_sdp_mdirection

typedef enum janus_sdp_mdirection janus_sdp_mdirection

Helper enumeration to quickly identify m-line directions.

## janus_sdp_mline

typedef struct janus_sdp_mline janus_sdp_mline

SDP m-line representation.

## janus_sdp_mtype

typedef enum janus_sdp_mtype janus_sdp_mtype

Helper enumeration to quickly identify m-line media types.

## janus_sdp_oa_type

typedef enum janus_sdp_oa_type janus_sdp_oa_type

## Enumeration Type Documentation

## janus_sdp_mdirection

enum janus_sdp_mdirection

Helper enumeration to quickly identify m-line directions.

Enumerator
JANUS_SDP_DEFAULT | default=sendrecv
JANUS_SDP_SENDRECV | sendrecv
JANUS_SDP_SENDONLY | sendonly
JANUS_SDP_RECVONLY | recvonly
JANUS_SDP_INACTIVE | inactive
JANUS_SDP_INVALID | invalid direction (when parsing)

## janus_sdp_mtype

enum janus_sdp_mtype

Helper enumeration to quickly identify m-line media types.

Enumerator
JANUS_SDP_AUDIO | m=audio
JANUS_SDP_VIDEO | m=video
JANUS_SDP_APPLICATION | m=application
JANUS_SDP_OTHER | m=whatever (we don't care, unsupported)

## janus_sdp_oa_type

enum janus_sdp_oa_type

Enumerator
JANUS_SDP_OA_MLINE | Add a new m-line of the specific kind (used as a separator for audio, video and data details passed to janus_sdp_generate_offer).
JANUS_SDP_OA_ENABLED | Whether we should enable a specific m-line when offering/answering (depends on what follows, true by default).
JANUS_SDP_OA_DIRECTION | When generating an offer or answer automatically, use this direction for media (depends on value that follows, sendrecv by default).
JANUS_SDP_OA_MID | When generating an offer automatically, use this mid (depends on value that follows, needs to be a string).
JANUS_SDP_OA_MSID | When generating an offer or answer automatically, use this msid (depends on the two strings that follow, stream and track ID respectively).
JANUS_SDP_OA_CODEC | When generating an offer or answer automatically, use this codec (depends on value that follows, opus/vp8 by default).
JANUS_SDP_OA_EXTENSION | When generating an offer (this is ignored for answers), negotiate this extension: needs two arguments, extmap value and extension ID (can be used multiple times).

JANUS_SDP_OA_EXTENSIONS

When generating an offer (this is ignored for answers), negotiate these extensions: needs a hashtable with the mappings to a specific extmap.

Note
  This is only used internally, and will be ignored if provided; in plugins, you should stick to JANUS_SDP_OA_EXTENSION

JANUS_SDP_OA_ACCEPT_EXTMAP | When generating an answer (this is ignored for offers), accept this extension (by default, we reject them all; can be used multiple times).
JANUS_SDP_OA_PT | When generating an offer (this is ignored for answers), use this payload type (depends on value that follows).

JANUS_SDP_OA_FMTP

When generating an offer or answer automatically, add this custom fmtp string.

Note
  When dealing with video, this property is ignored if JANUS_SDP_OA_VP9_PROFILE or JANUS_SDP_OA_H264_PROFILE is used on a compliant codec.

JANUS_SDP_OA_AUDIO_DTMF | When generating an offer or answer automatically, do or do not negotiate telephone events (FIXME telephone-event/8000 only, true by default).
JANUS_SDP_OA_OPUSRED_PT | When generating an offer (this is ignored for answers), use this payload type for RED/Opus (depends on value that follows).
JANUS_SDP_OA_ACCEPT_OPUSRED | When generating an answer (this is ignored for offers), accept opus/red if offered.
JANUS_SDP_OA_VP9_PROFILE | When generating an offer or answer automatically, use this profile for VP9 (depends on value that follows).
JANUS_SDP_OA_H264_PROFILE | When generating an offer or answer automatically, use this profile for H.264 (depends on value that follows).
JANUS_SDP_OA_VIDEO_RTCPFB_DEFAULTS | When generating an offer or answer automatically, do or do not add the rtcpfb attributes we typically negotiate (fir, nack, pli, remb; true by defaukt).
JANUS_SDP_OA_DATA_LEGACY | When generating an offer (this is ignored for answers), use the old "DTLS/SCTP" instead of the new "UDP/DTLS/SCTP (depends on what follows, false by default).
JANUS_SDP_OA_DONE | MUST be used as the last argument in janus_sdp_generate_offer, janus_sdp_generate_offer_mline and janus_sdp_generate_answer.

## Function Documentation

## 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.

Parameters

  [in] | mline | The m-line to add the attribute to
  [in] | attr | The attribute to add

Returns
  0 in case of success, -1 otherwise

## janus_sdp_attribute_create()

janus_sdp_attribute * janus_sdp_attribute_create | ( | const char * | name,
|  | const char * | value,
|  |  | ... )

Helper method to quickly create a janus_sdp_attribute instance.

Parameters

  [in] | name | Name of the attribute
  [in] | value | Value of the attribute, as a printf compliant string (variable arguments)

Returns
  A pointer to a valid janus_sdp_attribute instance, if successfull, NULL otherwise

## 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.

Note
  This method does not remove the attribute from the global or m-line attributes, that's up to the caller

Parameters

  [in] | attr | The janus_sdp_attribute instance to free

## janus_sdp_destroy()

void janus_sdp_destroy | ( | janus_sdp * | sdp | ) |

Method to destroy a Janus SDP object.

Parameters

  [in] | sdp | The Janus SDP object to free

## 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 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.

Note
  The codec argument is input/output, and it will be set to a static value in janus_preferred_audio_codecs or janus_preferred_video_codecs, so don't free it.

Parameters

  [in] | sdp | The Janus SDP object to parse
  [in] | type | Whether we're looking at an audio or video codec
  [in] | index | The m-line to refer to (use -1 for the first m-line that matches)
  [out] | codec | The audio or video codec that was found

## 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, (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.

Note
  The codec argument is input/output, and it will be set to a static value in janus_preferred_audio_codecs or janus_preferred_video_codecs, so don't free it.

Parameters

  [in] | sdp | The Janus SDP object to parse
  [in] | type | Whether we're looking at an audio or video codec
  [in] | index | The m-line to refer to (use -1 for the first m-line that matches)
  [out] | codec | The audio or video codec that was found

## 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 the individual m-lines: it will just create an empty response, create the corresponding m-lines, but leave them all "rejected". To answer each m-line you'll have to iterate on the offer m-lines and call janus_sdp_generate_answer_mline instead, e.g.:

           janus_sdp *answer = janus_sdp_generate_answer(offer);
           GList *temp = offer->m_lines;
           while(temp) {
            janus_sdp_mline *m = (janus_sdp_mline *)temp->data;
            janus_sdp_generate_answer_mline(offer, answer, m,
                    [..]
                    JANUS_SDP_OA_DONE);
            temp = temp->next;
           }

to only accept the audio stream being offered, but as `recvonly`, use Opus and reject both video and datachannels. Refer to the property names in the header file for a complete list of how you can drive the answer. The default, if not specified, is to accept everything as `sendrecv`.

Parameters

  [in] | offer | The Janus SDP offer to respond to

Returns
  A pointer to a janus_sdp object, if successful, NULL otherwise

## 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_generate_offer_mline supports. The first argument MUST be JANUS_SDP_OA_MLINE, specifying the type of the media, e.g.:

           janus_sdp_generate_answer_mline(offer, answer, offer_mline,
            JANUS_SDP_OA_MLINE, JANUS_SDP_AUDIO,
                    JANUS_SDP_OA_CODEC, "opus",
                    JANUS_SDP_OA_DIRECTION, JANUS_SDP_RECVONLY,
            JANUS_SDP_OA_DONE);

to respond to an offered m-line with recvonly audio and use Opus.

Parameters

  [in] | offer | The Janus SDP offer
  [in] | answer | The Janus SDP answer to add the new m-line to
  [in] | offered | The Janus SDP m-line from the offer to respond to

Returns
  0 if successful, a negative integer othwerwise

## 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.g., in terms of media to offer, directions, etc.). Variable arguments are in the form of a sequence of name-value terminated by a JANUS_SDP_OA_DONE, e.g.:

           janus_sdp *offer = janus_sdp_generate_offer("My session", "127.0.0.1",
            JANUS_SDP_OA_MLINE, JANUS_SDP_AUDIO,
                    JANUS_SDP_OA_PT, 100,
                    JANUS_SDP_OA_DIRECTION, JANUS_SDP_SENDONLY,
                    JANUS_SDP_OA_CODEC, "opus",
            JANUS_SDP_OA_MLINE, JANUS_SDP_VIDEO,
                    JANUS_SDP_OA_PT, 101,
                    JANUS_SDP_OA_DIRECTION, JANUS_SDP_RECVONLY,
                    JANUS_SDP_OA_CODEC, "vp8",

to offer a `sendonly` Opus audio stream being offered with 100 as payload type, and a `recvonly` VP8 video stream with 101 as payload type. Refer to the property names in the header file for a complete list of how you can drive the offer. Other media streams can be added, as long as you prefix/specify them with JANUS_SDP_OA_MLINE as done here. The default, if not specified, is to not offer anything, meaning it will be up to you to add m-lines subsequently.

Parameters

  [in] | name | The session name (if NULL, a default value will be set)
  [in] | address | The IP to set in o= and c= fields (if NULL, a default value will be set)

Returns
  A pointer to a janus_sdp object, if successful, NULL otherwise

## 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_offer supports. This is useful whenever you need to create a new offer, but don't know in advance how many m-lines you'll need, or it would be hard to do programmatically in a single call to janus_sdp_generate_offer. The first argument MUST be JANUS_SDP_OA_MLINE, specifying the type of the media.

Note
  In case case you add audio and don't specify anything else, the default is to use Opus and payload type 111. For video, the default is VP8 and payload type 96. The default media direction is `sendrecv`.

Parameters

  [in] | offer | The Janus SDP offer to add the new m-line to

Returns
  0 if successful, a negative integer othwerwise

## 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.

Parameters

  sdp | The Janus SDP instance to process
  index | The m-line to refer to (use -1 for the first m-line that matches)
  pt | The payload type to find

Returns
  The codec name, if found, or NULL otherwise

## 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.

Note
  This version doesn't involve profiles, which means that in case of multiple payload types associated to the same codec because of different profiles (e.g., VP9 and H.264), this will simply return the first payload type associated with it the codec itself.

Parameters

  sdp | The Janus SDP instance to process
  index | The m-line to refer to (use -1 for the first m-line that matches)
  codec | The codec to find, as a string

Returns
  The payload type, if found, or -1 otherwise

## 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 codec profile as a hint as well.

Note
  The profile will only be used if the codec supports it, and the core is aware of it: right now, this is only VP9 and H.264. If the codec is there but the profile is not found, then no payload type is returned.

Parameters

  sdp | The Janus SDP instance to process
  index | The m-line to refer to (use -1 for the first m-line that matches)
  codec | The codec to find, as a string
  profile | The codec profile to use as a hint, as a string

Returns
  The payload type, if found, or -1 otherwise

## 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.

Parameters

  codec | The codec name, as a string (e.g., "opus")

Returns
  The rtpmap value, if found (e.g., "opus/48000/2"), or NULL otherwise

## 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.

Parameters

  sdp | The Janus SDP instance to process
  index | The m-line to refer to (use -1 for the first m-line that matches)
  pt | The payload type to find

Returns
  The fmtp content, if found, or NULL otherwise

## 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.

Parameters

  sdp | The Janus SDP instance to process
  index | The m-line to refer to (use -1 for the first m-line that matches)

Returns
  The payload type, if found, or -1 otherwise

## 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.

Parameters

  codec | The rtpmap, as a string (e.g., "VP8/90000")

Returns
  The codec name, if found (e.g., "vp8"), or NULL otherwise

## 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.

Note
  The returned profile string is allocated, so must be freed by the caller

Parameters

  codec | The video codec to refer to
  fmtp | The fmtp value to parse

Returns
  The profile content, if found, or NULL otherwise

## 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.

Note
  Don't free the returned value, as it's a constant value

Parameters

  [in] | type | The type of media to match
  [in] | codec | The codec to match

Returns
  The codec, if found, or NULL otherwise

## 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.

Parameters

  [in] | direction | The direction to stringify

Returns
  The direction as a string, if valid, or NULL otherwise

## 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.

Note
  The `type_str` property of the new m-line is created automatically depending on the provided `type` attribute. If `type` is JANUS_SDP_OTHER, though, `type_str` will NOT we allocated, and will be up to the caller.

Parameters

  [in] | type | Type of the media (audio/video/application) as a janus_sdp_mtype
  [in] | port | Port to advertise
  [in] | proto | Profile to advertise
  [in] | direction | Direction of the media as a janus_sdp_direction

Returns
  A pointer to a valid janus_sdp_mline instance, if successfull, NULL otherwise

## janus_sdp_mline_destroy()

void janus_sdp_mline_destroy | ( | janus_sdp_mline * | mline | ) |

Helper method to free a janus_sdp_mline instance.

Note
  This method does not remove the m-line from the janus_sdp instance, that's up to the caller

Parameters

  [in] | mline | The janus_sdp_mline instance to free

## 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.

Note
  This currently returns the first m-line of the specified type it finds: as such, it's mostly here for making things easier for plugins not doing multistream.

Parameters

  [in] | sdp | The Janus SDP object to search
  [in] | type | The type of media to search

Returns
  The janus_sdp_mline instance, if found, or NULL otherwise

## 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.

Parameters

  [in] | sdp | The Janus SDP object to search
  [in] | index | The index of the m-line in the SDP

Returns
  The janus_sdp_mline instance, if found, or NULL otherwise

## 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.

Note
  This currently removes the first m-line of the specified type it finds: as such, it's mostly here for making things easier for plugins not doing multistream.

Parameters

  [in] | sdp | The Janus SDP object to modify
  [in] | type | The type of media to remove

Returns
  0 if successful, a negative integer otherwise

## 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.

Parameters

  [in] | type | The type to stringify

Returns
  The type as a string, if valid, or NULL otherwise

## 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.

Note
  This allocates the `o_addr`, `s_name` and `c_addr` properties: if you want to replace them, don't forget to `g_free` the original pointers first.

Parameters

  [in] | name | The session name (if NULL, a default value will be set)
  [in] | address | The IP to set in o= and c= fields (if NULL, a default value will be set)

Returns
  A pointer to a janus_sdp object, if successful, NULL otherwise

## janus_sdp_oa_type_str()

const char * janus_sdp_oa_type_str | ( | janus_sdp_oa_type | type | ) |

## 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.

Parameters

  [in] | sdp | The SDP string to parse
  [in,out] | error | Buffer to receive a reason for an error, if any
  [in] | errlen | The length of the error buffer

Returns
  A pointer to a janus_sdp object, if successful, NULL otherwise; in case of errors, if provided the error string is filled with a reason

## 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.

Parameters

  [in] | direction | The direction to parse as a string (e.g., "sendrecv")

Returns
  The corresponding janus_sdp_mdirection value

## 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.

Parameters

  [in] | type | The type to parse as a string (e.g., "audio")

Returns
  The corresponding janus_sdp_mtype value

## 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.

Parameters

  [in] | sdp | The janus_sdp object to remove the payload type from
  [in] | index | The m-line to remove the payload type from (use -1 for the first m-line that matches)
  [in] | pt | The payload type to remove

Returns
  0 in case of success, a negative integer otherwise

## janus_sdp_write()

char * janus_sdp_write | ( | janus_sdp * | sdp | ) |

Method to serialize a janus_sdp object to an SDP string.

Parameters

  [in] | sdp | The janus_sdp object to serialize

Returns
  A pointer to a string with the serialized SDP, if successful, NULL otherwise