Skip to content

Commit

Permalink
rtp: Add rtp_open which creates an RTP object only for sending.
Browse files Browse the repository at this point in the history
For (multicast) RTP transmission feature we need a function that simply creates
an rtp_open object only for sending RTP packets to one specific IP and port
number. Also there is no need for RTCP session for now.
  • Loading branch information
cspiel1 authored and sreimers committed Feb 27, 2021
1 parent 1cfda99 commit 31e46ce
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
1 change: 1 addition & 0 deletions include/re_rtp.h
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ int rtp_alloc(struct rtp_sock **rsp);
int rtp_listen(struct rtp_sock **rsp, int proto, const struct sa *ip,
uint16_t min_port, uint16_t max_port, bool enable_rtcp,
rtp_recv_h *recvh, rtcp_recv_h *rtcph, void *arg);
int rtp_open(struct rtp_sock **rsp, int af);
int rtp_hdr_encode(struct mbuf *mb, const struct rtp_header *hdr);
int rtp_hdr_decode(struct rtp_header *hdr, struct mbuf *mb);
int rtp_encode(struct rtp_sock *rs, bool ext, bool marker, uint8_t pt,
Expand Down
33 changes: 33 additions & 0 deletions src/rtp/rtp.c
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,39 @@ int rtp_listen(struct rtp_sock **rsp, int proto, const struct sa *ip,
}


/**
* Open RTP Socket without bind.
*
* @param rsp Pointer to returned RTP socket
* @param af Address family AF_INET or AF_INET6
*
* @return 0 for success, otherwise errorcode
*/
int rtp_open(struct rtp_sock **rsp, int af)
{
struct rtp_sock *rs;
struct udp_sock *us_rtp;
int err;

err = rtp_alloc(&rs);
if (err)
return err;

rs->proto = IPPROTO_UDP;

us_rtp = NULL;
err = udp_open(&us_rtp, af);
rs->sock_rtp = us_rtp;

if (err)
mem_deref(rs);
else
*rsp = rs;

return err;
}


/**
* Encode a new RTP header into the beginning of the buffer
*
Expand Down

0 comments on commit 31e46ce

Please sign in to comment.