Skip to content

Commit

Permalink
sdp: a utility function for decoding SDP direction
Browse files Browse the repository at this point in the history
  • Loading branch information
cspiel1 authored and sreimers committed Mar 25, 2022
1 parent a8f0ef6 commit 8caba18
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
2 changes: 2 additions & 0 deletions include/re_sdp.h
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,8 @@ extern const char sdp_proto_rtpsavp[];

/* utility functions */

enum sdp_dir sdp_dir_decode(const struct pl *pl);

/** RTP Header Extensions, as defined in RFC 5285 */
struct sdp_extmap {
struct pl name;
Expand Down
25 changes: 25 additions & 0 deletions src/sdp/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,31 @@
#include <re_sdp.h>


/**
* Decode an SDP direction
*
* @param pl SDP direction as string
*
* @return sdp_dir SDP direction, SDP_SENDRECV as fallback
*/
enum sdp_dir sdp_dir_decode(const struct pl *pl)
{
if (!pl_strcmp(pl, "off")) {
return SDP_INACTIVE;
}
else if (!pl_strcmp(pl, "inactive")) {
return SDP_INACTIVE;
}
else if (!pl_strcmp(pl, "sendonly")) {
return SDP_SENDONLY;
}
else if (!pl_strcmp(pl, "recvonly")) {
return SDP_RECVONLY;
}

return SDP_SENDRECV;
}

/**
* Decode RTP Header Extension SDP attribute value
*
Expand Down

0 comments on commit 8caba18

Please sign in to comment.