From 5c24624a45caaf455501cf184a8f9e490f6869dd Mon Sep 17 00:00:00 2001 From: Austin Sweat Date: Thu, 9 Jun 2016 11:49:11 -0400 Subject: [PATCH 1/2] Adds SPEEX codec support to RTPEndpoint. Fitted for 6.5.0 --- src/gst-plugins/commons/kmsenctreebin.c | 10 ++++++++++ src/gst-plugins/commons/kmsutils.c | 3 +++ src/server/config/SdpEndpoint.conf.json | 3 +++ src/server/implementation/objects/MediaElementImpl.cpp | 4 ++++ 4 files changed, 20 insertions(+) diff --git a/src/gst-plugins/commons/kmsenctreebin.c b/src/gst-plugins/commons/kmsenctreebin.c index 47402bff2..5cc80cb77 100644 --- a/src/gst-plugins/commons/kmsenctreebin.c +++ b/src/gst-plugins/commons/kmsenctreebin.c @@ -46,6 +46,7 @@ typedef enum X264, OPENH264, OPUS, + SPEEX, UNSUPPORTED } EncoderType; @@ -77,6 +78,8 @@ kms_enc_tree_bin_get_name_from_type (EncoderType enc_type) return "openh264"; case OPUS: return "opus"; + case SPEEX: + return "speex"; case UNSUPPORTED: default: return NULL; @@ -183,6 +186,11 @@ configure_encoder (GstElement * encoder, EncoderType type, gint target_bitrate, "perfect-timestamp", TRUE, NULL); break; } + case SPEEX: + { + g_object_set (G_OBJECT (encoder), "complexity", 4, NULL); + break; + } default: GST_DEBUG ("Codec %" GST_PTR_FORMAT " not configured because it is not supported", encoder); @@ -207,6 +215,8 @@ kms_enc_tree_bin_set_encoder_type (KmsEncTreeBin * self) self->priv->enc_type = OPENH264; } else if (g_str_has_prefix (name, "opusenc")) { self->priv->enc_type = OPUS; + } else if (g_str_has_prefix (name, "speexenc")) { + self->priv->enc_type = SPEEX; } else { self->priv->enc_type = UNSUPPORTED; } diff --git a/src/gst-plugins/commons/kmsutils.c b/src/gst-plugins/commons/kmsutils.c index b39c8a982..e97ae03db 100644 --- a/src/gst-plugins/commons/kmsutils.c +++ b/src/gst-plugins/commons/kmsutils.c @@ -216,6 +216,9 @@ kms_utils_get_caps_codec_name_from_sdp (const gchar * codec_name) if (g_ascii_strcasecmp (VP8_ENCONDING_NAME, codec_name) == 0) { return "VP8"; } + if (g_ascii_strcasecmp ("speex", codec_name) == 0) { + return "SPEEX"; + } return codec_name; } diff --git a/src/server/config/SdpEndpoint.conf.json b/src/server/config/SdpEndpoint.conf.json index 72647ef98..117df728b 100644 --- a/src/server/config/SdpEndpoint.conf.json +++ b/src/server/config/SdpEndpoint.conf.json @@ -19,6 +19,9 @@ }, { "name" : "AMR/8000" + }, + { + "name" : "speex/16000" } ], "videoCodecs" : [ diff --git a/src/server/implementation/objects/MediaElementImpl.cpp b/src/server/implementation/objects/MediaElementImpl.cpp index 5d7daabc1..e41b0ef57 100644 --- a/src/server/implementation/objects/MediaElementImpl.cpp +++ b/src/server/implementation/objects/MediaElementImpl.cpp @@ -1012,6 +1012,10 @@ void MediaElementImpl::setAudioFormat (std::shared_ptr caps) str_caps = "audio/x-raw"; break; + case AudioCodec::SPEEX: + str_caps = "audio/x-speex"; + break; + default: throw KurentoException (MEDIA_OBJECT_ILLEGAL_PARAM_ERROR, "Invalid parameter provided: " + codec->getString() ); From 7e72b42d83d9ca52218c7025d0d7c2f5f2f88f97 Mon Sep 17 00:00:00 2001 From: Austin Sweat Date: Thu, 9 Jun 2016 12:39:41 -0400 Subject: [PATCH 2/2] Adds SPEEX to AudioCodec class. --- src/gst-plugins/commons/constants.h | 1 + src/gst-plugins/commons/kmsutils.c | 2 +- src/server/interface/core.kmd.json | 3 ++- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/gst-plugins/commons/constants.h b/src/gst-plugins/commons/constants.h index fc2b388a4..6804c7613 100644 --- a/src/gst-plugins/commons/constants.h +++ b/src/gst-plugins/commons/constants.h @@ -76,6 +76,7 @@ G_BEGIN_DECLS /* RTP enconding names */ #define OPUS_ENCONDING_NAME "OPUS" #define VP8_ENCONDING_NAME "VP8" +#define SPEEX_ENCONDING_NAME "speex" G_END_DECLS #endif /* __KMS_CONSTANTS_H__ */ diff --git a/src/gst-plugins/commons/kmsutils.c b/src/gst-plugins/commons/kmsutils.c index e97ae03db..f52fb5f44 100644 --- a/src/gst-plugins/commons/kmsutils.c +++ b/src/gst-plugins/commons/kmsutils.c @@ -216,7 +216,7 @@ kms_utils_get_caps_codec_name_from_sdp (const gchar * codec_name) if (g_ascii_strcasecmp (VP8_ENCONDING_NAME, codec_name) == 0) { return "VP8"; } - if (g_ascii_strcasecmp ("speex", codec_name) == 0) { + if (g_ascii_strcasecmp (SPEEX_ENCONDING_NAME, codec_name) == 0) { return "SPEEX"; } diff --git a/src/server/interface/core.kmd.json b/src/server/interface/core.kmd.json index 145a55a07..4e70dab6c 100644 --- a/src/server/interface/core.kmd.json +++ b/src/server/interface/core.kmd.json @@ -989,7 +989,8 @@ "values": [ "OPUS", "PCMU", - "RAW" + "RAW", + "SPEEX" ], "name": "AudioCodec", "doc": "Codec used for transmission of audio."