Updated libs
This commit is contained in:
parent
be5d5e24f8
commit
0d3d1a098f
|
@ -86,6 +86,7 @@ struct debug_cat {
|
|||
{ "router", "\033[1;35m" },
|
||||
{ "stderr", "\033[1;37m" },
|
||||
{ "ss5", "\033[1;34m" },
|
||||
{ "r1", "\033[1;34m" },
|
||||
{ "isdn", "\033[1;35m" },
|
||||
{ "misdn", "\033[0;34m" },
|
||||
{ "dss1", "\033[1;34m" },
|
||||
|
|
|
@ -48,15 +48,16 @@
|
|||
#define DROUTER 41
|
||||
#define DSTDERR 42
|
||||
#define DSS5 43
|
||||
#define DISDN 44
|
||||
#define DMISDN 45
|
||||
#define DDSS1 46
|
||||
#define DSIP 47
|
||||
#define DTEL 48
|
||||
#define DUK0 49
|
||||
#define DPH 50
|
||||
#define DDCF77 51
|
||||
#define DJITTER 52
|
||||
#define DR1 44
|
||||
#define DISDN 45
|
||||
#define DMISDN 46
|
||||
#define DDSS1 47
|
||||
#define DSIP 48
|
||||
#define DTEL 49
|
||||
#define DUK0 50
|
||||
#define DPH 51
|
||||
#define DDCF77 52
|
||||
#define DJITTER 53
|
||||
//NOTE: increment mask array, if 127 is exceeded
|
||||
|
||||
void lock_debug(void);
|
||||
|
|
|
@ -88,13 +88,12 @@ void iir_bandpass_init(iir_filter_t *filter, double frequency, int samplerate, i
|
|||
filter->b2 = (1 - K / Q + K * K) * norm;
|
||||
}
|
||||
|
||||
void iir_notch_init(iir_filter_t *filter, double frequency, int samplerate, int iterations)
|
||||
void iir_notch_init(iir_filter_t *filter, double frequency, int samplerate, int iterations, double Q)
|
||||
{
|
||||
double Fc, Q, K, norm;
|
||||
double Fc, K, norm;
|
||||
|
||||
memset(filter, 0, sizeof(*filter));
|
||||
filter->iter = iterations;
|
||||
Q = pow(sqrt(0.5), 1.0 / (double)iterations); /* 0.7071 @ 1 iteration */
|
||||
Fc = frequency / (double)samplerate;
|
||||
K = tan(PI * Fc);
|
||||
norm = 1 / (1 + K / Q + K * K);
|
||||
|
|
|
@ -10,7 +10,7 @@ typedef struct iir_filter {
|
|||
void iir_lowpass_init(iir_filter_t *filter, double frequency, int samplerate, int iterations);
|
||||
void iir_highpass_init(iir_filter_t *filter, double frequency, int samplerate, int iterations);
|
||||
void iir_bandpass_init(iir_filter_t *filter, double frequency, int samplerate, int iterations);
|
||||
void iir_notch_init(iir_filter_t *filter, double frequency, int samplerate, int iterations);
|
||||
void iir_notch_init(iir_filter_t *filter, double frequency, int samplerate, int iterations, double Q);
|
||||
void iir_process(iir_filter_t *filter, sample_t *samples, int length);
|
||||
void iir_process_baseband(iir_filter_t *filter, float *baseband, int length);
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
#include <stdint.h>
|
||||
|
||||
/* ulaw -> signed 16-bit */
|
||||
static int16_t g711_ulaw_flipped_to_linear[256] =
|
||||
static int16_t g711_ulaw_to_linear[256] =
|
||||
{
|
||||
0x8284, 0x8684, 0x8a84, 0x8e84, 0x9284, 0x9684, 0x9a84, 0x9e84,
|
||||
0xa284, 0xa684, 0xaa84, 0xae84, 0xb284, 0xb684, 0xba84, 0xbe84,
|
||||
|
@ -89,7 +89,7 @@ static int16_t g711_alaw_flipped_to_linear[256] =
|
|||
|
||||
/* Xlaw -> signed 16-bit */
|
||||
static int16_t g711_alaw_to_linear[256];
|
||||
static int16_t g711_ulaw_to_linear[256];
|
||||
static int16_t g711_ulaw_flipped_to_linear[256];
|
||||
|
||||
/* signed 16-bit -> Xlaw */
|
||||
static uint8_t g711_linear_to_alaw_flipped[65536];
|
||||
|
@ -196,7 +196,7 @@ void g711_init(void)
|
|||
+ ((i & 64) >> 5)
|
||||
+ ((i & 128) >> 7);
|
||||
g711_alaw_to_linear[i] = g711_alaw_flipped_to_linear[g711_flip[i]];
|
||||
g711_ulaw_to_linear[i] = g711_ulaw_flipped_to_linear[g711_flip[i]];
|
||||
g711_ulaw_flipped_to_linear[i] = g711_ulaw_to_linear[g711_flip[i]];
|
||||
}
|
||||
|
||||
/* linear to alaw tables */
|
||||
|
@ -214,18 +214,18 @@ void g711_init(void)
|
|||
/* linear to ulaw tables */
|
||||
i = j = 0;
|
||||
while(i < 32768) {
|
||||
if (i - 32768 > g711_ulaw_flipped_to_linear[j])
|
||||
if (i - 32768 > g711_ulaw_to_linear[j])
|
||||
j++;
|
||||
g711_linear_to_ulaw_flipped[(i - 32768) & 0xffff] = j;
|
||||
g711_linear_to_ulaw[(i - 32768) & 0xffff] = g711_flip[j];
|
||||
g711_linear_to_ulaw[(i - 32768) & 0xffff] = j;
|
||||
g711_linear_to_ulaw_flipped[(i - 32768) & 0xffff] = g711_flip[j];
|
||||
i++;
|
||||
}
|
||||
j = 255;
|
||||
while(i < 65536) {
|
||||
if (i - 32768 > g711_alaw_flipped_to_linear[j])
|
||||
if (i - 32768 > g711_ulaw_to_linear[j])
|
||||
j--;
|
||||
g711_linear_to_ulaw_flipped[(i - 32768) & 0xffff] = j;
|
||||
g711_linear_to_ulaw[(i - 32768) & 0xffff] = g711_flip[j];
|
||||
g711_linear_to_ulaw[(i - 32768) & 0xffff] = j;
|
||||
g711_linear_to_ulaw_flipped[(i - 32768) & 0xffff] = g711_flip[j];
|
||||
i++;
|
||||
}
|
||||
|
||||
|
|
|
@ -27,7 +27,9 @@
|
|||
#include "../libtimer/timer.h"
|
||||
#include "../libselect/select.h"
|
||||
#include "../libdebug/debug.h"
|
||||
#include "endpoint.h"
|
||||
#include "session.h"
|
||||
#include "message.h"
|
||||
#include "rtp.h"
|
||||
#include "helper.h"
|
||||
|
||||
osmo_cc_session_t *osmo_cc_helper_audio_offer(osmo_cc_session_config_t *conf, void *priv, struct osmo_cc_helper_audio_codecs *codecs, void (*receiver)(struct osmo_cc_session_codec *codec, uint8_t marker, uint16_t sequence_number, uint32_t timestamp, uint32_t ssrc, uint8_t *data, int len), osmo_cc_msg_t *msg, int debug)
|
||||
|
@ -44,8 +46,9 @@ osmo_cc_session_t *osmo_cc_helper_audio_offer(osmo_cc_session_config_t *conf, vo
|
|||
media = osmo_cc_add_media(session, 0, 0, NULL, osmo_cc_session_media_type_audio, 0, osmo_cc_session_media_proto_rtp, 1, 1, receiver, debug);
|
||||
osmo_cc_rtp_open(media);
|
||||
|
||||
for (i = 0; codecs[i].payload_name; i++)
|
||||
for (i = 0; codecs[i].payload_name; i++) {
|
||||
osmo_cc_add_codec(media, codecs[i].payload_name, codecs[i].payload_rate, codecs[i].payload_channels, codecs[i].encoder, codecs[i].decoder, debug);
|
||||
}
|
||||
|
||||
sdp = osmo_cc_session_send_offer(session);
|
||||
osmo_cc_add_ie_sdp(msg, sdp);
|
||||
|
@ -54,6 +57,11 @@ osmo_cc_session_t *osmo_cc_helper_audio_offer(osmo_cc_session_config_t *conf, vo
|
|||
}
|
||||
|
||||
const char *osmo_cc_helper_audio_accept(osmo_cc_session_config_t *conf, void *priv, struct osmo_cc_helper_audio_codecs *codecs, void (*receiver)(struct osmo_cc_session_codec *codec, uint8_t marker, uint16_t sequence_number, uint32_t timestamp, uint32_t ssrc, uint8_t *data, int len), osmo_cc_msg_t *msg, osmo_cc_session_t **session_p, osmo_cc_session_codec_t **codec_p, int force_our_codec)
|
||||
{
|
||||
return osmo_cc_helper_audio_accept_te(conf, priv, codecs, receiver, msg, session_p, codec_p, NULL, force_our_codec);
|
||||
}
|
||||
|
||||
const char *osmo_cc_helper_audio_accept_te(osmo_cc_session_config_t *conf, void *priv, struct osmo_cc_helper_audio_codecs *codecs, void (*receiver)(struct osmo_cc_session_codec *codec, uint8_t marker, uint16_t sequence_number, uint32_t timestamp, uint32_t ssrc, uint8_t *data, int len), osmo_cc_msg_t *msg, osmo_cc_session_t **session_p, osmo_cc_session_codec_t **codec_p, osmo_cc_session_codec_t **telephone_event_p, int force_our_codec)
|
||||
{
|
||||
char offer_sdp[65536];
|
||||
const char *accept_sdp;
|
||||
|
@ -136,6 +144,8 @@ const char *osmo_cc_helper_audio_accept(osmo_cc_session_config_t *conf, void *pr
|
|||
osmo_cc_rtp_open(selected_media);
|
||||
osmo_cc_rtp_connect(selected_media);
|
||||
*codec_p = selected_codec;
|
||||
if (telephone_event_p)
|
||||
*telephone_event_p = telephone_event;
|
||||
|
||||
accept_sdp = osmo_cc_session_send_answer(*session_p);
|
||||
if (!accept_sdp) {
|
||||
|
@ -148,9 +158,15 @@ const char *osmo_cc_helper_audio_accept(osmo_cc_session_config_t *conf, void *pr
|
|||
}
|
||||
|
||||
int osmo_cc_helper_audio_negotiate(osmo_cc_msg_t *msg, osmo_cc_session_t **session_p, osmo_cc_session_codec_t **codec_p)
|
||||
{
|
||||
return osmo_cc_helper_audio_negotiate_te(msg, session_p, codec_p, NULL);
|
||||
}
|
||||
|
||||
int osmo_cc_helper_audio_negotiate_te(osmo_cc_msg_t *msg, osmo_cc_session_t **session_p, osmo_cc_session_codec_t **codec_p, osmo_cc_session_codec_t **telephone_event_p)
|
||||
{
|
||||
char sdp[65536];
|
||||
osmo_cc_session_media_t *media;
|
||||
osmo_cc_session_codec_t *codec;
|
||||
int rc;
|
||||
|
||||
if (!(*session_p)) {
|
||||
|
@ -158,10 +174,6 @@ int osmo_cc_helper_audio_negotiate(osmo_cc_msg_t *msg, osmo_cc_session_t **sessi
|
|||
abort();
|
||||
}
|
||||
|
||||
/* once done, just ignore further messages that reply to setup */
|
||||
if (*codec_p)
|
||||
return 0;
|
||||
|
||||
/* SDP IE */
|
||||
rc = osmo_cc_get_ie_sdp(msg, 0, sdp, sizeof(sdp));
|
||||
if (rc < 0)
|
||||
|
@ -172,12 +184,29 @@ int osmo_cc_helper_audio_negotiate(osmo_cc_msg_t *msg, osmo_cc_session_t **sessi
|
|||
return rc;
|
||||
|
||||
osmo_cc_session_for_each_media((*session_p)->media_list, media) {
|
||||
/* skip not accepted medias */
|
||||
if (!media->accepted)
|
||||
continue;
|
||||
/* only audio */
|
||||
if (media->description.type != osmo_cc_session_media_type_audio)
|
||||
continue;
|
||||
/* select first codec, if one was accpeted */
|
||||
if (media->codec_list)
|
||||
*codec_p = media->codec_list;
|
||||
osmo_cc_session_for_each_codec(media->codec_list, codec) {
|
||||
/* skip not accepted codecs */
|
||||
if (!codec->accepted)
|
||||
continue;
|
||||
if (!!strcasecmp(codec->payload_name, "telephone-event")) {
|
||||
/* select first codec, if one was accpeted */
|
||||
if (!(*codec_p)) {
|
||||
LOGP(DCC, LOGL_DEBUG, "Select codec '%s'.\n", codec->payload_name);
|
||||
*codec_p = codec;
|
||||
}
|
||||
} else {
|
||||
if (telephone_event_p && !(*telephone_event_p)) {
|
||||
LOGP(DCC, LOGL_DEBUG, "select telephone event codec.\n");
|
||||
*telephone_event_p = codec;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (*codec_p) {
|
||||
osmo_cc_rtp_connect(media);
|
||||
/* no more media streams */
|
||||
|
|
|
@ -9,5 +9,7 @@ struct osmo_cc_helper_audio_codecs {
|
|||
|
||||
osmo_cc_session_t *osmo_cc_helper_audio_offer(osmo_cc_session_config_t *conf, void *priv, struct osmo_cc_helper_audio_codecs *codecs, void (*receiver)(struct osmo_cc_session_codec *codec, uint8_t marker, uint16_t sequence_number, uint32_t timestamp, uint32_t ssrc, uint8_t *data, int len), osmo_cc_msg_t *msg, int debug);
|
||||
const char *osmo_cc_helper_audio_accept(osmo_cc_session_config_t *conf, void *priv, struct osmo_cc_helper_audio_codecs *codecs, void (*receiver)(struct osmo_cc_session_codec *codec, uint8_t marker, uint16_t sequence_number, uint32_t timestamp, uint32_t ssrc, uint8_t *data, int len), osmo_cc_msg_t *msg, osmo_cc_session_t **session_p, osmo_cc_session_codec_t **codec_p, int force_our_codec);
|
||||
const char *osmo_cc_helper_audio_accept_te(osmo_cc_session_config_t *conf, void *priv, struct osmo_cc_helper_audio_codecs *codecs, void (*receiver)(struct osmo_cc_session_codec *codec, uint8_t marker, uint16_t sequence_number, uint32_t timestamp, uint32_t ssrc, uint8_t *data, int len), osmo_cc_msg_t *msg, osmo_cc_session_t **session_p, osmo_cc_session_codec_t **codec_p, osmo_cc_session_codec_t **telephone_event_p, int force_our_codec);
|
||||
int osmo_cc_helper_audio_negotiate(osmo_cc_msg_t *msg, osmo_cc_session_t **session_p, osmo_cc_session_codec_t **codec_p);
|
||||
int osmo_cc_helper_audio_negotiate_te(osmo_cc_msg_t *msg, osmo_cc_session_t **session_p, osmo_cc_session_codec_t **codec_p, osmo_cc_session_codec_t **telephone_event_p);
|
||||
|
||||
|
|
|
@ -338,6 +338,7 @@ static const char *osmo_cc_network_name[OSMO_CC_NETWORK_NUM] = {
|
|||
[OSMO_CC_NETWORK_DECT_NONE] = "decs",
|
||||
[OSMO_CC_NETWORK_BLUETOOTH_NONE] = "bluetooth",
|
||||
[OSMO_CC_NETWORK_SS5_NONE] = "ss5",
|
||||
[OSMO_CC_NETWORK_R1_NONE] = "r1",
|
||||
[OSMO_CC_NETWORK_ANETZ_NONE] = "anetz",
|
||||
[OSMO_CC_NETWORK_BNETZ_MUENZ] = "bnetz",
|
||||
[OSMO_CC_NETWORK_CNETZ_NONE] = "cnetz",
|
||||
|
|
|
@ -310,6 +310,7 @@ int osmo_cc_socket_cause_name2value(const char *name);
|
|||
#define OSMO_CC_NETWORK_DECT_NONE 0x08
|
||||
#define OSMO_CC_NETWORK_BLUETOOTH_NONE 0x09
|
||||
#define OSMO_CC_NETWORK_SS5_NONE 0x0a
|
||||
#define OSMO_CC_NETWORK_R1_NONE 0x0b
|
||||
#define OSMO_CC_NETWORK_ANETZ_NONE 0x80
|
||||
#define OSMO_CC_NETWORK_BNETZ_MUENZ 0x81 /* id starts with 'M' */
|
||||
#define OSMO_CC_NETWORK_CNETZ_NONE 0x82
|
||||
|
|
|
@ -24,7 +24,6 @@
|
|||
#include <fcntl.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <sys/socket.h>
|
||||
#include <arpa/inet.h>
|
||||
#include "../libdebug/debug.h"
|
||||
#include "../libtimer/timer.h"
|
||||
|
@ -53,7 +52,7 @@ struct rtp_x_hdr {
|
|||
uint16_t length;
|
||||
} __attribute__((packed));
|
||||
|
||||
static int rtp_receive(int sock, uint8_t **payload_p, int *payload_len_p, uint8_t *marker_p, uint8_t *pt_p, uint16_t *sequence_p, uint32_t *timestamp_p, uint32_t *ssrc_p)
|
||||
static int rtp_receive(struct sockaddr_storage *sa, socklen_t *slen, int sock, uint8_t **payload_p, int *payload_len_p, uint8_t *marker_p, uint8_t *pt_p, uint16_t *sequence_p, uint32_t *timestamp_p, uint32_t *ssrc_p)
|
||||
{
|
||||
static uint8_t data[2048];
|
||||
int len;
|
||||
|
@ -64,7 +63,7 @@ static int rtp_receive(int sock, uint8_t **payload_p, int *payload_len_p, uint8_
|
|||
int payload_len;
|
||||
int x_len;
|
||||
|
||||
len = read(sock, data, sizeof(data));
|
||||
len = recvfrom(sock, data, sizeof(data), 0, (struct sockaddr *)sa, slen);
|
||||
if (len < 0) {
|
||||
if (errno == EAGAIN)
|
||||
return -EAGAIN;
|
||||
|
@ -133,12 +132,12 @@ static int rtp_receive(int sock, uint8_t **payload_p, int *payload_len_p, uint8_
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int rtcp_receive(int sock)
|
||||
static int rtcp_receive(struct sockaddr_storage *sa, socklen_t *slen, int sock)
|
||||
{
|
||||
static uint8_t data[2048];
|
||||
int len;
|
||||
|
||||
len = read(sock, data, sizeof(data));
|
||||
len = recvfrom(sock, data, sizeof(data), 0, (struct sockaddr *)sa, slen);
|
||||
if (len < 0) {
|
||||
if (errno == EAGAIN)
|
||||
return -EAGAIN;
|
||||
|
@ -149,7 +148,7 @@ static int rtcp_receive(int sock)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void rtp_send(int sock, uint8_t *payload, int payload_len, uint8_t marker, uint8_t pt, uint16_t sequence, uint32_t timestamp, uint32_t ssrc)
|
||||
static void rtp_send(struct sockaddr_storage *sa, socklen_t slen, int sock, uint8_t *payload, int payload_len, uint8_t marker, uint8_t pt, uint16_t sequence, uint32_t timestamp, uint32_t ssrc)
|
||||
{
|
||||
struct rtp_hdr *rtph;
|
||||
char data[sizeof(*rtph) + payload_len];
|
||||
|
@ -169,9 +168,9 @@ static void rtp_send(int sock, uint8_t *payload, int payload_len, uint8_t marker
|
|||
}
|
||||
memcpy(data + sizeof(*rtph), payload, payload_len);
|
||||
|
||||
rc = write(sock, data, len);
|
||||
rc = sendto(sock, data, len, 0, (struct sockaddr *)sa, slen);
|
||||
if (rc < 0)
|
||||
LOGP(DCC, LOGL_DEBUG, "Write errno = %d (%s)\n", errno, strerror(errno));
|
||||
LOGP(DCC, LOGL_DEBUG, "sendto errno = %d (%s)\n", errno, strerror(errno));
|
||||
}
|
||||
|
||||
static int rtp_listen_cb(struct osmo_fd *ofd, unsigned int when);
|
||||
|
@ -186,7 +185,7 @@ int osmo_cc_rtp_open(osmo_cc_session_media_t *media)
|
|||
int domain = 0; // make GCC happy
|
||||
uint16_t start_port;
|
||||
struct sockaddr_storage sa;
|
||||
int slen = 0; // make GCC happy
|
||||
socklen_t slen = 0; // make GCC happy
|
||||
struct sockaddr_in6 *sa6;
|
||||
struct sockaddr_in *sa4;
|
||||
uint16_t *sport;
|
||||
|
@ -294,19 +293,16 @@ bind_error:
|
|||
*/
|
||||
int osmo_cc_rtp_connect(osmo_cc_session_media_t *media)
|
||||
{
|
||||
struct sockaddr_storage sa;
|
||||
int slen = 0; // make GCC happy
|
||||
struct sockaddr_in6 *sa6;
|
||||
struct sockaddr_in *sa4;
|
||||
uint16_t *sport;
|
||||
int rc;
|
||||
|
||||
LOGP(DCC, LOGL_DEBUG, "Connecting media port %d->%d\n", media->description.port_local, media->description.port_remote);
|
||||
LOGP(DCC, LOGL_DEBUG, "Connecting media port %d->%d (remote %s)\n", media->description.port_local, media->description.port_remote, media->connection_data_remote.address);
|
||||
|
||||
switch (media->connection_data_remote.addrtype) {
|
||||
case osmo_cc_session_addrtype_ipv4:
|
||||
memset(&sa, 0, sizeof(sa));
|
||||
sa4 = (struct sockaddr_in *)&sa;
|
||||
memset(&media->rtp_sa, 0, sizeof(media->rtp_sa));
|
||||
sa4 = (struct sockaddr_in *)&media->rtp_sa;
|
||||
sa4->sin_family = AF_INET;
|
||||
rc = inet_pton(AF_INET, media->connection_data_remote.address, &sa4->sin_addr);
|
||||
if (rc < 1) {
|
||||
|
@ -314,36 +310,34 @@ pton_error:
|
|||
LOGP(DCC, LOGL_NOTICE, "Cannot connect to address '%s'.\n", media->connection_data_remote.address);
|
||||
return -EINVAL;
|
||||
}
|
||||
sport = &sa4->sin_port;
|
||||
slen = sizeof(*sa4);
|
||||
media->rtp_sport = &sa4->sin_port;
|
||||
media->rtp_slen = sizeof(*sa4);
|
||||
memcpy(&media->rtcp_sa, &media->rtp_sa, sizeof(*sa4));
|
||||
sa4 = (struct sockaddr_in *)&media->rtcp_sa;
|
||||
media->rtcp_sport = &sa4->sin_port;
|
||||
media->rtcp_slen = sizeof(*sa4);
|
||||
break;
|
||||
case osmo_cc_session_addrtype_ipv6:
|
||||
memset(&sa, 0, sizeof(sa));
|
||||
sa6 = (struct sockaddr_in6 *)&sa;
|
||||
memset(&media->rtp_sa, 0, sizeof(media->rtp_sa));
|
||||
sa6 = (struct sockaddr_in6 *)&media->rtp_sa;
|
||||
sa6->sin6_family = AF_INET6;
|
||||
rc = inet_pton(AF_INET6, media->connection_data_remote.address, &sa6->sin6_addr);
|
||||
if (rc < 1)
|
||||
goto pton_error;
|
||||
sport = &sa6->sin6_port;
|
||||
slen = sizeof(*sa6);
|
||||
media->rtp_sport = &sa6->sin6_port;
|
||||
media->rtp_slen = sizeof(*sa6);
|
||||
memcpy(&media->rtcp_sa, &media->rtp_sa, sizeof(*sa6));
|
||||
sa6 = (struct sockaddr_in6 *)&media->rtcp_sa;
|
||||
media->rtcp_sport = &sa6->sin6_port;
|
||||
media->rtcp_slen = sizeof(*sa6);
|
||||
break;
|
||||
case osmo_cc_session_addrtype_unknown:
|
||||
LOGP(DCC, LOGL_NOTICE, "Unsupported address type '%s'.\n", media->connection_data_local.addrtype_name);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
*sport = htons(media->description.port_remote);
|
||||
rc = connect(media->rtp_ofd.fd, (struct sockaddr *)&sa, slen);
|
||||
if (rc < 0) {
|
||||
connect_error:
|
||||
LOGP(DCC, LOGL_NOTICE, "Cannot connect to address '%s'.\n", media->connection_data_remote.address);
|
||||
osmo_cc_rtp_close(media);
|
||||
return -EIO;
|
||||
}
|
||||
*sport = htons(media->description.port_remote + 1);
|
||||
rc = connect(media->rtcp_ofd.fd, (struct sockaddr *)&sa, slen);
|
||||
if (rc < 0)
|
||||
goto connect_error;
|
||||
*media->rtp_sport = htons(media->description.port_remote);
|
||||
*media->rtcp_sport = htons(media->description.port_remote + 1);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -364,7 +358,7 @@ void osmo_cc_rtp_send(osmo_cc_session_codec_t *codec, uint8_t *data, int len, ui
|
|||
payload_len = len;
|
||||
}
|
||||
|
||||
rtp_send(codec->media->rtp_ofd.fd, payload, payload_len, marker, codec->payload_type_remote, codec->media->tx_sequence, codec->media->tx_timestamp, codec->media->tx_ssrc);
|
||||
rtp_send(&codec->media->rtp_sa, codec->media->rtp_slen, codec->media->rtp_ofd.fd, payload, payload_len, marker, codec->payload_type_remote, codec->media->tx_sequence, codec->media->tx_timestamp, codec->media->tx_ssrc);
|
||||
codec->media->tx_sequence += inc_sequence;
|
||||
codec->media->tx_timestamp += inc_timestamp;
|
||||
|
||||
|
@ -372,6 +366,68 @@ void osmo_cc_rtp_send(osmo_cc_session_codec_t *codec, uint8_t *data, int len, ui
|
|||
free(payload);
|
||||
}
|
||||
|
||||
/* dito, but with absolute sequence and timestamp */
|
||||
void osmo_cc_rtp_send_ts(osmo_cc_session_codec_t *codec, uint8_t *data, int len, uint8_t marker, uint16_t tx_sequence, uint32_t tx_timestamp, void *priv)
|
||||
{
|
||||
uint8_t *payload = NULL;
|
||||
int payload_len = 0;
|
||||
|
||||
if (!codec || !codec->media->rtp_ofd.fd)
|
||||
return;
|
||||
|
||||
if (codec->encoder)
|
||||
codec->encoder(data, len, &payload, &payload_len, priv);
|
||||
else {
|
||||
payload = data;
|
||||
payload_len = len;
|
||||
}
|
||||
|
||||
rtp_send(&codec->media->rtp_sa, codec->media->rtp_slen, codec->media->rtp_ofd.fd, payload, payload_len, marker, codec->payload_type_remote, tx_sequence, tx_timestamp, codec->media->tx_ssrc);
|
||||
codec->media->tx_sequence = tx_sequence;
|
||||
codec->media->tx_timestamp = tx_timestamp;
|
||||
|
||||
if (codec->encoder)
|
||||
free(payload);
|
||||
}
|
||||
|
||||
static void check_port_translation(struct sockaddr_storage *sa, struct sockaddr_storage *media_sa, const char *what)
|
||||
{
|
||||
struct sockaddr_in6 *sa6, *sa6_2;
|
||||
struct sockaddr_in *sa4, *sa4_2;
|
||||
int from = 0, to = 0;
|
||||
|
||||
if (sa->ss_family != media_sa->ss_family)
|
||||
return;
|
||||
|
||||
switch (sa->ss_family) {
|
||||
case AF_INET:
|
||||
sa4 = (struct sockaddr_in *)sa;
|
||||
sa4_2 = (struct sockaddr_in *)media_sa;
|
||||
if (sa4->sin_port != sa4_2->sin_port) {
|
||||
if (!!memcmp(&sa4->sin_addr, &sa4_2->sin_addr, sizeof(struct in_addr)))
|
||||
break;
|
||||
from = ntohs(sa4_2->sin_port);
|
||||
to = ntohs(sa4->sin_port);
|
||||
sa4_2->sin_port = sa4->sin_port;
|
||||
}
|
||||
break;
|
||||
case AF_INET6:
|
||||
sa6 = (struct sockaddr_in6 *)sa;
|
||||
sa6_2 = (struct sockaddr_in6 *)media_sa;
|
||||
if (sa6->sin6_port != sa6_2->sin6_port) {
|
||||
if (!!memcmp(&sa6->sin6_addr, &sa6_2->sin6_addr, sizeof(struct in6_addr)))
|
||||
break;
|
||||
from = ntohs(sa6_2->sin6_port);
|
||||
to = ntohs(sa6->sin6_port);
|
||||
sa6_2->sin6_port = sa6->sin6_port;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (from)
|
||||
LOGP(DCC, LOGL_NOTICE, "Remote sends with different %s port, changing from %d to %d!\n", what, from, to);
|
||||
}
|
||||
|
||||
static int rtp_listen_cb(struct osmo_fd *ofd, unsigned int when)
|
||||
{
|
||||
osmo_cc_session_media_t *media = ofd->data;
|
||||
|
@ -383,11 +439,14 @@ static int rtp_listen_cb(struct osmo_fd *ofd, unsigned int when)
|
|||
osmo_cc_session_codec_t *codec;
|
||||
uint8_t *data;
|
||||
int len;
|
||||
struct sockaddr_storage sa;
|
||||
socklen_t slen = sizeof(sa); // must be initialized and will be overwritten
|
||||
|
||||
if (when & OSMO_FD_READ) {
|
||||
rc = rtp_receive(media->rtp_ofd.fd, &payload, &payload_len, &marker, &payload_type, &media->rx_sequence, &media->rx_timestamp, &media->rx_ssrc);
|
||||
rc = rtp_receive(&sa, &slen, media->rtp_ofd.fd, &payload, &payload_len, &marker, &payload_type, &media->rx_sequence, &media->rx_timestamp, &media->rx_ssrc);
|
||||
if (rc < 0)
|
||||
return rc;
|
||||
check_port_translation(&sa, &media->rtp_sa, "RTP");
|
||||
|
||||
/* search for codec */
|
||||
for (codec = media->codec_list; codec; codec = codec->next) {
|
||||
|
@ -420,11 +479,14 @@ static int rtcp_listen_cb(struct osmo_fd *ofd, unsigned int when)
|
|||
{
|
||||
osmo_cc_session_media_t *media = ofd->data;
|
||||
int rc;
|
||||
struct sockaddr_storage sa;
|
||||
socklen_t slen = sizeof(sa); // must be initialized and will be overwritten
|
||||
|
||||
if (when & OSMO_FD_READ) {
|
||||
rc = rtcp_receive(media->rtp_ofd.fd);
|
||||
rc = rtcp_receive(&sa, &slen, media->rtcp_ofd.fd);
|
||||
if (rc < 0)
|
||||
return rc;
|
||||
check_port_translation(&sa, &media->rtcp_sa, "RTCP");
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -3,5 +3,6 @@ void osmo_cc_set_rtp_ports(osmo_cc_session_config_t *conf, uint16_t from, uint16
|
|||
int osmo_cc_rtp_open(osmo_cc_session_media_t *media);
|
||||
int osmo_cc_rtp_connect(osmo_cc_session_media_t *media);
|
||||
void osmo_cc_rtp_send(osmo_cc_session_codec_t *codec, uint8_t *data, int len, uint8_t marker, int inc_sequence, int inc_timestamp, void *priv);
|
||||
void osmo_cc_rtp_send_ts(osmo_cc_session_codec_t *codec, uint8_t *data, int len, uint8_t marker, uint16_t tx_sequence, uint32_t tx_timestamp, void *priv);
|
||||
void osmo_cc_rtp_close(osmo_cc_session_media_t *media);
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
}
|
||||
|
||||
/* generate SDP from session structure */
|
||||
char *osmo_cc_session_gensdp(osmo_cc_session_t *session)
|
||||
char *osmo_cc_session_gensdp(osmo_cc_session_t *session, int accepted_only)
|
||||
{
|
||||
/* calc max size of SDP: quick an dirty (close to max UDP payload size) */
|
||||
static char sdp[65000];
|
||||
|
@ -68,6 +68,8 @@ char *osmo_cc_session_gensdp(osmo_cc_session_t *session)
|
|||
/* Connection Data (if all media have the same data) */
|
||||
if (session->media_list) {
|
||||
osmo_cc_session_for_each_media(session->media_list->next, media) {
|
||||
if (accepted_only && !media->accepted)
|
||||
continue;
|
||||
if (session->media_list->connection_data_local.nettype != media->connection_data_local.nettype)
|
||||
break;
|
||||
if (session->media_list->connection_data_local.addrtype != media->connection_data_local.addrtype)
|
||||
|
@ -87,6 +89,8 @@ char *osmo_cc_session_gensdp(osmo_cc_session_t *session)
|
|||
/* sendonly /recvonly (if all media have the same data) */
|
||||
if (session->media_list) {
|
||||
osmo_cc_session_for_each_media(session->media_list->next, media) {
|
||||
if (accepted_only && !media->accepted)
|
||||
continue;
|
||||
if (session->media_list->send != media->send)
|
||||
break;
|
||||
if (session->media_list->receive != media->receive)
|
||||
|
@ -106,12 +110,17 @@ char *osmo_cc_session_gensdp(osmo_cc_session_t *session)
|
|||
|
||||
/* media */
|
||||
osmo_cc_session_for_each_media(session->media_list, media) {
|
||||
if (accepted_only && !media->accepted)
|
||||
continue;
|
||||
strncat_printf(sdp, "m=%s %u %s",
|
||||
osmo_cc_session_media_type2string(media->description.type) ? : media->description.type_name,
|
||||
media->description.port_local,
|
||||
osmo_cc_session_media_proto2string(media->description.proto) ? : media->description.proto_name);
|
||||
osmo_cc_session_for_each_codec(media->codec_list, codec)
|
||||
osmo_cc_session_for_each_codec(media->codec_list, codec) {
|
||||
if (accepted_only && !codec->accepted)
|
||||
continue;
|
||||
strncat_printf(sdp, " %u", codec->payload_type_local);
|
||||
}
|
||||
strncat_printf(sdp, "\r\n");
|
||||
/* don't list rtpmap when session was canceled by setting port to 0 */
|
||||
if (media->description.port_local == 0)
|
||||
|
@ -119,6 +128,8 @@ char *osmo_cc_session_gensdp(osmo_cc_session_t *session)
|
|||
if (individual_connection_data)
|
||||
strncat_printf(sdp, "c=%s %s %s\r\n", osmo_cc_session_nettype2string(media->connection_data_local.nettype), osmo_cc_session_addrtype2string(media->connection_data_local.addrtype), media->connection_data_local.address);
|
||||
osmo_cc_session_for_each_codec(media->codec_list, codec) {
|
||||
if (accepted_only && !codec->accepted)
|
||||
continue;
|
||||
strncat_printf(sdp, "a=rtpmap:%u %s/%d", codec->payload_type_local, codec->payload_name, codec->payload_rate);
|
||||
if (codec->payload_channels >= 2)
|
||||
strncat_printf(sdp, "/%d", codec->payload_channels);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
|
||||
char *osmo_cc_session_gensdp(struct osmo_cc_session *session);
|
||||
char *osmo_cc_session_gensdp(struct osmo_cc_session *session, int accepted_only);
|
||||
struct osmo_cc_session *osmo_cc_session_parsesdp(osmo_cc_session_config_t *conf, void *priv, const char *_sdp);
|
||||
int osmo_cc_payload_type_by_attrs(uint8_t *fmt, const char *name, uint32_t *rate, int *channels);
|
||||
void osmo_cc_debug_sdp(const char *sdp);
|
||||
|
|
|
@ -348,7 +348,7 @@ const char *osmo_cc_session_send_offer(osmo_cc_session_t *session)
|
|||
abort();
|
||||
}
|
||||
|
||||
sdp = osmo_cc_session_gensdp(session);
|
||||
sdp = osmo_cc_session_gensdp(session, 0);
|
||||
osmo_cc_debug_sdp(sdp);
|
||||
|
||||
return sdp;
|
||||
|
@ -419,42 +419,20 @@ void osmo_cc_session_accept_codec(osmo_cc_session_codec_t *codec, void (*encoder
|
|||
LOGP(DCC, LOGL_DEBUG, " -> payload channels = %d\n", codec->payload_channels);
|
||||
}
|
||||
|
||||
/* remove codecs/media that have not been accepted and generate SDP */
|
||||
const char *osmo_cc_session_send_answer(osmo_cc_session_t *session)
|
||||
{
|
||||
osmo_cc_session_media_t *media;
|
||||
osmo_cc_session_codec_t *codec, **codec_p;
|
||||
const char *sdp;
|
||||
int rc;
|
||||
|
||||
LOGP(DCC, LOGL_DEBUG, "Generating session answer.\n");
|
||||
|
||||
/* loop all media */
|
||||
osmo_cc_session_for_each_media(session->media_list, media) {
|
||||
/* remove unaccepted codecs */
|
||||
codec_p = &media->codec_list;
|
||||
codec = *codec_p;
|
||||
while (codec) {
|
||||
if (!codec->accepted) {
|
||||
osmo_cc_free_codec(codec);
|
||||
codec = *codec_p;
|
||||
continue;
|
||||
}
|
||||
codec_p = &codec->next;
|
||||
codec = *codec_p;
|
||||
}
|
||||
/* mark media as unused, if no codec or not accepted */
|
||||
if (!media->accepted || !media->codec_list)
|
||||
media->description.port_local = 0;
|
||||
}
|
||||
|
||||
rc = osmo_cc_session_check(session, 0);
|
||||
if (rc < 0) {
|
||||
LOGP(DCC, LOGL_ERROR, "Please fix!\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
sdp = osmo_cc_session_gensdp(session);
|
||||
sdp = osmo_cc_session_gensdp(session, 1);
|
||||
osmo_cc_debug_sdp(sdp);
|
||||
|
||||
return sdp;
|
||||
|
@ -505,13 +483,14 @@ static int osmo_cc_session_negotiate(osmo_cc_session_t *session_local, struct os
|
|||
&& codec_local->payload_channels == codec_remote->payload_channels)
|
||||
break;
|
||||
}
|
||||
if (!codec_remote) {
|
||||
osmo_cc_free_codec(codec_local);
|
||||
codec_local = *codec_local_p;
|
||||
continue;
|
||||
if (codec_remote) {
|
||||
/* mark as accepted, copy remote codec information */
|
||||
codec_local->accepted = 1;
|
||||
codec_local->payload_type_remote = codec_remote->payload_type_remote;
|
||||
} else {
|
||||
/* mark as not accepted, in case it was accepted in earlier response */
|
||||
codec_local->accepted = 0;
|
||||
}
|
||||
/* copy remote codec information */
|
||||
codec_local->payload_type_remote = codec_remote->payload_type_remote;
|
||||
codec_local_p = &codec_local->next;
|
||||
codec_local = *codec_local_p;
|
||||
}
|
||||
|
@ -525,14 +504,16 @@ static int osmo_cc_session_negotiate(osmo_cc_session_t *session_local, struct os
|
|||
return -EINVAL;
|
||||
}
|
||||
|
||||
/* remove media with port == 0 or no codec at all */
|
||||
/* mark media as accepted, if there is a remote port and there is at least one codec */
|
||||
media_local_p = &session_local->media_list;
|
||||
media_local = *media_local_p;
|
||||
while (media_local) {
|
||||
if (media_local->description.port_remote == 0 || !media_local->codec_list) {
|
||||
osmo_cc_free_media(media_local);
|
||||
media_local = *media_local_p;
|
||||
continue;
|
||||
if (media_local->description.port_remote && media_local->codec_list) {
|
||||
/* mark as accepted */
|
||||
media_local->accepted = 1;
|
||||
} else {
|
||||
/* mark as not accepted, in case it was accepted in earlier response */
|
||||
media_local->accepted = 0;
|
||||
}
|
||||
media_local_p = &media_local->next;
|
||||
media_local = *media_local_p;
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
#include <sys/socket.h>
|
||||
|
||||
/* configuration */
|
||||
|
||||
enum osmo_cc_session_nettype {
|
||||
|
@ -80,6 +82,9 @@ typedef struct osmo_cc_session_media {
|
|||
struct osmo_cc_session_codec *codec_list;
|
||||
int send, receive;
|
||||
void (*receiver)(struct osmo_cc_session_codec *codec, uint8_t marker, uint16_t sequence_number, uint32_t timestamp, uint32_t ssrc, uint8_t *data, int len);
|
||||
struct sockaddr_storage rtp_sa, rtcp_sa;
|
||||
socklen_t rtp_slen, rtcp_slen;
|
||||
uint16_t *rtp_sport, *rtcp_sport; // pointers to the port inside sa sockaddr
|
||||
struct osmo_fd rtp_ofd;
|
||||
struct osmo_fd rtcp_ofd;
|
||||
uint32_t tx_ssrc, rx_ssrc;
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
AM_CPPFLAGS = -Wall -Wextra -g $(all_includes)
|
||||
|
||||
noinst_LIBRARIES = libselect.a
|
||||
|
||||
libselect_a_SOURCES = \
|
||||
select.c
|
|
@ -0,0 +1,168 @@
|
|||
/* Timer handling
|
||||
*
|
||||
* (C) 2023 by Andreas Eversberg <jolly@eversberg.eu>
|
||||
* All Rights Reserved
|
||||
*
|
||||
* Inspired by libosmocore
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <sys/select.h>
|
||||
#include <sys/time.h>
|
||||
#include "select.h"
|
||||
|
||||
//#define DEBUG
|
||||
|
||||
#define MAX_OFD 1024
|
||||
|
||||
struct osmo_fd *ofd_list = NULL;
|
||||
int ofd_changed = 0;
|
||||
|
||||
int osmo_fd_register(struct osmo_fd *ofd)
|
||||
{
|
||||
struct osmo_fd **ofdp;
|
||||
|
||||
/* attach to list, if not already */
|
||||
ofdp = &ofd_list;
|
||||
while (*ofdp) {
|
||||
if (*ofdp == ofd)
|
||||
break;
|
||||
ofdp = &((*ofdp)->next);
|
||||
}
|
||||
if (!*ofdp) {
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "%s: ofd=%p fd=%d registers.\n", __func__, ofd, ofd->fd);
|
||||
#endif
|
||||
ofd->next = NULL;
|
||||
*ofdp = ofd;
|
||||
ofd_changed = 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void osmo_fd_unregister(struct osmo_fd *ofd)
|
||||
{
|
||||
struct osmo_fd **ofdp;
|
||||
|
||||
/* detach from list, if not already */
|
||||
ofdp = &ofd_list;
|
||||
while (*ofdp) {
|
||||
if (*ofdp == ofd)
|
||||
break;
|
||||
ofdp = &((*ofdp)->next);
|
||||
}
|
||||
if (*ofdp) {
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "%s: ofd=%p fd=%d unregisters.\n", __func__, ofd, ofd->fd);
|
||||
#endif
|
||||
*ofdp = ofd->next;
|
||||
ofd->next = NULL;
|
||||
ofd_changed = 1;
|
||||
}
|
||||
}
|
||||
|
||||
int osmo_fd_select(double timeout)
|
||||
{
|
||||
fd_set readset;
|
||||
fd_set writeset;
|
||||
fd_set exceptset;
|
||||
struct osmo_fd *ofd;
|
||||
struct timeval tv;
|
||||
int max_fd;
|
||||
unsigned int what;
|
||||
int work = 0;
|
||||
int rc;
|
||||
|
||||
/* init event sets */
|
||||
FD_ZERO(&readset);
|
||||
FD_ZERO(&writeset);
|
||||
FD_ZERO(&exceptset);
|
||||
|
||||
/* populate event set with all file descriptios */
|
||||
ofd = ofd_list;
|
||||
max_fd = 0;
|
||||
while (ofd) {
|
||||
if (ofd->fd > max_fd)
|
||||
max_fd = ofd->fd;
|
||||
if (ofd->when & OSMO_FD_READ)
|
||||
FD_SET(ofd->fd, &readset);
|
||||
if (ofd->when & OSMO_FD_WRITE)
|
||||
FD_SET(ofd->fd, &writeset);
|
||||
if (ofd->when & OSMO_FD_EXCEPT)
|
||||
FD_SET(ofd->fd, &exceptset);
|
||||
ofd = ofd->next;
|
||||
}
|
||||
|
||||
if (timeout >= 0) {
|
||||
/* prepare timeout */
|
||||
tv.tv_sec = floor(timeout);
|
||||
tv.tv_usec = (timeout - tv.tv_sec) * 1000000.0;
|
||||
/* wait for event or timeout */
|
||||
rc = select(max_fd + 1, &readset, &writeset, &exceptset, &tv);
|
||||
} else {
|
||||
/* wait for event */
|
||||
rc = select(max_fd + 1, &readset, &writeset, &exceptset, NULL);
|
||||
}
|
||||
if (rc < 0) {
|
||||
if (errno != EINTR)
|
||||
fprintf(stderr, "%s: select() failed: '%d' with errno %d (%s) Please fix!\n", __func__, rc, errno, strerror(errno));
|
||||
return 0;
|
||||
}
|
||||
|
||||
again:
|
||||
/* check the result and call handler */
|
||||
ofd_changed = 0;
|
||||
ofd = ofd_list;
|
||||
while (ofd) {
|
||||
what = 0;
|
||||
if (FD_ISSET(ofd->fd, &readset)) {
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "%s: ofd=%p fd=%d get READ event.\n", __func__, ofd, ofd->fd);
|
||||
#endif
|
||||
what |= OSMO_FD_READ;
|
||||
FD_CLR(ofd->fd, &readset);
|
||||
}
|
||||
if (FD_ISSET(ofd->fd, &writeset)) {
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "%s: ofd=%p fd=%d get WRITE event.\n", __func__, ofd, ofd->fd);
|
||||
#endif
|
||||
what |= OSMO_FD_WRITE;
|
||||
FD_CLR(ofd->fd, &writeset);
|
||||
}
|
||||
if (FD_ISSET(ofd->fd, &exceptset)) {
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "%s: ofd=%p fd=%d get EXCEPTION event.\n", __func__, ofd, ofd->fd);
|
||||
#endif
|
||||
what |= OSMO_FD_EXCEPT;
|
||||
FD_CLR(ofd->fd, &exceptset);
|
||||
}
|
||||
if (what) {
|
||||
work = 1;
|
||||
ofd->cb(ofd, what);
|
||||
/* list has changed */
|
||||
if (ofd_changed)
|
||||
goto again;
|
||||
}
|
||||
ofd = ofd->next;
|
||||
}
|
||||
|
||||
return work;
|
||||
}
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
|
||||
#define OSMO_FD_READ 0x0001
|
||||
#define OSMO_FD_WRITE 0x0002
|
||||
#define OSMO_FD_EXCEPT 0x0004
|
||||
#define BSC_FD_READ 0x0001
|
||||
#define BSC_FD_WRITE 0x0002
|
||||
#define BSC_FD_EXCEPT 0x0004
|
||||
|
||||
struct osmo_fd {
|
||||
struct osmo_fd *next;
|
||||
int fd;
|
||||
unsigned int when;
|
||||
int (*cb)(struct osmo_fd *fd, unsigned int what);
|
||||
void *data;
|
||||
};
|
||||
|
||||
int osmo_fd_register(struct osmo_fd *ofd);
|
||||
void osmo_fd_unregister(struct osmo_fd *ofd);
|
||||
int osmo_fd_select(double timeout);
|
||||
|
Loading…
Reference in New Issue