Jingle Audio: Update codecs

Fixes #9535
This commit is contained in:
streaps 2019-01-10 22:28:00 +01:00 committed by Philipp Hörist
parent 911674d580
commit 88439091b0
1 changed files with 27 additions and 9 deletions

View File

@ -301,8 +301,9 @@ class JingleRTPContent(JingleContent):
attrs = { attrs = {
'name': codec.encoding_name, 'name': codec.encoding_name,
'id': codec.id, 'id': codec.id,
'channels': codec.channels
} }
if codec.channels > 0:
attrs['channels'] = codec.channels
if codec.clock_rate: if codec.clock_rate:
attrs['clockrate'] = codec.clock_rate attrs['clockrate'] = codec.clock_rate
if codec.optional_params: if codec.optional_params:
@ -350,18 +351,35 @@ class JingleAudio(JingleRTPContent):
def setup_stream(self): def setup_stream(self):
JingleRTPContent.setup_stream(self, self._on_src_pad_added) JingleRTPContent.setup_stream(self, self._on_src_pad_added)
# Configure SPEEX # list of codecs that are explicitly allowed
# Workaround for psi (not needed since rev allow_codecs = [
# 147aedcea39b43402fe64c533d1866a25449888a): Farstream.Codec.new(Farstream.CODEC_ID_ANY, 'OPUS',
# place 16kHz before 8kHz, as buggy psi versions will take in Farstream.MediaType.AUDIO, 48000),
# account only the first codec Farstream.Codec.new(Farstream.CODEC_ID_ANY, 'SPEEX',
Farstream.MediaType.AUDIO, 32000),
codecs = [
Farstream.Codec.new(Farstream.CODEC_ID_ANY, 'SPEEX', Farstream.Codec.new(Farstream.CODEC_ID_ANY, 'SPEEX',
Farstream.MediaType.AUDIO, 16000), Farstream.MediaType.AUDIO, 16000),
Farstream.Codec.new(Farstream.CODEC_ID_ANY, 'G722',
Farstream.MediaType.AUDIO, 8000),
Farstream.Codec.new(Farstream.CODEC_ID_ANY, 'SPEEX', Farstream.Codec.new(Farstream.CODEC_ID_ANY, 'SPEEX',
Farstream.MediaType.AUDIO, 8000),
Farstream.Codec.new(Farstream.CODEC_ID_ANY, 'PCMA',
Farstream.MediaType.AUDIO, 8000),
Farstream.Codec.new(Farstream.CODEC_ID_ANY, 'PCMU',
Farstream.MediaType.AUDIO, 8000)] Farstream.MediaType.AUDIO, 8000)]
self.p2psession.set_codec_preferences(codecs)
# disable all other codecs
disable_codecs = []
codecs_without_config = self.p2psession.props.codecs_without_config
allowed_encoding_names = [c.encoding_name for c in allow_codecs] + ['telephone-event']
for codec in codecs_without_config:
if codec.encoding_name not in allowed_encoding_names:
disable_codecs.append(Farstream.Codec.new(Farstream.CODEC_ID_DISABLE,
codec.encoding_name,
Farstream.MediaType.AUDIO,
codec.clock_rate))
self.p2psession.set_codec_preferences(allow_codecs + disable_codecs)
# the local parts # the local parts
# TODO: Add queues? # TODO: Add queues?