[jitsi-dev] [patch] Encoding configuration for specific accounts


#1

Hello,

The attached patch (against r9809) adds support for configuring audio and video
encodings for individual (Jabber and SIP) accounts. The motivation for this
feature is that sometimes we want to disable a specific codec for a specific
account, or we want to make the SDP list of formats shorter (again for a
specific account only).

About the user interface:
An "Encodings" panel is added to the Jabber and SIP account registration
wizards. It contains two tables like the ones under the main "Audio" and
"Video" configuration. If the wizard is finished, the preferences in those
tables are written to the account properties. On account creation, or when
modifying an account without such properties set, the tables are populated with
the "global" preferences. There is a "Reset" button that does the same.

There is an "override encodings" checkbox, that specifies whether these local
preferences should be used instead of the "global" ones. At the moment the
tables are active even when the checkbox is unchecked, but maybe it would be
better to make them inactive. What do you think?

Even if the checkbox is not set, the preferences in the tables are saved/loaded
(this allows to quickly turn on/off the option without losing the preferences).

When a call is made or accepted, the "override encodings" setting is checked
for the account. If it's set, the account settings are used. If it's not set,
the "global" settings are used.

I encountered a bug in the current encodings configuration, which is somewhat
more exposed with this patch. When one of the disabled formats is re-enabled,
its place in the table does not change (but it's priority does). Once Jitsi is
restarted it is moved to a new spot in the table. The same now happens
in the account configuration, except it does not require a restart of Jitsi,
only finishing the wizard. I don't know how to fix this at the moment, but
I intend to work on it next.

I understand you might be reluctant to commit this, since it changes alot of
things, and in the least requires a careful overview by someone familiar with
the code. I'll be happy to answer any questions and make necessarry updates.

Here are some explanations about the changes:

Changes to libjitsi:

Split the EncodingConfiguration class into
service.neomedia.codec.EncodingConfiguration and
impl.neomedia.codec.EncodingConfigurationImpl. The one in service
maintains a list of available MediaFormat's and their priorities. The
implementation takes care of registering codecs and packages with JMF and
initializing the default format preferences. It also knows how to load the
"global" configuration (be reading the properties under
net.java.sip.communicator.impl.neomedia.codec.EncodingConfiguration).

There's an important semantic change: the EncodingConfigurationImpl constructor
does *not* load any configuration, it only sets the default values. This means
that the instance that the MediaService maintains now contains all available
formats, and not only the ones enabled in the "global" configuration as it
previously did. The MediaService now provides a getNewEncodingConfiguration()
method that returns a new instance.

Because of that change MediaDevice#getSupportedFormats() now returns all
supported formats (including those disabled in configuration). The
getSupportedFormats(QualityPreset, QualityPreset, EncodingConfiguration) method
allows a custom configuration to be used.

Changes to trunk:

The two lines changed in AccountManager allow for properties with a
"." in them to
be stored for an account (e.g.
"net.java.sip.communicator.impl.protocol.sip.acc1344934919199.Encodings.speex/8000=0").

The net.java.sip.communicator.util.plugin.wizard package was added to contain
utility classes shared between plugins, and the SecurityPanel and
SecurityAccountRegistration classes were moved there, since they are used in
both Jabber and SIP account registration wizards.

In service.protocol.media.CallPeerMediaHandler, a
getLocallySupportedFormats(MediaDevice) method was added. It is a wrapper
around MediaDevice.getSupportedFormats, that takes into account the encodings
configured for the account in use. Implementations were updated to use it
instead of directly calling MediaDevice.getSupportedFormats() (that now returns
all supported formats due to the changes explained above).

Boris

encodings-libjitsi.patch (73 KB)

encodings-trunk.patch (169 KB)


#2

Hello again,

Attached is a version of the patch against r9839.

Boris

encodings-r9839-libjitsi.patch (73 KB)

encodings-r9839-trunk.patch (190 KB)


#3

Hey Boris,

People have been asking for this one for quite a while now and I am sure
that many would be happy to here that it's now applied, committed
(r9847) and acked!

Thanks for the great contributions that you've been making!

Emil

···

On 23.08.12, 14:32, Boris Grozev wrote:

Hello,

The attached patch (against r9809) adds support for configuring audio and video
encodings for individual (Jabber and SIP) accounts. The motivation for this
feature is that sometimes we want to disable a specific codec for a specific
account, or we want to make the SDP list of formats shorter (again for a
specific account only).

About the user interface:
An "Encodings" panel is added to the Jabber and SIP account registration
wizards. It contains two tables like the ones under the main "Audio" and
"Video" configuration. If the wizard is finished, the preferences in those
tables are written to the account properties. On account creation, or when
modifying an account without such properties set, the tables are populated with
the "global" preferences. There is a "Reset" button that does the same.

There is an "override encodings" checkbox, that specifies whether these local
preferences should be used instead of the "global" ones. At the moment the
tables are active even when the checkbox is unchecked, but maybe it would be
better to make them inactive. What do you think?

Even if the checkbox is not set, the preferences in the tables are saved/loaded
(this allows to quickly turn on/off the option without losing the preferences).

When a call is made or accepted, the "override encodings" setting is checked
for the account. If it's set, the account settings are used. If it's not set,
the "global" settings are used.

I encountered a bug in the current encodings configuration, which is somewhat
more exposed with this patch. When one of the disabled formats is re-enabled,
its place in the table does not change (but it's priority does). Once Jitsi is
restarted it is moved to a new spot in the table. The same now happens
in the account configuration, except it does not require a restart of Jitsi,
only finishing the wizard. I don't know how to fix this at the moment, but
I intend to work on it next.

I understand you might be reluctant to commit this, since it changes alot of
things, and in the least requires a careful overview by someone familiar with
the code. I'll be happy to answer any questions and make necessarry updates.

Here are some explanations about the changes:

Changes to libjitsi:

Split the EncodingConfiguration class into
service.neomedia.codec.EncodingConfiguration and
impl.neomedia.codec.EncodingConfigurationImpl. The one in service
maintains a list of available MediaFormat's and their priorities. The
implementation takes care of registering codecs and packages with JMF and
initializing the default format preferences. It also knows how to load the
"global" configuration (be reading the properties under
net.java.sip.communicator.impl.neomedia.codec.EncodingConfiguration).

There's an important semantic change: the EncodingConfigurationImpl constructor
does *not* load any configuration, it only sets the default values. This means
that the instance that the MediaService maintains now contains all available
formats, and not only the ones enabled in the "global" configuration as it
previously did. The MediaService now provides a getNewEncodingConfiguration()
method that returns a new instance.

Because of that change MediaDevice#getSupportedFormats() now returns all
supported formats (including those disabled in configuration). The
getSupportedFormats(QualityPreset, QualityPreset, EncodingConfiguration) method
allows a custom configuration to be used.

Changes to trunk:

The two lines changed in AccountManager allow for properties with a
"." in them to
be stored for an account (e.g.
"net.java.sip.communicator.impl.protocol.sip.acc1344934919199.Encodings.speex/8000=0").

The net.java.sip.communicator.util.plugin.wizard package was added to contain
utility classes shared between plugins, and the SecurityPanel and
SecurityAccountRegistration classes were moved there, since they are used in
both Jabber and SIP account registration wizards.

In service.protocol.media.CallPeerMediaHandler, a
getLocallySupportedFormats(MediaDevice) method was added. It is a wrapper
around MediaDevice.getSupportedFormats, that takes into account the encodings
configured for the account in use. Implementations were updated to use it
instead of directly calling MediaDevice.getSupportedFormats() (that now returns
all supported formats due to the changes explained above).

Boris

--
Emil Ivov, Ph.D. 67000 Strasbourg,
Project Lead France
Jitsi
emcho@jitsi.org PHONE: +33.1.77.62.43.30
http://jitsi.org FAX: +33.1.77.62.47.31


#4

Hello,

Hey Boris,

People have been asking for this one for quite a while now and I am sure
that many would be happy to here that it's now applied, committed
(r9847) and acked!

Thank you for going over this and committing it. Unfortunately I seem to
have missed something and introduced a bug that makes calls fail when using
codecs that are disabled by default (SILK/8000, SILK/12000 and G729).

The problem is that MediaFormatFactory.createFormat() fails to create a
format unless its one of the formats enabled in the EncodingConfiguration
instance it gets from the media service. With multiple configurations now
possible, and just a default one in MediaService this creates a problem.

Attached is a fix that makes it use all available formats, instead of just
the enabled ones.

Boris

MediaFormatFactoryImpl.patch (1.05 KB)

···

On Thu, Sep 13, 2012 at 6:50 PM, Emil Ivov <emcho@jitsi.org> wrote:


#5

Hey Boris,

···

On 16.09.12, 12:22, Boris Grozev wrote:

Hello,

On Thu, Sep 13, 2012 at 6:50 PM, Emil Ivov <emcho@jitsi.org > <mailto:emcho@jitsi.org>> wrote:

    Hey Boris,

    People have been asking for this one for quite a while now and I am sure
    that many would be happy to here that it's now applied, committed
    (r9847) and acked!

Thank you for going over this and committing it. Unfortunately I seem to
have missed something and introduced a bug that makes calls fail when
using codecs that are disabled by default (SILK/8000, SILK/12000 and G729).

The problem is that MediaFormatFactory.createFormat() fails to create a
format unless its one of the formats enabled in the
EncodingConfiguration instance it gets from the media service. With
multiple configurations now possible, and just a default one in
MediaService this creates a problem.

Attached is a fix that makes it use all available formats, instead of
just the enabled ones.

OK I see.

I have just applied, committed and acked this. Thanks!

I'll be applying some other changes on the EncodingConfiguration stuff
shortly, but I'll probably come back to them in another thread.

Thanks!
Emil