annotate src/endp_register.c @ 42:334d883b96ba

twrtp_jibuf_create: make config argument const While this config structure is not a constant in the mathematical sense of the term (it is expected that vty config changes may happen while twjit instance is alive), twjit functions never write to it, only read, hence it is 'const' in the not-quite-mathematical C-standard sense.
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 20 Dec 2024 22:47:20 +0000
parents 695fdb670d30
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
20
695fdb670d30 implement twrtp_endp_register_fds()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
695fdb670d30 implement twrtp_endp_register_fds()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 * Here we implement the step of fd registration in twrtp_endp.
695fdb670d30 implement twrtp_endp_register_fds()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 */
695fdb670d30 implement twrtp_endp_register_fds()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4
695fdb670d30 implement twrtp_endp_register_fds()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5 #include <stdint.h>
695fdb670d30 implement twrtp_endp_register_fds()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 #include <stdbool.h>
695fdb670d30 implement twrtp_endp_register_fds()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 #include <unistd.h>
695fdb670d30 implement twrtp_endp_register_fds()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8
695fdb670d30 implement twrtp_endp_register_fds()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 #include <osmocom/core/osmo_io.h>
695fdb670d30 implement twrtp_endp_register_fds()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 #include <osmocom/core/utils.h>
695fdb670d30 implement twrtp_endp_register_fds()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11
695fdb670d30 implement twrtp_endp_register_fds()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 #include <themwi/rtp/endp.h>
695fdb670d30 implement twrtp_endp_register_fds()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13
695fdb670d30 implement twrtp_endp_register_fds()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 int twrtp_endp_register_fds(struct twrtp_endp *endp)
695fdb670d30 implement twrtp_endp_register_fds()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 {
695fdb670d30 implement twrtp_endp_register_fds()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 int rc;
695fdb670d30 implement twrtp_endp_register_fds()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17
695fdb670d30 implement twrtp_endp_register_fds()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 if (endp->register_done)
695fdb670d30 implement twrtp_endp_register_fds()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 return 0;
695fdb670d30 implement twrtp_endp_register_fds()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20
695fdb670d30 implement twrtp_endp_register_fds()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 rc = osmo_iofd_register(endp->iofd_rtp, endp->rtp_fd);
695fdb670d30 implement twrtp_endp_register_fds()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 if (rc < 0) {
695fdb670d30 implement twrtp_endp_register_fds()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 close(endp->rtp_fd);
695fdb670d30 implement twrtp_endp_register_fds()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 close(endp->rtcp_fd);
695fdb670d30 implement twrtp_endp_register_fds()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 return rc;
695fdb670d30 implement twrtp_endp_register_fds()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 }
695fdb670d30 implement twrtp_endp_register_fds()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27
695fdb670d30 implement twrtp_endp_register_fds()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 rc = osmo_iofd_register(endp->iofd_rtcp, endp->rtcp_fd);
695fdb670d30 implement twrtp_endp_register_fds()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 if (rc < 0) {
695fdb670d30 implement twrtp_endp_register_fds()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 osmo_iofd_close(endp->iofd_rtp);
695fdb670d30 implement twrtp_endp_register_fds()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 close(endp->rtcp_fd);
695fdb670d30 implement twrtp_endp_register_fds()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 return rc;
695fdb670d30 implement twrtp_endp_register_fds()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 }
695fdb670d30 implement twrtp_endp_register_fds()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34
695fdb670d30 implement twrtp_endp_register_fds()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 endp->register_done = true;
695fdb670d30 implement twrtp_endp_register_fds()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36 return 0;
695fdb670d30 implement twrtp_endp_register_fds()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37 }