Browse Source

TT#31950 add compile-time switch to disable transcoding features

Change-Id: Ice0c019b8a07d4c941d14f47021dbb7b0eb68d3c
changes/26/18926/5
Richard Fuchs 8 years ago
parent
commit
10c852b204
6 changed files with 106 additions and 23 deletions
  1. +1
    -0
      daemon/.ycm_extra_conf.py
  2. +13
    -5
      daemon/Makefile
  3. +4
    -0
      daemon/call_interfaces.c
  4. +49
    -15
      daemon/codec.c
  5. +11
    -1
      daemon/codec.h
  6. +28
    -2
      lib/codeclib.h

+ 1
- 0
daemon/.ycm_extra_conf.py View File

@ -28,6 +28,7 @@ flags = [
'-DRTPENGINE_VERSION="dummy"',
'-DRE_PLUGIN_DIR="/usr/lib/rtpengine"',
'-DWITH_IPTABLES_OPTION',
'-DWITH_TRANSCODING',
'-O2',
'-fstack-protector',
'--param=ssp-buffer-size=4',


+ 13
- 5
daemon/Makefile View File

@ -1,6 +1,7 @@
TARGET= rtpengine
with_iptables_option ?= yes
with_transcoding ?= yes
CFLAGS= -g -Wall -pthread -fno-strict-aliasing
CFLAGS+= -std=c99
@ -16,14 +17,20 @@ CFLAGS+= `pkg-config xmlrpc_util --cflags 2> /dev/null`
CFLAGS+= `pkg-config --cflags json-glib-1.0`
ifeq ($(with_iptables_option),yes)
CFLAGS+= `pkg-config --cflags libiptc`
CFLAGS+= -DWITH_IPTABLES_OPTION
endif
CFLAGS+= -I. -I../kernel-module/ -I../lib/
CFLAGS+= -D_GNU_SOURCE
ifeq ($(with_transcoding),yes)
CFLAGS+= `pkg-config --cflags libavcodec`
CFLAGS+= `pkg-config --cflags libavformat`
CFLAGS+= `pkg-config --cflags libavutil`
CFLAGS+= `pkg-config --cflags libavresample`
CFLAGS+= `pkg-config --cflags libavfilter`
CFLAGS+= -DWITH_TRANSCODING
else
CFLAGS+= -DWITHOUT_CODECLIB
endif
CFLAGS+= -DRE_PLUGIN_DIR="\"/usr/lib/rtpengine\""
@ -32,10 +39,6 @@ CFLAGS+= -DRE_PLUGIN_DIR="\"/usr/lib/rtpengine\""
#CFLAGS+= -DTERMINATE_SDP_AT_BLANK_LINE
#CFLAGS+= -DSTRICT_SDES_KEY_LIFETIME
ifeq ($(with_iptables_option),yes)
CFLAGS+= -DWITH_IPTABLES_OPTION
endif
LDFLAGS= -lm
LDFLAGS+= `pkg-config --libs glib-2.0`
LDFLAGS+= `pkg-config --libs gthread-2.0`
@ -54,11 +57,13 @@ LDFLAGS+= `pkg-config --libs json-glib-1.0`
ifeq ($(with_iptables_option),yes)
LDFLAGS+= `pkg-config --libs libiptc`
endif
ifeq ($(with_transcoding),yes)
LDFLAGS+= `pkg-config --libs libavcodec`
LDFLAGS+= `pkg-config --libs libavformat`
LDFLAGS+= `pkg-config --libs libavutil`
LDFLAGS+= `pkg-config --libs libavresample`
LDFLAGS+= `pkg-config --libs libavfilter`
endif
include ../lib/lib.Makefile
@ -67,7 +72,10 @@ SRCS= main.c kernel.c poller.c aux.c control_tcp.c streambuf.c call.c control_u
crypto.c rtp.c call_interfaces.c dtls.c log.c cli.c graphite.c ice.c socket.c \
media_socket.c homer.c recording.c statistics.c cdr.c ssrc.c iptables.c tcp_listener.c \
codec.c
LIBSRCS= loglib.c auxlib.c rtplib.c codeclib.c resample.c str.c
LIBSRCS= loglib.c auxlib.c rtplib.c str.c
ifeq ($(with_transcoding),yes)
LIBSRCS+= codeclib.c resample.c
endif
OBJS= $(SRCS:.c=.o) $(LIBSRCS:.c=.o)


+ 4
- 0
daemon/call_interfaces.c View File

@ -618,11 +618,13 @@ static void call_ng_flags_flags(struct sdp_ng_flags *out, str *s, void *dummy) {
return;
if (call_ng_flags_prefix(out, s, "codec-offer-", call_ng_flags_codec_list, &out->codec_offer))
return;
#ifdef WITH_TRANSCODING
if (call_ng_flags_prefix(out, s, "transcode-", call_ng_flags_codec_list, &out->codec_transcode))
return;
if (call_ng_flags_prefix(out, s, "codec-transcode-", call_ng_flags_codec_list,
&out->codec_transcode))
return;
#endif
ilog(LOG_WARN, "Unknown flag encountered: '" STR_FORMAT "'",
STR_FMT(s));
@ -699,7 +701,9 @@ static void call_ng_process_flags(struct sdp_ng_flags *out, bencode_item_t *inpu
/* XXX module still needs to support these */
call_ng_flags_list(out, dict, "strip", call_ng_flags_codec_ht, out->codec_strip);
call_ng_flags_list(out, dict, "offer", call_ng_flags_codec_list, &out->codec_offer);
#ifdef WITH_TRANSCODING
call_ng_flags_list(out, dict, "transcode", call_ng_flags_codec_list, &out->codec_transcode);
#endif
}
}
static void call_ng_free_flags(struct sdp_ng_flags *flags) {


+ 49
- 15
daemon/codec.c View File

@ -11,6 +11,24 @@
static codec_handler_func handler_func_passthrough;
static struct rtp_payload_type *__rtp_payload_type_copy(const struct rtp_payload_type *pt);
static void __rtp_payload_type_dup(struct call *call, struct rtp_payload_type *pt);
static void __rtp_payload_type_add_name(GHashTable *, struct rtp_payload_type *pt);
static struct codec_handler codec_handler_stub = {
.source_pt.payload_type = -1,
.func = handler_func_passthrough,
};
#ifdef WITH_TRANSCODING
struct codec_ssrc_handler {
struct ssrc_entry h; // must be first
struct codec_handler *handler;
@ -32,7 +50,6 @@ struct transcode_packet {
};
static codec_handler_func handler_func_passthrough;
static codec_handler_func handler_func_passthrough_ssrc;
static codec_handler_func handler_func_transcode;
@ -41,15 +58,7 @@ static void __ssrc_handler_free(struct codec_ssrc_handler *p);
static void __transcode_packet_free(struct transcode_packet *);
static struct rtp_payload_type *__rtp_payload_type_copy(const struct rtp_payload_type *pt);
static void __rtp_payload_type_dup(struct call *call, struct rtp_payload_type *pt);
static void __rtp_payload_type_add_name(GHashTable *, struct rtp_payload_type *pt);
static struct codec_handler codec_handler_stub = {
.source_pt.payload_type = -1,
.func = handler_func_passthrough,
};
static struct codec_handler codec_handler_stub_ssrc = {
.source_pt.payload_type = -1,
.func = handler_func_passthrough_ssrc,
@ -365,8 +374,14 @@ next:
}
}
#endif
// call must be locked in R
struct codec_handler *codec_handler_get(struct call_media *m, int payload_type) {
#ifdef WITH_TRANSCODING
struct codec_handler *h;
if (payload_type < 0)
@ -376,6 +391,8 @@ struct codec_handler *codec_handler_get(struct call_media *m, int payload_type)
if (G_LIKELY(G_LIKELY(h) && G_LIKELY(h->source_pt.payload_type == payload_type)))
return h;
if (G_UNLIKELY(!m->codec_handlers))
goto out;
h = g_hash_table_lookup(m->codec_handlers, &payload_type);
if (!h)
goto out;
@ -387,6 +404,7 @@ struct codec_handler *codec_handler_get(struct call_media *m, int payload_type)
out:
if (MEDIA_ISSET(m, TRANSCODE))
return &codec_handler_stub_ssrc;
#endif
return &codec_handler_stub;
}
@ -409,6 +427,23 @@ static int handler_func_passthrough(struct codec_handler *h, struct call_media *
codec_add_raw_packet(mp);
return 0;
}
void codec_packet_free(void *pp) {
struct codec_packet *p = pp;
if (p->free_func)
p->free_func(p->s.s);
g_slice_free1(sizeof(*p), p);
}
#ifdef WITH_TRANSCODING
static int handler_func_passthrough_ssrc(struct codec_handler *h, struct call_media *media,
struct media_packet *mp)
{
@ -641,12 +676,8 @@ static int handler_func_transcode(struct codec_handler *h, struct call_media *me
return 0;
}
void codec_packet_free(void *pp) {
struct codec_packet *p = pp;
if (p->free_func)
p->free_func(p->s.s);
g_slice_free1(sizeof(*p), p);
}
@ -761,6 +792,7 @@ static struct rtp_payload_type *codec_add_payload_type(const str *codec, struct
#endif
@ -881,6 +913,7 @@ void codec_rtp_payload_types(struct call_media *media, struct call_media *other_
__revert_codec_strip(removed, codec, media, other_media);
}
#ifdef WITH_TRANSCODING
// add transcode codecs
for (GList *l = transcode ? transcode->head : NULL; l; l = l->next) {
str *codec = l->data;
@ -905,6 +938,7 @@ void codec_rtp_payload_types(struct call_media *media, struct call_media *other_
STR_FMT(&pt->encoding_with_params), pt->payload_type);
__rtp_payload_type_add_recv(media, pt);
}
#endif
g_hash_table_destroy(removed);
}

+ 11
- 1
daemon/codec.h View File

@ -32,7 +32,6 @@ struct codec_packet {
};
void codec_handlers_update(struct call_media *receiver, struct call_media *sink);
struct codec_handler *codec_handler_get(struct call_media *, int payload_type);
void codec_handlers_free(struct call_media *);
@ -45,5 +44,16 @@ void codec_rtp_payload_types(struct call_media *media, struct call_media *other_
#ifdef WITH_TRANSCODING
void codec_handlers_update(struct call_media *receiver, struct call_media *sink);
#else
INLINE void codec_handlers_update(struct call_media *receiver, struct call_media *sink) { }
#endif
#endif

+ 28
- 2
lib/codeclib.h View File

@ -2,6 +2,14 @@
#define __CODECLIB_H__
struct codec_def_s;
typedef struct codec_def_s codec_def_t;
#ifndef WITHOUT_CODECLIB
#include <libavresample/avresample.h>
#include <libavcodec/avcodec.h>
#include <libavutil/audio_fifo.h>
@ -9,7 +17,6 @@
struct codec_def_s;
struct decoder_s;
struct encoder_s;
struct format_s;
@ -18,7 +25,6 @@ struct seq_packet_s;
struct packet_sequencer_s;
struct rtp_payload_type;
typedef struct codec_def_s codec_def_t;
typedef struct decoder_s decoder_t;
typedef struct encoder_s encoder_t;
typedef struct format_s format_t;
@ -166,4 +172,24 @@ INLINE void format_init(format_t *f) {
}
#else
// stubs
enum media_type {
MT_INVALID = -1,
};
struct codec_def_s {
};
INLINE void codeclib_init(void) { }
INLINE enum media_type codec_get_type(const str *type) {
return -1;
}
INLINE const codec_def_t *codec_find(const str *name, enum media_type type) {
return NULL;
}
#endif
#endif

Loading…
Cancel
Save