FreeCalypso > hg > themwi-rtp-lib
changeset 21:2032201bd034
implement twrtp_endp_bind_ip_port()
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sun, 07 Jul 2024 04:17:18 +0000 |
parents | 695fdb670d30 |
children | 587437b62ed5 |
files | include/endp.h src/Makefile src/endp_bind.c |
diffstat | 3 files changed, 30 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/include/endp.h Sun Jul 07 04:06:16 2024 +0000 +++ b/include/endp.h Sun Jul 07 04:17:18 2024 +0000 @@ -59,3 +59,5 @@ void twrtp_endp_destroy(struct twrtp_endp *endp); int twrtp_endp_register_fds(struct twrtp_endp *endp); +int twrtp_endp_bind_ip_port(struct twrtp_endp *endp, const char *ip, + uint16_t port);
--- a/src/Makefile Sun Jul 07 04:06:16 2024 +0000 +++ b/src/Makefile Sun Jul 07 04:17:18 2024 +0000 @@ -1,5 +1,5 @@ -OBJS= bind_fdpair.o endp_create.o endp_register.o twjit.o twjit_in.o \ - twjit_out.o twjit_vty.o +OBJS= bind_fdpair.o endp_bind.o endp_create.o endp_register.o twjit.o \ + twjit_in.o twjit_out.o twjit_vty.o LIB= libtwrtp.a include ../config.defs
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/endp_bind.c Sun Jul 07 04:17:18 2024 +0000 @@ -0,0 +1,26 @@ +/* + * Here we implement the wrapper function that first obtains a pair of fds + * bound to IP & port for RTP & RTCP, then registers them with twrtp_endp. + */ + +#include <stdint.h> +#include <stdbool.h> +#include <errno.h> + +#include <themwi/rtp/endp.h> +#include <themwi/rtp/fdpair.h> + +int twrtp_endp_bind_ip_port(struct twrtp_endp *endp, const char *ip, + uint16_t port) +{ + int rc; + + if (endp->register_done) + return -EBUSY; + + rc = twrtp_bind_fdpair(ip, port, &endp->rtp_fd, &endp->rtcp_fd); + if (rc < 0) + return rc; + + return twrtp_endp_register_fds(endp); +}