Philipp Hörist pushed to branch master at gajim / gajim

Commits:

1 changed file:

Changes:

  • gajim/common/jingle_rtp.py
    ... ... @@ -301,8 +301,9 @@ class JingleRTPContent(JingleContent):
    301 301
                 attrs = {
    
    302 302
                     'name': codec.encoding_name,
    
    303 303
                     'id': codec.id,
    
    304
    -                'channels': codec.channels
    
    305 304
                 }
    
    305
    +            if codec.channels > 0:
    
    306
    +                attrs['channels'] = codec.channels
    
    306 307
                 if codec.clock_rate:
    
    307 308
                     attrs['clockrate'] = codec.clock_rate
    
    308 309
                 if codec.optional_params:
    
    ... ... @@ -350,18 +351,35 @@ class JingleAudio(JingleRTPContent):
    350 351
         def setup_stream(self):
    
    351 352
             JingleRTPContent.setup_stream(self, self._on_src_pad_added)
    
    352 353
     
    
    353
    -        # Configure SPEEX
    
    354
    -        # Workaround for psi (not needed since rev
    
    355
    -        # 147aedcea39b43402fe64c533d1866a25449888a):
    
    356
    -        #  place 16kHz before 8kHz, as buggy psi versions will take in
    
    357
    -        #  account only the first codec
    
    358
    -
    
    359
    -        codecs = [
    
    354
    +        # list of codecs that are explicitly allowed
    
    355
    +        allow_codecs = [
    
    356
    +            Farstream.Codec.new(Farstream.CODEC_ID_ANY, 'OPUS',
    
    357
    +                                Farstream.MediaType.AUDIO, 48000),
    
    358
    +            Farstream.Codec.new(Farstream.CODEC_ID_ANY, 'SPEEX',
    
    359
    +                                Farstream.MediaType.AUDIO, 32000),
    
    360 360
                 Farstream.Codec.new(Farstream.CODEC_ID_ANY, 'SPEEX',
    
    361 361
                                     Farstream.MediaType.AUDIO, 16000),
    
    362
    +            Farstream.Codec.new(Farstream.CODEC_ID_ANY, 'G722',
    
    363
    +                                Farstream.MediaType.AUDIO, 8000),
    
    362 364
                 Farstream.Codec.new(Farstream.CODEC_ID_ANY, 'SPEEX',
    
    365
    +                                Farstream.MediaType.AUDIO, 8000),
    
    366
    +            Farstream.Codec.new(Farstream.CODEC_ID_ANY, 'PCMA',
    
    367
    +                                Farstream.MediaType.AUDIO, 8000),
    
    368
    +            Farstream.Codec.new(Farstream.CODEC_ID_ANY, 'PCMU',
    
    363 369
                                     Farstream.MediaType.AUDIO, 8000)]
    
    364
    -        self.p2psession.set_codec_preferences(codecs)
    
    370
    +
    
    371
    +        # disable all other codecs
    
    372
    +        disable_codecs = []
    
    373
    +        codecs_without_config = self.p2psession.props.codecs_without_config
    
    374
    +        allowed_encoding_names = [c.encoding_name for c in allow_codecs] + ['telephone-event']
    
    375
    +        for codec in codecs_without_config:
    
    376
    +            if codec.encoding_name not in allowed_encoding_names:
    
    377
    +                disable_codecs.append(Farstream.Codec.new(Farstream.CODEC_ID_DISABLE,
    
    378
    +                                                          codec.encoding_name,
    
    379
    +                                                          Farstream.MediaType.AUDIO,
    
    380
    +                                                          codec.clock_rate))
    
    381
    +
    
    382
    +        self.p2psession.set_codec_preferences(allow_codecs + disable_codecs)
    
    365 383
     
    
    366 384
             # the local parts
    
    367 385
             # TODO: Add queues?