# HG changeset patch # User Mychaela Falconia # Date 1720325176 0 # Node ID 695fdb670d3051ccbbb1271ea0e6b5b46a961cde # Parent b8cb5146e5b4aebb5093ef95c9df59b38cded95f implement twrtp_endp_register_fds() diff -r b8cb5146e5b4 -r 695fdb670d30 include/endp.h --- 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); diff -r b8cb5146e5b4 -r 695fdb670d30 src/Makefile --- 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 diff -r b8cb5146e5b4 -r 695fdb670d30 src/endp_register.c --- /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 +#include +#include + +#include +#include + +#include + +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; +}