annotate src/endp_create.c @ 19:b8cb5146e5b4

endp: beginning
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 07 Jul 2024 02:14:01 +0000
parents
children 84d427017d2f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
19
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 * Create and destroy functions for twrtp_endp.
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 */
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5 #include <stdint.h>
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 #include <stdbool.h>
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 #include <string.h>
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 #include <osmocom/core/talloc.h>
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 #include <osmocom/core/osmo_io.h>
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 #include <osmocom/core/utils.h>
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 #include <themwi/rtp/endp.h>
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 #include <themwi/rtp/twjit.h>
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 #include "endp_internal.h"
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 struct twrtp_endp *twrtp_endp_create(void *ctx,
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 struct twrtp_jibuf_config *config)
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 {
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 struct twrtp_endp *endp;
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 endp = talloc_zero(ctx, struct twrtp_endp);
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 if (!endp)
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 return NULL;
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 endp->iofd_rtp = osmo_iofd_setup(endp, -1, NULL,
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 OSMO_IO_FD_MODE_RECVFROM_SENDTO,
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 &_twrtp_endp_iops_rtp, endp);
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 if (!endp->iofd_rtp) {
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 talloc_free(endp);
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 return NULL;
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 }
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 endp->iofd_rtcp = osmo_iofd_setup(endp, -1, NULL,
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 OSMO_IO_FD_MODE_RECVFROM_SENDTO,
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36 &_twrtp_endp_iops_rtcp, endp);
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37 if (!endp->iofd_rtcp) {
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38 osmo_iofd_free(endp->iofd_rtp);
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39 talloc_free(endp);
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40 return NULL;
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
41 }
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
42
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
43 endp->twjit = twrtp_jibuf_create(endp, config);
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
44 if (!endp->twjit) {
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
45 osmo_iofd_free(endp->iofd_rtp);
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
46 osmo_iofd_free(endp->iofd_rtcp);
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
47 talloc_free(endp);
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
48 return NULL;
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
49 }
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
50
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
51 return endp;
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
52 }
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
53
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
54 void twrtp_endp_destroy(struct twrtp_endp *endp)
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
55 {
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
56 osmo_iofd_free(endp->iofd_rtp);
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
57 osmo_iofd_free(endp->iofd_rtcp);
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
58 twrtp_jibuf_destroy(endp->twjit);
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
59 talloc_free(endp);
b8cb5146e5b4 endp: beginning
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
60 }