FreeCalypso > hg > themwi-rtp-lib
comparison 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 |
comparison
equal
deleted
inserted
replaced
18:ec50018cc4ea | 19:b8cb5146e5b4 |
---|---|
1 /* | |
2 * Create and destroy functions for twrtp_endp. | |
3 */ | |
4 | |
5 #include <stdint.h> | |
6 #include <stdbool.h> | |
7 #include <string.h> | |
8 | |
9 #include <osmocom/core/talloc.h> | |
10 #include <osmocom/core/osmo_io.h> | |
11 #include <osmocom/core/utils.h> | |
12 | |
13 #include <themwi/rtp/endp.h> | |
14 #include <themwi/rtp/twjit.h> | |
15 #include "endp_internal.h" | |
16 | |
17 struct twrtp_endp *twrtp_endp_create(void *ctx, | |
18 struct twrtp_jibuf_config *config) | |
19 { | |
20 struct twrtp_endp *endp; | |
21 | |
22 endp = talloc_zero(ctx, struct twrtp_endp); | |
23 if (!endp) | |
24 return NULL; | |
25 | |
26 endp->iofd_rtp = osmo_iofd_setup(endp, -1, NULL, | |
27 OSMO_IO_FD_MODE_RECVFROM_SENDTO, | |
28 &_twrtp_endp_iops_rtp, endp); | |
29 if (!endp->iofd_rtp) { | |
30 talloc_free(endp); | |
31 return NULL; | |
32 } | |
33 | |
34 endp->iofd_rtcp = osmo_iofd_setup(endp, -1, NULL, | |
35 OSMO_IO_FD_MODE_RECVFROM_SENDTO, | |
36 &_twrtp_endp_iops_rtcp, endp); | |
37 if (!endp->iofd_rtcp) { | |
38 osmo_iofd_free(endp->iofd_rtp); | |
39 talloc_free(endp); | |
40 return NULL; | |
41 } | |
42 | |
43 endp->twjit = twrtp_jibuf_create(endp, config); | |
44 if (!endp->twjit) { | |
45 osmo_iofd_free(endp->iofd_rtp); | |
46 osmo_iofd_free(endp->iofd_rtcp); | |
47 talloc_free(endp); | |
48 return NULL; | |
49 } | |
50 | |
51 return endp; | |
52 } | |
53 | |
54 void twrtp_endp_destroy(struct twrtp_endp *endp) | |
55 { | |
56 osmo_iofd_free(endp->iofd_rtp); | |
57 osmo_iofd_free(endp->iofd_rtcp); | |
58 twrtp_jibuf_destroy(endp->twjit); | |
59 talloc_free(endp); | |
60 } |