FreeCalypso > hg > themwi-rtp-lib
annotate src/endp_bind.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 | 2032201bd034 |
children |
rev | line source |
---|---|
21
2032201bd034
implement twrtp_endp_bind_ip_port()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
2032201bd034
implement twrtp_endp_bind_ip_port()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 * Here we implement the wrapper function that first obtains a pair of fds |
2032201bd034
implement twrtp_endp_bind_ip_port()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 * bound to IP & port for RTP & RTCP, then registers them with twrtp_endp. |
2032201bd034
implement twrtp_endp_bind_ip_port()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 */ |
2032201bd034
implement twrtp_endp_bind_ip_port()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 |
2032201bd034
implement twrtp_endp_bind_ip_port()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 #include <stdint.h> |
2032201bd034
implement twrtp_endp_bind_ip_port()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 #include <stdbool.h> |
2032201bd034
implement twrtp_endp_bind_ip_port()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 #include <errno.h> |
2032201bd034
implement twrtp_endp_bind_ip_port()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 |
2032201bd034
implement twrtp_endp_bind_ip_port()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 #include <themwi/rtp/endp.h> |
2032201bd034
implement twrtp_endp_bind_ip_port()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 #include <themwi/rtp/fdpair.h> |
2032201bd034
implement twrtp_endp_bind_ip_port()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 |
2032201bd034
implement twrtp_endp_bind_ip_port()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 int twrtp_endp_bind_ip_port(struct twrtp_endp *endp, const char *ip, |
2032201bd034
implement twrtp_endp_bind_ip_port()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 uint16_t port) |
2032201bd034
implement twrtp_endp_bind_ip_port()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 { |
2032201bd034
implement twrtp_endp_bind_ip_port()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 int rc; |
2032201bd034
implement twrtp_endp_bind_ip_port()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 |
2032201bd034
implement twrtp_endp_bind_ip_port()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 if (endp->register_done) |
2032201bd034
implement twrtp_endp_bind_ip_port()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 return -EBUSY; |
2032201bd034
implement twrtp_endp_bind_ip_port()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 |
2032201bd034
implement twrtp_endp_bind_ip_port()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 rc = twrtp_bind_fdpair(ip, port, &endp->rtp_fd, &endp->rtcp_fd); |
2032201bd034
implement twrtp_endp_bind_ip_port()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 if (rc < 0) |
2032201bd034
implement twrtp_endp_bind_ip_port()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 return rc; |
2032201bd034
implement twrtp_endp_bind_ip_port()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 |
2032201bd034
implement twrtp_endp_bind_ip_port()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 return twrtp_endp_register_fds(endp); |
2032201bd034
implement twrtp_endp_bind_ip_port()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 } |