forked from cc/libosmo-cc
Compare commits
5 Commits
Author | SHA1 | Date |
---|---|---|
Andreas Eversberg | 40075d1a99 | |
Andreas Eversberg | 68db24cf60 | |
Martin Hauke | 0f89975760 | |
Andreas Eversberg | 6ab8dc1dea | |
Andreas Eversberg | 3f77726226 |
|
@ -1 +1 @@
|
|||
1.0.0
|
||||
2.0.0
|
||||
|
|
13
configure.ac
13
configure.ac
|
@ -1,6 +1,4 @@
|
|||
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([.])
|
||||
|
@ -64,9 +62,8 @@ CFLAGS="$saved_CFLAGS"
|
|||
AC_SUBST(SYMBOL_VISIBILITY)
|
||||
|
||||
dnl Generate the output
|
||||
AM_CONFIG_HEADER(config.h)
|
||||
|
||||
PKG_CHECK_MODULES(LIBOSMOCORE, libosmocore >= 1.9.0)
|
||||
PKG_CHECK_MODULES(LIBOSMOCORE, libosmocore >= 1.6.0)
|
||||
|
||||
AC_ARG_ENABLE(sanitize,
|
||||
[AS_HELP_STRING(
|
||||
|
@ -128,8 +125,8 @@ CFLAGS=$_cflags_save
|
|||
AC_MSG_RESULT([CFLAGS="$CFLAGS"])
|
||||
AC_MSG_RESULT([CPPFLAGS="$CPPFLAGS"])
|
||||
|
||||
AC_OUTPUT(
|
||||
libosmocc.pc
|
||||
AC_CONFIG_FILES([libosmocc.pc
|
||||
include/Makefile
|
||||
src/Makefile
|
||||
Makefile)
|
||||
Makefile])
|
||||
AC_OUTPUT
|
||||
|
|
|
@ -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 *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_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_close(osmo_cc_session_media_t *media);
|
||||
|
|
|
@ -1,11 +1,22 @@
|
|||
AM_CPPFLAGS = -Wall -Wextra -g $(all_includes) -I../include
|
||||
# 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
|
||||
|
||||
lib_LTLIBRARIES = libosmocc.la
|
||||
AM_CPPFLAGS = \
|
||||
$(all_includes) \
|
||||
-I$(top_srcdir)/include \
|
||||
$(NULL)
|
||||
|
||||
AM_CFLAGS = \
|
||||
-Wall \
|
||||
$(LIBOSMOCORE_CFLAGS) \
|
||||
$(NULL)
|
||||
|
||||
lib_LTLIBRARIES = \
|
||||
libosmocc.la \
|
||||
$(NULL)
|
||||
|
||||
libosmocc_la_LDFLAGS = $(AM_LDFLAGS) \
|
||||
-no-undefined \
|
||||
$(NULL)
|
||||
libosmocc_la_LIBADD = $(COMMONLIBS)
|
||||
libosmocc_la_SOURCES = \
|
||||
message.c \
|
||||
socket.c \
|
||||
|
@ -17,4 +28,14 @@ libosmocc_la_SOURCES = \
|
|||
rtp.c \
|
||||
helper.c \
|
||||
g711.c \
|
||||
misc.c
|
||||
misc.c \
|
||||
$(NULL)
|
||||
|
||||
libosmocc_la_LDFLAGS = \
|
||||
-version-info $(LIBVERSION) \
|
||||
-no-undefined \
|
||||
$(NULL)
|
||||
|
||||
libosmocc_la_LIBADD = \
|
||||
$(LIBOSMOCORE_LIBS) \
|
||||
$(NULL)
|
||||
|
|
48
src/rtp.c
48
src/rtp.c
|
@ -354,56 +354,30 @@ pton_error:
|
|||
}
|
||||
|
||||
/* send rtp data with given codec */
|
||||
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(osmo_cc_session_codec_t *codec, uint8_t *payload, int payload_len, uint8_t marker, int inc_sequence,
|
||||
int inc_timestamp)
|
||||
{
|
||||
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 *data, int len, uint8_t marker, uint16_t tx_sequence,
|
||||
uint32_t tx_timestamp, void *priv)
|
||||
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)
|
||||
{
|
||||
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)
|
||||
|
@ -454,8 +428,6 @@ 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
|
||||
|
||||
|
@ -477,19 +449,9 @@ 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,
|
||||
data, len);
|
||||
|
||||
if (codec->decoder)
|
||||
free(data);
|
||||
payload, payload_len);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
31
src/sdp.c
31
src/sdp.c
|
@ -132,10 +132,7 @@ 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", 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");
|
||||
strncat_printf(sdp, "a=rtpmap:%u %s/%d/%d\r\n", codec->payload_type_local, codec->payload_name, codec->payload_rate, codec->payload_channels);
|
||||
}
|
||||
if (individual_send_receive) {
|
||||
if (media->send && !media->receive)
|
||||
|
@ -499,32 +496,34 @@ 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)))
|
||||
goto rtpmap_done;
|
||||
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 ((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_done;
|
||||
goto rtpmap_broken;
|
||||
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)) {
|
||||
/* 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;
|
||||
/* 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;
|
||||
}
|
||||
codec->payload_channels = atoi(word);
|
||||
LOGP(DLCC, LOGL_DEBUG, " -> (rtpmap) payload channels = %d\n", codec->payload_channels);
|
||||
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;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue