TT#36301 add `always-transcode` flag

closes #527

Change-Id: I0d8192cf93c49823f35a6307ccd8c77842fb51dd
changes/96/21196/7
Richard Fuchs 8 years ago
parent 5c3d39748b
commit 2f5d792aae

@ -1176,6 +1176,18 @@ Optionally included keys are:
attribute already present in the SDP, it will leave the SDP untouched and not process attribute already present in the SDP, it will leave the SDP untouched and not process
the message. the message.
- `always transcode`
When transcoding is in use, *rtpengine* will normally match up the codecs offered with
one side with the codecs offered by the other side, and engage the transcoding engine
only for codec pairs that are not supported by both sides. With this flag present,
*rtpengine* will skip the codec match-up routine and always trancode any received media
to the first (highest priority) codec offered by the other side that is supported for
transcoding. Using this flag engages the transcoding engine even if no other
`transcoding` flags are present. Unlike other transcoding options, this one is directional,
which means that it's applied only to the one side doing the signalling that is being
handled (i.e. the side doing the `offer` or the `answer`).
* `replace` * `replace`
Similar to the `flags` list. Controls which parts of the SDP body should be rewritten. Similar to the `flags` list. Controls which parts of the SDP body should be rewritten.

@ -1653,7 +1653,7 @@ int monologue_offer_answer(struct call_monologue *other_ml, GQueue *streams,
codec_rtp_payload_types(media, other_media, &sp->rtp_payload_types, codec_rtp_payload_types(media, other_media, &sp->rtp_payload_types,
flags->codec_strip, &flags->codec_offer, &flags->codec_transcode, flags->codec_strip, &flags->codec_offer, &flags->codec_transcode,
flags->codec_mask); flags->codec_mask);
codec_handlers_update(media, other_media); codec_handlers_update(media, other_media, flags);
/* send and recv are from our POV */ /* send and recv are from our POV */
bf_copy_same(&media->media_flags, &sp->sp_flags, bf_copy_same(&media->media_flags, &sp->sp_flags,

@ -616,6 +616,8 @@ static void call_ng_flags_flags(struct sdp_ng_flags *out, str *s, void *dummy) {
out->no_rtcp_attr = 1; out->no_rtcp_attr = 1;
else if (!str_cmp(s, "loop-protect")) else if (!str_cmp(s, "loop-protect"))
out->loop_protect = 1; out->loop_protect = 1;
else if (!str_cmp(s, "always-transcode"))
out->always_transcode = 1;
else { else {
// handle values aliases from other dictionaries // handle values aliases from other dictionaries
if (call_ng_flags_prefix(out, s, "SDES-", ng_sdes_option, NULL)) if (call_ng_flags_prefix(out, s, "SDES-", ng_sdes_option, NULL))

@ -59,6 +59,7 @@ struct sdp_ng_flags {
reset:1, reset:1,
record_call:1, record_call:1,
loop_protect:1, loop_protect:1,
always_transcode:1,
supports_load_limit:1, supports_load_limit:1,
dtls_off:1, dtls_off:1,
sdes_off:1, sdes_off:1,

@ -9,6 +9,7 @@
#include "codeclib.h" #include "codeclib.h"
#include "ssrc.h" #include "ssrc.h"
#include "rtcp.h" #include "rtcp.h"
#include "call_interfaces.h"
@ -158,7 +159,9 @@ static GList *__delete_receiver_codec(struct call_media *receiver, GList *link)
} }
// call must be locked in W // call must be locked in W
void codec_handlers_update(struct call_media *receiver, struct call_media *sink) { void codec_handlers_update(struct call_media *receiver, struct call_media *sink,
const struct sdp_ng_flags *flags)
{
if (!receiver->codec_handlers) if (!receiver->codec_handlers)
receiver->codec_handlers = g_hash_table_new_full(g_int_hash, g_int_equal, receiver->codec_handlers = g_hash_table_new_full(g_int_hash, g_int_equal,
NULL, __codec_handler_free); NULL, __codec_handler_free);
@ -302,7 +305,9 @@ void codec_handlers_update(struct call_media *receiver, struct call_media *sink)
// in case of ptime mismatch, we transcode // in case of ptime mismatch, we transcode
//struct rtp_payload_type *dest_pt = g_hash_table_lookup(sink->codec_names_send, &pt->encoding); //struct rtp_payload_type *dest_pt = g_hash_table_lookup(sink->codec_names_send, &pt->encoding);
GQueue *dest_codecs = g_hash_table_lookup(sink->codec_names_send, &pt->encoding); GQueue *dest_codecs = NULL;
if (!flags || !flags->always_transcode)
dest_codecs = g_hash_table_lookup(sink->codec_names_send, &pt->encoding);
if (dest_codecs) { if (dest_codecs) {
// the sink supports this codec - check offered formats // the sink supports this codec - check offered formats
dest_pt = NULL; dest_pt = NULL;

@ -13,6 +13,7 @@ struct call_media;
struct codec_handler; struct codec_handler;
struct media_packet; struct media_packet;
struct ssrc_hash; struct ssrc_hash;
struct sdp_ng_flags;
typedef int codec_handler_func(struct codec_handler *, struct call_media *, struct media_packet *); typedef int codec_handler_func(struct codec_handler *, struct call_media *, struct media_packet *);
@ -56,7 +57,7 @@ void __rtp_payload_type_add_send(struct call_media *other_media, struct rtp_payl
#ifdef WITH_TRANSCODING #ifdef WITH_TRANSCODING
void codec_handlers_update(struct call_media *receiver, struct call_media *sink); void codec_handlers_update(struct call_media *receiver, struct call_media *sink, const struct sdp_ng_flags *);
#else #else

@ -1413,7 +1413,7 @@ static int json_link_medias(struct call *c, struct redis_list *medias,
for (GList *l = other_ml->medias.head; l; l = l->next) { for (GList *l = other_ml->medias.head; l; l = l->next) {
struct call_media *other_m = l->data; struct call_media *other_m = l->data;
if (other_m->index == med->index) { if (other_m->index == med->index) {
codec_handlers_update(med, other_m); codec_handlers_update(med, other_m, NULL);
break; break;
} }
} }

@ -56,6 +56,7 @@ GetOptions(
'flags=s@' => \$options{'flags'}, 'flags=s@' => \$options{'flags'},
'supports=s@' => \$options{'supports'}, 'supports=s@' => \$options{'supports'},
'xmlrpc-callback=s' => \$options{'xmlrpc-callback'}, 'xmlrpc-callback=s' => \$options{'xmlrpc-callback'},
'always-transcode' => \$options{'always transcode'},
) or die; ) or die;
my $cmd = shift(@ARGV) or die; my $cmd = shift(@ARGV) or die;
@ -68,7 +69,7 @@ for my $x (split(/,/, 'from-tag,to-tag,call-id,transport protocol,media address,
for my $x (split(/,/, 'TOS,delete-delay')) { for my $x (split(/,/, 'TOS,delete-delay')) {
defined($options{$x}) and $packet{$x} = $options{$x}; defined($options{$x}) and $packet{$x} = $options{$x};
} }
for my $x (split(/,/, 'trust address,symmetric,asymmetric,force,strict source,media handover,sip source address,reset,port latching,no rtcp attribute,loop protect,record call')) { for my $x (split(/,/, 'trust address,symmetric,asymmetric,force,strict source,media handover,sip source address,reset,port latching,no rtcp attribute,loop protect,record call,always transcode')) {
defined($options{$x}) and push(@{$packet{flags}}, $x); defined($options{$x}) and push(@{$packet{flags}}, $x);
} }
for my $x (split(/,/, 'origin,session connection')) { for my $x (split(/,/, 'origin,session connection')) {

Loading…
Cancel
Save