annotate src/endp_bind.c @ 32:aa97e77e7de6

implement RTCP Tx
author Mychaela Falconia <falcon@freecalypso.org>
date Mon, 08 Jul 2024 07:17:38 +0000
parents 2032201bd034
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
21
2032201bd034 implement twrtp_endp_bind_ip_port()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
2032201bd034 implement twrtp_endp_bind_ip_port()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 * Here we implement the wrapper function that first obtains a pair of fds
2032201bd034 implement twrtp_endp_bind_ip_port()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 * bound to IP & port for RTP & RTCP, then registers them with twrtp_endp.
2032201bd034 implement twrtp_endp_bind_ip_port()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4 */
2032201bd034 implement twrtp_endp_bind_ip_port()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5
2032201bd034 implement twrtp_endp_bind_ip_port()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 #include <stdint.h>
2032201bd034 implement twrtp_endp_bind_ip_port()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 #include <stdbool.h>
2032201bd034 implement twrtp_endp_bind_ip_port()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 #include <errno.h>
2032201bd034 implement twrtp_endp_bind_ip_port()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9
2032201bd034 implement twrtp_endp_bind_ip_port()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 #include <themwi/rtp/endp.h>
2032201bd034 implement twrtp_endp_bind_ip_port()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 #include <themwi/rtp/fdpair.h>
2032201bd034 implement twrtp_endp_bind_ip_port()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12
2032201bd034 implement twrtp_endp_bind_ip_port()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 int twrtp_endp_bind_ip_port(struct twrtp_endp *endp, const char *ip,
2032201bd034 implement twrtp_endp_bind_ip_port()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 uint16_t port)
2032201bd034 implement twrtp_endp_bind_ip_port()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 {
2032201bd034 implement twrtp_endp_bind_ip_port()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 int rc;
2032201bd034 implement twrtp_endp_bind_ip_port()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17
2032201bd034 implement twrtp_endp_bind_ip_port()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 if (endp->register_done)
2032201bd034 implement twrtp_endp_bind_ip_port()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 return -EBUSY;
2032201bd034 implement twrtp_endp_bind_ip_port()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20
2032201bd034 implement twrtp_endp_bind_ip_port()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 rc = twrtp_bind_fdpair(ip, port, &endp->rtp_fd, &endp->rtcp_fd);
2032201bd034 implement twrtp_endp_bind_ip_port()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 if (rc < 0)
2032201bd034 implement twrtp_endp_bind_ip_port()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 return rc;
2032201bd034 implement twrtp_endp_bind_ip_port()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24
2032201bd034 implement twrtp_endp_bind_ip_port()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 return twrtp_endp_register_fds(endp);
2032201bd034 implement twrtp_endp_bind_ip_port()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 }