FreeCalypso > hg > themwi-rtp-lib
comparison src/endp_register.c @ 20:695fdb670d30
implement twrtp_endp_register_fds()
| author | Mychaela Falconia <falcon@freecalypso.org> |
|---|---|
| date | Sun, 07 Jul 2024 04:06:16 +0000 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 19:b8cb5146e5b4 | 20:695fdb670d30 |
|---|---|
| 1 /* | |
| 2 * Here we implement the step of fd registration in twrtp_endp. | |
| 3 */ | |
| 4 | |
| 5 #include <stdint.h> | |
| 6 #include <stdbool.h> | |
| 7 #include <unistd.h> | |
| 8 | |
| 9 #include <osmocom/core/osmo_io.h> | |
| 10 #include <osmocom/core/utils.h> | |
| 11 | |
| 12 #include <themwi/rtp/endp.h> | |
| 13 | |
| 14 int twrtp_endp_register_fds(struct twrtp_endp *endp) | |
| 15 { | |
| 16 int rc; | |
| 17 | |
| 18 if (endp->register_done) | |
| 19 return 0; | |
| 20 | |
| 21 rc = osmo_iofd_register(endp->iofd_rtp, endp->rtp_fd); | |
| 22 if (rc < 0) { | |
| 23 close(endp->rtp_fd); | |
| 24 close(endp->rtcp_fd); | |
| 25 return rc; | |
| 26 } | |
| 27 | |
| 28 rc = osmo_iofd_register(endp->iofd_rtcp, endp->rtcp_fd); | |
| 29 if (rc < 0) { | |
| 30 osmo_iofd_close(endp->iofd_rtp); | |
| 31 close(endp->rtcp_fd); | |
| 32 return rc; | |
| 33 } | |
| 34 | |
| 35 endp->register_done = true; | |
| 36 return 0; | |
| 37 } |
