Compare commits

..

No commits in common. "master" and "master" have entirely different histories.

6 changed files with 79 additions and 58 deletions

View File

@ -1 +1 @@
2.0.0
1.0.0

View File

@ -1,4 +1,6 @@
AC_INIT([libosmo-cc],[m4_esyscmd(./git-version-gen .tarball-version)],[openbsc@lists.osmocom.org])
AC_INIT([libosmo-cc],
m4_esyscmd([./git-version-gen .tarball-version]),
[openbsc@lists.osmocom.org])
dnl *This* is the root dir, even if an install-sh exists in ../ or ../../
AC_CONFIG_AUX_DIR([.])
@ -62,8 +64,9 @@ CFLAGS="$saved_CFLAGS"
AC_SUBST(SYMBOL_VISIBILITY)
dnl Generate the output
AM_CONFIG_HEADER(config.h)
PKG_CHECK_MODULES(LIBOSMOCORE, libosmocore >= 1.6.0)
PKG_CHECK_MODULES(LIBOSMOCORE, libosmocore >= 1.9.0)
AC_ARG_ENABLE(sanitize,
[AS_HELP_STRING(
@ -125,8 +128,8 @@ CFLAGS=$_cflags_save
AC_MSG_RESULT([CFLAGS="$CFLAGS"])
AC_MSG_RESULT([CPPFLAGS="$CPPFLAGS"])
AC_CONFIG_FILES([libosmocc.pc
AC_OUTPUT(
libosmocc.pc
include/Makefile
src/Makefile
Makefile])
AC_OUTPUT
Makefile)

View File

@ -3,8 +3,8 @@
void osmo_cc_set_rtp_ports(osmo_cc_session_config_t *conf, uint16_t from, uint16_t to);
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 *payload, int payload_len, uint8_t marker, int inc_sequence,
int inc_timestamp);
void osmo_cc_rtp_send_ts(osmo_cc_session_codec_t *codec, uint8_t *payload, int payload_len, uint8_t marker,
uint16_t tx_sequence, uint32_t tx_timestamp);
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);

View File

@ -1,22 +1,11 @@
# This is _NOT_ the library release version, it's an API version.
# Please read Chapter 6 "Library interface versions" of the libtool
# documentation before making any modification
LIBVERSION=2:0:0
AM_CPPFLAGS = -Wall -Wextra -g $(all_includes) -I../include
AM_CPPFLAGS = \
$(all_includes) \
-I$(top_srcdir)/include \
$(NULL)
AM_CFLAGS = \
-Wall \
$(LIBOSMOCORE_CFLAGS) \
$(NULL)
lib_LTLIBRARIES = \
libosmocc.la \
$(NULL)
lib_LTLIBRARIES = libosmocc.la
libosmocc_la_LDFLAGS = $(AM_LDFLAGS) \
-no-undefined \
$(NULL)
libosmocc_la_LIBADD = $(COMMONLIBS)
libosmocc_la_SOURCES = \
message.c \
socket.c \
@ -28,14 +17,4 @@ libosmocc_la_SOURCES = \
rtp.c \
helper.c \
g711.c \
misc.c \
$(NULL)
libosmocc_la_LDFLAGS = \
-version-info $(LIBVERSION) \
-no-undefined \
$(NULL)
libosmocc_la_LIBADD = \
$(LIBOSMOCORE_LIBS) \
$(NULL)
misc.c

View File

@ -354,30 +354,56 @@ pton_error:
}
/* send rtp data with given codec */
void osmo_cc_rtp_send(osmo_cc_session_codec_t *codec, uint8_t *payload, int payload_len, uint8_t marker, int inc_sequence,
int inc_timestamp)
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)
{
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, codec->media->tx_sequence, codec->media->tx_timestamp,
codec->media->tx_ssrc);
codec->media->tx_sequence += inc_sequence;
codec->media->tx_timestamp += inc_timestamp;
if (codec->encoder)
free(payload);
}
/* dito, but with absolute sequence and timestamp */
void osmo_cc_rtp_send_ts(osmo_cc_session_codec_t *codec, uint8_t *payload, int payload_len, uint8_t marker,
uint16_t tx_sequence, uint32_t tx_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)
@ -428,6 +454,8 @@ static int rtp_listen_cb(struct osmo_fd *ofd, unsigned int when)
uint8_t marker;
uint8_t payload_type;
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
@ -449,9 +477,19 @@ static int rtp_listen_cb(struct osmo_fd *ofd, unsigned int when)
return 0;
}
if (codec->decoder)
codec->decoder(payload, payload_len, &data, &len, media->session->priv);
else {
data = payload;
len = payload_len;
}
if (codec->media->receive)
codec->media->receiver(codec, marker, media->rx_sequence, media->rx_timestamp, media->rx_ssrc,
payload, payload_len);
data, len);
if (codec->decoder)
free(data);
}
return 0;

View File

@ -132,7 +132,10 @@ char *osmo_cc_session_gensdp(osmo_cc_session_t *session, int accepted_only)
osmo_cc_session_for_each_codec(media->codec_list, codec) {
if (accepted_only && !codec->accepted)
continue;
strncat_printf(sdp, "a=rtpmap:%u %s/%d/%d\r\n", codec->payload_type_local, codec->payload_name, codec->payload_rate, codec->payload_channels);
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);
strncat_printf(sdp, "\r\n");
}
if (individual_send_receive) {
if (media->send && !media->receive)
@ -496,34 +499,32 @@ struct osmo_cc_session *osmo_cc_session_parsesdp(osmo_cc_session_config_t *conf,
break;
}
LOGP(DLCC, LOGL_DEBUG, " -> (rtpmap) payload type = %d\n", codec->payload_type_remote);
if (!(word = wordsep(&next_word))) {
rtpmap_broken:
LOGP(DLCC, LOGL_NOTICE, "Broken 'rtpmap' definition in SDP line %d = '%s' Skipping codec!\n", line_no, line);
osmo_cc_free_codec(codec);
break;
}
if (!(word = wordsep(&next_word)))
goto rtpmap_done;
if ((p = strchr(word, '/')))
*p++ = '\0';
free((char *)codec->payload_name); // in case it is already set above
codec->payload_name = strdup(word);
LOGP(DLCC, LOGL_DEBUG, " -> (rtpmap) payload name = %s\n", codec->payload_name);
if (!(word = p))
goto rtpmap_broken;
goto rtpmap_done;
if ((p = strchr(word, '/')))
*p++ = '\0';
codec->payload_rate = atoi(word);
LOGP(DLCC, LOGL_DEBUG, " -> (rtpmap) payload rate = %d\n", codec->payload_rate);
if (!(word = p)) {
/* For audio streams, encoding-params indicates the number of audio channels.
* This parameter is OPTIONAL and may be omitted if the number of channels is
* one, provided that no additional parameters are needed. */
codec->payload_channels = 1;
LOGP(DLCC, LOGL_DEBUG, " -> (rtpmap) payload channels = %d (default)\n", codec->payload_channels);
break;
/* if no channel is given and no default was specified, we must set 1 channel */
if (!codec->payload_channels)
codec->payload_channels = 1;
goto rtpmap_done;
}
codec->payload_channels = atoi(word);
LOGP(DLCC, LOGL_DEBUG, " -> (rtpmap) payload channels = %d\n", codec->payload_channels);
break;
rtpmap_done:
if (!codec->payload_name || !codec->payload_rate || !codec->payload_channels) {
LOGP(DLCC, LOGL_NOTICE, "Broken 'rtpmap' definition in SDP line %d = '%s' Skipping codec!\n", line_no, line);
osmo_cc_free_codec(codec);
}
}
break;
}