view 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
line wrap: on
line source

/*
 * Here we implement the step of fd registration in twrtp_endp.
 */

#include <stdint.h>
#include <stdbool.h>
#include <unistd.h>

#include <osmocom/core/osmo_io.h>
#include <osmocom/core/utils.h>

#include <themwi/rtp/endp.h>

int twrtp_endp_register_fds(struct twrtp_endp *endp)
{
	int rc;

	if (endp->register_done)
		return 0;

	rc = osmo_iofd_register(endp->iofd_rtp, endp->rtp_fd);
	if (rc < 0) {
		close(endp->rtp_fd);
		close(endp->rtcp_fd);
		return rc;
	}

	rc = osmo_iofd_register(endp->iofd_rtcp, endp->rtcp_fd);
	if (rc < 0) {
		osmo_iofd_close(endp->iofd_rtp);
		close(endp->rtcp_fd);
		return rc;
	}

	endp->register_done = true;
	return 0;
}