FreeCalypso > hg > themwi-rtp-lib
changeset 20:695fdb670d30
implement twrtp_endp_register_fds()
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sun, 07 Jul 2024 04:06:16 +0000 |
parents | b8cb5146e5b4 |
children | 2032201bd034 |
files | include/endp.h src/Makefile src/endp_register.c |
diffstat | 3 files changed, 41 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/include/endp.h Sun Jul 07 02:14:01 2024 +0000 +++ b/include/endp.h Sun Jul 07 04:06:16 2024 +0000 @@ -56,5 +56,6 @@ struct twrtp_endp *twrtp_endp_create(void *ctx, struct twrtp_jibuf_config *config); +void twrtp_endp_destroy(struct twrtp_endp *endp); -void twrtp_endp_destroy(struct twrtp_endp *endp); +int twrtp_endp_register_fds(struct twrtp_endp *endp);
--- a/src/Makefile Sun Jul 07 02:14:01 2024 +0000 +++ b/src/Makefile Sun Jul 07 04:06:16 2024 +0000 @@ -1,4 +1,5 @@ -OBJS= bind_fdpair.o endp_create.o twjit.o twjit_in.o twjit_out.o twjit_vty.o +OBJS= bind_fdpair.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_register.c Sun Jul 07 04:06:16 2024 +0000 @@ -0,0 +1,37 @@ +/* + * Here we implement the step of fd registration in twrtp_endp. + */ + +#include <stdint.h> +#include <stdbool.h> +#include <unistd.h> + +#include <osmocom/core/osmo_io.h> +#include <osmocom/core/utils.h> + +#include <themwi/rtp/endp.h> + +int twrtp_endp_register_fds(struct twrtp_endp *endp) +{ + int rc; + + if (endp->register_done) + return 0; + + rc = osmo_iofd_register(endp->iofd_rtp, endp->rtp_fd); + if (rc < 0) { + close(endp->rtp_fd); + close(endp->rtcp_fd); + return rc; + } + + rc = osmo_iofd_register(endp->iofd_rtcp, endp->rtcp_fd); + if (rc < 0) { + osmo_iofd_close(endp->iofd_rtp); + close(endp->rtcp_fd); + return rc; + } + + endp->register_done = true; + return 0; +}