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